@@ -220,13 +220,18 @@ TEST_F(TestFixedShapeTensorType, MetadataSerializationRoundtrip) {
220220 R"( {"shape":[3],"dim_names":["x","y"]})" ,
221221 " Invalid dim_names" );
222222
223- // Validate shape values must be integers
223+ // Validate shape values must be integers. Error message should include the
224+ // JSON type name of the offending value.
224225 CheckDeserializationRaises (ext_type_, storage_type, R"( {"shape":[3.5,4]})" ,
225- " shape must contain integers" );
226+ " shape must contain integers, got Number " );
226227 CheckDeserializationRaises (ext_type_, storage_type, R"( {"shape":["3","4"]})" ,
227- " shape must contain integers" );
228+ " shape must contain integers, got String " );
228229 CheckDeserializationRaises (ext_type_, storage_type, R"( {"shape":[null]})" ,
229- " shape must contain integers" );
230+ " shape must contain integers, got Null" );
231+ CheckDeserializationRaises (ext_type_, storage_type, R"( {"shape":[true]})" ,
232+ " shape must contain integers, got True" );
233+ CheckDeserializationRaises (ext_type_, storage_type, R"( {"shape":[false]})" ,
234+ " shape must contain integers, got False" );
230235
231236 // Validate shape values must be non-negative
232237 CheckDeserializationRaises (ext_type_, fixed_size_list (int64 (), 1 ), R"( {"shape":[-1]})" ,
@@ -239,10 +244,16 @@ TEST_F(TestFixedShapeTensorType, MetadataSerializationRoundtrip) {
239244 // Validate permutation member must be an array with integer values
240245 CheckDeserializationRaises (ext_type_, storage_type,
241246 R"( {"shape":[3,4],"permutation":"invalid"})" ,
242- " permutation must be an array" );
247+ " permutation must be an array, got String" );
248+ CheckDeserializationRaises (ext_type_, storage_type,
249+ R"( {"shape":[3,4],"permutation":{"a":1}})" ,
250+ " permutation must be an array, got Object" );
243251 CheckDeserializationRaises (ext_type_, storage_type,
244252 R"( {"shape":[3,4],"permutation":[1.5,0.5]})" ,
245- " permutation must contain integers" );
253+ " permutation must contain integers, got Number" );
254+ CheckDeserializationRaises (ext_type_, storage_type,
255+ R"( {"shape":[3,4],"permutation":["a","b"]})" ,
256+ " permutation must contain integers, got String" );
246257
247258 // Validate permutation values must be unique integers in [0, N-1]
248259 CheckDeserializationRaises (ext_type_, storage_type,
@@ -258,10 +269,13 @@ TEST_F(TestFixedShapeTensorType, MetadataSerializationRoundtrip) {
258269 // Validate dim_names member must be an array with string values
259270 CheckDeserializationRaises (ext_type_, storage_type,
260271 R"( {"shape":[3,4],"dim_names":"invalid"})" ,
261- " dim_names must be an array" );
272+ " dim_names must be an array, got String " );
262273 CheckDeserializationRaises (ext_type_, storage_type,
263274 R"( {"shape":[3,4],"dim_names":[1,2]})" ,
264- " dim_names must contain strings" );
275+ " dim_names must contain strings, got Number" );
276+ CheckDeserializationRaises (ext_type_, storage_type,
277+ R"( {"shape":[3,4],"dim_names":[null,null]})" ,
278+ " dim_names must contain strings, got Null" );
265279}
266280
267281TEST_F (TestFixedShapeTensorType, MakeValidatesShape) {
@@ -847,6 +861,32 @@ TEST_F(TestVariableShapeTensorType, MetadataSerializationRoundtrip) {
847861 " Invalid: permutation" );
848862 CheckDeserializationRaises (ext_type_, storage_type, R"( {"dim_names":["x","y"]})" ,
849863 " Invalid: dim_names" );
864+
865+ // Validate permutation member must be an array with integer values. Error
866+ // message should include the JSON type name of the offending value.
867+ CheckDeserializationRaises (ext_type_, storage_type, R"( {"permutation":"invalid"})" ,
868+ " permutation must be an array, got String" );
869+ CheckDeserializationRaises (ext_type_, storage_type, R"( {"permutation":[1.5,0.5,2.5]})" ,
870+ " permutation must contain integers, got Number" );
871+ CheckDeserializationRaises (ext_type_, storage_type,
872+ R"( {"permutation":[null,null,null]})" ,
873+ " permutation must contain integers, got Null" );
874+
875+ // Validate dim_names member must be an array with string values
876+ CheckDeserializationRaises (ext_type_, storage_type, R"( {"dim_names":"invalid"})" ,
877+ " dim_names must be an array, got String" );
878+ CheckDeserializationRaises (ext_type_, storage_type, R"( {"dim_names":[1,2,3]})" ,
879+ " dim_names must contain strings, got Number" );
880+
881+ // Validate uniform_shape member must be an array with integer-or-null values
882+ CheckDeserializationRaises (ext_type_, storage_type, R"( {"uniform_shape":"invalid"})" ,
883+ " uniform_shape must be an array, got String" );
884+ CheckDeserializationRaises (ext_type_, storage_type,
885+ R"( {"uniform_shape":[1.5,null,null]})" ,
886+ " uniform_shape must contain integers or nulls, got Number" );
887+ CheckDeserializationRaises (ext_type_, storage_type,
888+ R"( {"uniform_shape":["x",null,null]})" ,
889+ " uniform_shape must contain integers or nulls, got String" );
850890}
851891
852892TEST_F (TestVariableShapeTensorType, RoundtripBatch) {
0 commit comments