diff --git a/test_suite/tests/test_enum_internally_tagged.rs b/test_suite/tests/test_enum_internally_tagged.rs index cf39ebe3..e7beae0b 100644 --- a/test_suite/tests/test_enum_internally_tagged.rs +++ b/test_suite/tests/test_enum_internally_tagged.rs @@ -23,6 +23,14 @@ struct Struct { f: u8, } +#[derive(Debug, PartialEq, Serialize, Deserialize)] +enum Enum { + Unit, + Newtype(u8), + Tuple(u8, u8), + Struct { f: u8 }, +} + #[derive(Debug, PartialEq, Serialize, Deserialize)] #[serde(tag = "tag")] enum InternallyTagged { @@ -450,28 +458,25 @@ mod string_and_bytes { #[test] fn struct_variant_containing_unit_variant() { - #[derive(Debug, PartialEq, Serialize, Deserialize)] - pub enum Level { - Info, - } - #[derive(Debug, PartialEq, Serialize, Deserialize)] #[serde(tag = "tag")] - pub enum Message { - Log { level: Level }, + enum Message { + Log { level: Enum }, } assert_de_tokens( - &Level::Info, + &Enum::Unit, &[ - Token::Enum { name: "Level" }, - Token::BorrowedStr("Info"), + Token::Enum { name: "Enum" }, + Token::BorrowedStr("Unit"), Token::Unit, ], ); + let value = Message::Log { level: Enum::Unit }; + assert_de_tokens( - &Message::Log { level: Level::Info }, + &value, &[ Token::Struct { name: "Message", @@ -480,34 +485,34 @@ fn struct_variant_containing_unit_variant() { Token::Str("tag"), Token::Str("Log"), Token::Str("level"), - Token::Enum { name: "Level" }, - Token::BorrowedStr("Info"), + Token::Enum { name: "Enum" }, + Token::BorrowedStr("Unit"), Token::Unit, Token::StructEnd, ], ); assert_de_tokens( - &Message::Log { level: Level::Info }, + &value, &[ Token::Map { len: Some(2) }, Token::Str("tag"), Token::Str("Log"), Token::Str("level"), - Token::Enum { name: "Level" }, - Token::BorrowedStr("Info"), + Token::Enum { name: "Enum" }, + Token::BorrowedStr("Unit"), Token::Unit, Token::MapEnd, ], ); assert_de_tokens( - &Message::Log { level: Level::Info }, + &value, &[ Token::Seq { len: Some(2) }, Token::Str("Log"), - Token::Enum { name: "Level" }, - Token::BorrowedStr("Info"), + Token::Enum { name: "Enum" }, + Token::BorrowedStr("Unit"), Token::Unit, Token::SeqEnd, ], @@ -546,14 +551,6 @@ fn newtype_variant_containing_externally_tagged_enum() { Inner(Enum), } - #[derive(Debug, PartialEq, Serialize, Deserialize)] - enum Enum { - Unit, - Newtype(u8), - Tuple(u8, u8), - Struct { f: u8 }, - } - assert_tokens( &Outer::Inner(Enum::Unit), &[