Skip to content

Commit

Permalink
Add additional checks for unit and newtype_unit tests
Browse files Browse the repository at this point in the history
- check that unit variant can be deserialized from a map
- check that newtype variant with unit can be deserialized from a struct
  • Loading branch information
Mingun committed Aug 6, 2024
1 parent a7bae65 commit 3bbc95c
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions test_suite/tests/test_enum_internally_tagged.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,25 @@ fn unit() {
],
);

assert_de_tokens(
&InternallyTagged::Unit,
&[
Token::Map { len: Some(1) },
Token::Str("tag"),
Token::Str("Unit"),
Token::MapEnd,
],
);
assert_de_tokens(
&InternallyTagged::Unit,
&[
Token::Map { len: Some(1) },
Token::BorrowedStr("tag"),
Token::BorrowedStr("Unit"),
Token::MapEnd,
],
);

assert_de_tokens(
&InternallyTagged::Unit,
&[
Expand Down Expand Up @@ -109,6 +128,31 @@ fn newtype_unit() {
Token::MapEnd,
],
);

assert_de_tokens(
&value,
&[
Token::Struct {
name: "InternallyTagged",
len: 1,
},
Token::Str("tag"),
Token::Str("NewtypeUnit"),
Token::StructEnd,
],
);
assert_de_tokens(
&value,
&[
Token::Struct {
name: "InternallyTagged",
len: 1,
},
Token::BorrowedStr("tag"),
Token::BorrowedStr("NewtypeUnit"),
Token::StructEnd,
],
);
}

#[test]
Expand Down

0 comments on commit 3bbc95c

Please sign in to comment.