@@ -70,6 +70,12 @@ enum Animal {
70
70
AntHive ( Vec < String > ) ,
71
71
}
72
72
73
+ #[ derive( Clone , Debug , PartialEq , Serialize , Deserialize ) ]
74
+ enum BoardGame {
75
+ Chess ,
76
+ Checkers ,
77
+ }
78
+
73
79
#[ derive( Clone , Debug , PartialEq , Serialize , Deserialize ) ]
74
80
struct Inner {
75
81
a : ( ) ,
@@ -1304,12 +1310,14 @@ fn test_parse_option() {
1304
1310
fn test_parse_enum_errors ( ) {
1305
1311
test_parse_err :: < Animal > (
1306
1312
& [
1307
- ( "{}" , "expected value at line 1 column 2 " ) ,
1308
- ( "[]" , "expected value at line 1 column 1 " ) ,
1313
+ ( "{}" , "invalid value: empty map, expected enum variant at line 1 column 1 " ) ,
1314
+ ( "[]" , "invalid type: sequence, expected variant identifier at line 1 column 0 " ) ,
1309
1315
( "\" unknown\" " ,
1310
1316
"unknown variant `unknown`, expected one of `Dog`, `Frog`, `Cat`, `AntHive` at line 1 column 9" ) ,
1311
1317
( "{\" unknown\" :null}" ,
1312
1318
"unknown variant `unknown`, expected one of `Dog`, `Frog`, `Cat`, `AntHive` at line 1 column 10" ) ,
1319
+ ( "{\" AntHive\" : []" , "EOF while parsing an object at line 1 column 14" ) ,
1320
+ ( "{\" AntHive\" : []\" " , "expected `,` or `}` at line 1 column 14" ) ,
1313
1321
( "{\" Dog\" :" , "EOF while parsing a value at line 1 column 7" ) ,
1314
1322
( "{\" Dog\" :}" , "expected value at line 1 column 8" ) ,
1315
1323
( "{\" Dog\" :{}}" , "invalid type: map, expected unit at line 1 column 7" ) ,
@@ -1331,6 +1339,37 @@ fn test_parse_enum_errors() {
1331
1339
) ;
1332
1340
}
1333
1341
1342
+ #[ test]
1343
+ fn test_parse_value_less_enum_errors ( ) {
1344
+ test_parse_err :: < BoardGame > ( & [
1345
+ (
1346
+ "1" ,
1347
+ "invalid type: integer `1`, expected variant identifier at line 1 column 1" ,
1348
+ ) ,
1349
+ (
1350
+ "null" ,
1351
+ "invalid type: null, expected variant identifier at line 1 column 4" ,
1352
+ ) ,
1353
+ (
1354
+ "true" ,
1355
+ "invalid type: boolean `true`, expected variant identifier at line 1 column 4" ,
1356
+ ) ,
1357
+ (
1358
+ "[]" ,
1359
+ "invalid type: sequence, expected variant identifier at line 1 column 0" ,
1360
+ ) ,
1361
+ ( "{}" , "invalid value: empty map, expected enum variant" ) ,
1362
+ (
1363
+ "{\" unknown\" : \" unknown\" }" ,
1364
+ "unknown variant `unknown`, expected `Chess` or `Checkers` at line 1 column 10" ,
1365
+ ) ,
1366
+ (
1367
+ "{\" Chess\" : \" unknown\" }" ,
1368
+ "invalid type: string \" unknown\" , expected unit at line 1 column 19" ,
1369
+ ) ,
1370
+ ] ) ;
1371
+ }
1372
+
1334
1373
#[ test]
1335
1374
fn test_parse_enum ( ) {
1336
1375
test_parse_ok ( vec ! [
0 commit comments