Skip to content

Commit

Permalink
test(serde): Show existing newtype key behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Sep 26, 2023
1 parent cb3eed5 commit 1bdf123
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions crates/toml/tests/testsuite/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,26 @@ fn newtype_variant() {
}
}

#[test]
#[should_panic = "invalid type: string \"x\", expected tuple struct NewType"]
fn newtype_key() {
#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Clone, Serialize, Deserialize)]
struct NewType(String);

type CustomKeyMap = std::collections::BTreeMap<NewType, u32>;

equivalent! {
[
(NewType("x".to_owned()), 1),
(NewType("y".to_owned()), 2),
].into_iter().collect::<CustomKeyMap>(),
map! {
x: Value::Integer(1),
y: Value::Integer(2)
},
}
}

#[derive(Debug, Default, PartialEq, Serialize, Deserialize)]
struct CanBeEmpty {
a: Option<String>,
Expand Down

0 comments on commit 1bdf123

Please sign in to comment.