Skip to content

Commit

Permalink
Add tests for #2387
Browse files Browse the repository at this point in the history
  • Loading branch information
bebecue committed Mar 7, 2023
1 parent f5e0fbc commit 01da3f7
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions test_suite/tests/test_annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2658,6 +2658,68 @@ fn test_flatten_any_after_flatten_struct() {
);
}

#[test]
fn test_alias_in_flatten_context() {
#[derive(Debug, PartialEq, Deserialize)]
struct Outer {
#[serde(flatten)]
a: AliasStruct,
b: i32,
}

assert_de_tokens(
&Outer {
a: AliasStruct {
a1: 1,
a2: 2,
a4: 4,
},
b: 7,
},
&[
Token::Struct {
name: "Outer",
len: 4,
},
Token::Str("a1"),
Token::I32(1),
Token::Str("a2"),
Token::I32(2),
Token::Str("a5"),
Token::I32(4),
Token::Str("b"),
Token::I32(7),
Token::StructEnd,
],
);

assert_de_tokens(
&Outer {
a: AliasStruct {
a1: 1,
a2: 2,
a4: 4,
},
b: 7,
},
&[
Token::Struct {
name: "Outer",
len: 4,
},
Token::Str("a1"),
Token::I32(1),
Token::Str("a2"),
Token::I32(2),
Token::Str("a6"),
Token::I32(4),
Token::Str("b"),
Token::I32(7),
Token::StructEnd,
],
);
}

#[test]
fn test_expecting_message() {
#[derive(Deserialize, PartialEq, Debug)]
Expand Down

0 comments on commit 01da3f7

Please sign in to comment.