Add regression test for issue #2565
failures (1): regression::issue2565::simple_variant
This commit is contained in:
parent
9b868ef831
commit
24614e44bf
41
test_suite/tests/regression/issue2565.rs
Normal file
41
test_suite/tests/regression/issue2565.rs
Normal file
@ -0,0 +1,41 @@
|
||||
use serde_derive::{Serialize, Deserialize};
|
||||
use serde_test::{assert_tokens, Token};
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||
enum Enum {
|
||||
Simple {
|
||||
a: i32,
|
||||
},
|
||||
Flatten {
|
||||
#[serde(flatten)]
|
||||
flatten: (),
|
||||
a: i32,
|
||||
},
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn simple_variant() {
|
||||
assert_tokens(
|
||||
&Enum::Simple { a: 42 },
|
||||
&[
|
||||
Token::StructVariant { name: "Enum", variant: "Simple", len: 1 },
|
||||
Token::Str("a"),
|
||||
Token::I32(42),
|
||||
Token::StructVariantEnd,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn flatten_variant() {
|
||||
assert_tokens(
|
||||
&Enum::Flatten { flatten: (), a: 42 },
|
||||
&[
|
||||
Token::NewtypeVariant { name: "Enum", variant: "Flatten" },
|
||||
Token::Map { len: None },
|
||||
Token::Str("a"),
|
||||
Token::I32(42),
|
||||
Token::MapEnd,
|
||||
]
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue
Block a user