Add additional checks for unit and newtype_unit tests
- check that unit variant can be deserialized from a map - check that newtype variant with unit can be deserialized from a struct
This commit is contained in:
parent
71ed1f2f12
commit
2adb0e99b0
@ -73,6 +73,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,
|
||||
&[
|
||||
@ -113,6 +132,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]
|
||||
|
Loading…
Reference in New Issue
Block a user