Group newtype and newtype_with_newtype tests

This commit is contained in:
Mingun 2024-08-11 23:11:31 +05:00 committed by Mingun
parent 5445f1741b
commit df07751e6f

View File

@ -216,6 +216,33 @@ fn newtype() {
); );
} }
#[test]
fn newtype_with_newtype() {
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct NewtypeStruct(u32);
assert_de_tokens(
&AdjacentlyTagged::Newtype(NewtypeStruct(5)),
&[
Token::Struct {
name: "AdjacentlyTagged",
len: 2,
},
Token::Str("c"),
Token::NewtypeStruct {
name: "NewtypeStruct",
},
Token::U32(5),
Token::Str("t"),
Token::UnitVariant {
name: "AdjacentlyTagged",
variant: "Newtype",
},
Token::StructEnd,
],
);
}
#[test] #[test]
fn tuple() { fn tuple() {
let value = AdjacentlyTagged::Tuple::<u8>(1, 1); let value = AdjacentlyTagged::Tuple::<u8>(1, 1);
@ -477,33 +504,6 @@ fn partially_untagged() {
// TODO test error output // TODO test error output
} }
#[test]
fn newtype_with_newtype() {
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct NewtypeStruct(u32);
assert_de_tokens(
&AdjacentlyTagged::Newtype(NewtypeStruct(5)),
&[
Token::Struct {
name: "AdjacentlyTagged",
len: 2,
},
Token::Str("c"),
Token::NewtypeStruct {
name: "NewtypeStruct",
},
Token::U32(5),
Token::Str("t"),
Token::UnitVariant {
name: "AdjacentlyTagged",
variant: "Newtype",
},
Token::StructEnd,
],
);
}
#[test] #[test]
fn deny_unknown_fields() { fn deny_unknown_fields() {
#[derive(Debug, PartialEq, Deserialize)] #[derive(Debug, PartialEq, Deserialize)]