From 7c0e6bd18f28eb15c622f7d3bb08a119ffe26929 Mon Sep 17 00:00:00 2001 From: Mingun Date: Mon, 7 Aug 2023 22:55:35 +0500 Subject: [PATCH] Reuse type in struct_variant_containing_unit_variant --- .../tests/test_enum_internally_tagged.rs | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/test_suite/tests/test_enum_internally_tagged.rs b/test_suite/tests/test_enum_internally_tagged.rs index 904985d3..900a9b33 100644 --- a/test_suite/tests/test_enum_internally_tagged.rs +++ b/test_suite/tests/test_enum_internally_tagged.rs @@ -42,6 +42,7 @@ enum InternallyTagged { NewtypeStruct(Struct), NewtypeEnum(Enum), Struct { a: u8 }, + StructEnum { enum_: Enum }, } #[test] @@ -184,7 +185,8 @@ fn wrong_tag() { `NewtypeMap`, \ `NewtypeStruct`, \ `NewtypeEnum`, \ - `Struct`", + `Struct`, \ + `StructEnum`", ); } @@ -460,12 +462,6 @@ mod string_and_bytes { #[test] fn struct_variant_containing_unit_variant() { - #[derive(Debug, PartialEq, Serialize, Deserialize)] - #[serde(tag = "tag")] - enum Message { - Log { level: Enum }, - } - assert_de_tokens( &Enum::Unit, &[ @@ -475,18 +471,18 @@ fn struct_variant_containing_unit_variant() { ], ); - let value = Message::Log { level: Enum::Unit }; + let value = InternallyTagged::StructEnum { enum_: Enum::Unit }; assert_de_tokens( &value, &[ Token::Struct { - name: "Message", + name: "InternallyTagged", len: 2, }, Token::Str("tag"), - Token::Str("Log"), - Token::Str("level"), + Token::Str("StructEnum"), + Token::Str("enum_"), Token::Enum { name: "Enum" }, Token::BorrowedStr("Unit"), Token::Unit, @@ -499,8 +495,8 @@ fn struct_variant_containing_unit_variant() { &[ Token::Map { len: Some(2) }, Token::Str("tag"), - Token::Str("Log"), - Token::Str("level"), + Token::Str("StructEnum"), + Token::Str("enum_"), Token::Enum { name: "Enum" }, Token::BorrowedStr("Unit"), Token::Unit, @@ -512,8 +508,8 @@ fn struct_variant_containing_unit_variant() { &value, &[ Token::Seq { len: Some(2) }, - Token::Str("Log"), - Token::Enum { name: "Enum" }, + Token::Str("StructEnum"), // tag + Token::Enum { name: "Enum" }, // enum_ Token::BorrowedStr("Unit"), Token::Unit, Token::SeqEnd,