From 8c60f5aea7238bf21a6dc82aa497e8c49db0a0cc Mon Sep 17 00:00:00 2001 From: Mingun Date: Sat, 22 Apr 2023 20:54:00 +0500 Subject: [PATCH] Reorder enum variants and tests to canonical order (Unit, Newtype, Tuple, Struct) --- test_suite/tests/test_macros.rs | 88 ++++++++++++++++----------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/test_suite/tests/test_macros.rs b/test_suite/tests/test_macros.rs index 64f0875d..9404c383 100644 --- a/test_suite/tests/test_macros.rs +++ b/test_suite/tests/test_macros.rs @@ -693,39 +693,11 @@ mod internally_tagged_enum { #[derive(Debug, PartialEq, Serialize, Deserialize)] #[serde(tag = "type")] enum InternallyTagged { - Struct { a: u8 }, Unit, - NewtypeMap(BTreeMap), NewtypeNewtype(Newtype), + NewtypeMap(BTreeMap), NewtypeStruct(Struct), - } - - #[test] - fn struct_() { - assert_tokens( - &InternallyTagged::Struct { a: 1 }, - &[ - Token::Struct { - name: "InternallyTagged", - len: 2, - }, - Token::Str("type"), - Token::Str("Struct"), - Token::Str("a"), - Token::U8(1), - Token::StructEnd, - ], - ); - - assert_de_tokens( - &InternallyTagged::Struct { a: 1 }, - &[ - Token::Seq { len: Some(2) }, - Token::Str("Struct"), - Token::U8(1), - Token::SeqEnd, - ], - ); + Struct { a: u8 }, } #[test] @@ -753,6 +725,19 @@ mod internally_tagged_enum { ); } + #[test] + fn newtype_newtype() { + assert_tokens( + &InternallyTagged::NewtypeNewtype(Newtype(BTreeMap::new())), + &[ + Token::Map { len: Some(1) }, + Token::Str("type"), + Token::Str("NewtypeNewtype"), + Token::MapEnd, + ], + ); + } + #[test] fn newtype_map() { assert_tokens( @@ -777,19 +762,6 @@ mod internally_tagged_enum { ); } - #[test] - fn newtype_newtype() { - assert_tokens( - &InternallyTagged::NewtypeNewtype(Newtype(BTreeMap::new())), - &[ - Token::Map { len: Some(1) }, - Token::Str("type"), - Token::Str("NewtypeNewtype"), - Token::MapEnd, - ], - ); - } - #[test] fn newtype_struct() { assert_tokens( @@ -818,6 +790,34 @@ mod internally_tagged_enum { ); } + #[test] + fn struct_() { + assert_tokens( + &InternallyTagged::Struct { a: 1 }, + &[ + Token::Struct { + name: "InternallyTagged", + len: 2, + }, + Token::Str("type"), + Token::Str("Struct"), + Token::Str("a"), + Token::U8(1), + Token::StructEnd, + ], + ); + + assert_de_tokens( + &InternallyTagged::Struct { a: 1 }, + &[ + Token::Seq { len: Some(2) }, + Token::Str("Struct"), + Token::U8(1), + Token::SeqEnd, + ], + ); + } + #[test] fn wrong_tag() { assert_de_tokens_error::( @@ -832,7 +832,7 @@ mod internally_tagged_enum { Token::Str("Z"), Token::MapEnd, ], - "unknown variant `Z`, expected one of `Struct`, `Unit`, `NewtypeMap`, `NewtypeNewtype`, `NewtypeStruct`", + "unknown variant `Z`, expected one of `Unit`, `NewtypeNewtype`, `NewtypeMap`, `NewtypeStruct`, `Struct`", ); }