Group Newtype variant checks in test_adjacently_tagged_enum together

This commit is contained in:
Mingun 2023-08-14 01:57:15 +05:00 committed by Mingun
parent 5e37ade519
commit 5a359e10f4

View File

@ -174,6 +174,44 @@ fn test_adjacently_tagged_enum() {
], ],
); );
// integer field keys
assert_de_tokens(
&AdjacentlyTagged::Newtype::<u8>(1),
&[
Token::Struct {
name: "AdjacentlyTagged",
len: 2,
},
Token::U64(1), // content field
Token::U8(1),
Token::U64(0), // tag field
Token::UnitVariant {
name: "AdjacentlyTagged",
variant: "Newtype",
},
Token::StructEnd,
],
);
// byte-array field keys
assert_de_tokens(
&AdjacentlyTagged::Newtype::<u8>(1),
&[
Token::Struct {
name: "AdjacentlyTagged",
len: 2,
},
Token::Bytes(b"c"),
Token::U8(1),
Token::Bytes(b"t"),
Token::UnitVariant {
name: "AdjacentlyTagged",
variant: "Newtype",
},
Token::StructEnd,
],
);
// tuple with tag first // tuple with tag first
assert_tokens( assert_tokens(
&AdjacentlyTagged::Tuple::<u8>(1, 1), &AdjacentlyTagged::Tuple::<u8>(1, 1),
@ -267,44 +305,6 @@ fn test_adjacently_tagged_enum() {
Token::StructEnd, Token::StructEnd,
], ],
); );
// integer field keys
assert_de_tokens(
&AdjacentlyTagged::Newtype::<u8>(1),
&[
Token::Struct {
name: "AdjacentlyTagged",
len: 2,
},
Token::U64(1), // content field
Token::U8(1),
Token::U64(0), // tag field
Token::UnitVariant {
name: "AdjacentlyTagged",
variant: "Newtype",
},
Token::StructEnd,
],
);
// byte-array field keys
assert_de_tokens(
&AdjacentlyTagged::Newtype::<u8>(1),
&[
Token::Struct {
name: "AdjacentlyTagged",
len: 2,
},
Token::Bytes(b"c"),
Token::U8(1),
Token::Bytes(b"t"),
Token::UnitVariant {
name: "AdjacentlyTagged",
variant: "Newtype",
},
Token::StructEnd,
],
);
} }
#[test] #[test]