Skip to content

Commit

Permalink
Add test for flattened unit
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 10, 2020
1 parent 53b9871 commit 26186bd
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test_suite/tests/test_annotations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1967,6 +1967,29 @@ fn test_flatten_map_twice() {
);
}

#[test]
fn test_flatten_unit() {
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct Response<T> {
#[serde(flatten)]
data: T,
status: usize,
}

assert_tokens(
&Response {
data: (),
status: 0,
},
&[
Token::Map { len: None },
Token::Str("status"),
Token::U64(0),
Token::MapEnd,
],
);
}

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

0 comments on commit 26186bd

Please sign in to comment.