Skip to content

Commit

Permalink
Test newtype key
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Aug 18, 2019
1 parent 81fa4e8 commit 9a5f273
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ where
value
}

#[derive(Debug, Deserialize)]
struct V {
used: (),
}

#[test]
fn test_readme() {
#[derive(Debug, PartialEq, Deserialize)]
Expand Down Expand Up @@ -75,11 +80,6 @@ fn test_int_key() {
a: Map<usize, V>,
}

#[derive(Debug, Deserialize)]
struct V {
used: (),
}

let json = r#"{
"a": {
"2": {
Expand All @@ -92,3 +92,21 @@ fn test_int_key() {
let ignored = &["a.2.unused"];
assert_ignored::<Test>(json, ignored);
}

#[test]
fn test_newtype_key() {
type Test = Map<Key, V>;

#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Deserialize)]
struct Key(&'static str);

let json = r#"{
"k": {
"used": null,
"unused": null
}
}"#;

let ignored = &["k.unused"];
assert_ignored::<Test>(json, ignored);
}

0 comments on commit 9a5f273

Please sign in to comment.