Skip to content

Commit

Permalink
Merge pull request #463 from epage/test
Browse files Browse the repository at this point in the history
test(de): Verify #425 is fixed by #457
  • Loading branch information
epage authored Jan 18, 2023
2 parents 21fdbab + 25294b7 commit 8462fda
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions crates/toml/tests/testsuite/spanned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,30 @@ fn test_spanned_array() {
}
}
}

#[test]
fn deny_unknown_fields() {
#[derive(Debug, serde::Deserialize)]
#[serde(deny_unknown_fields)]
struct Example {
#[allow(dead_code)]
real: u32,
}

let error = toml::from_str::<Example>(
r#"# my comment
# bla bla bla
fake = 1"#,
)
.unwrap_err();
snapbox::assert_eq(
"\
TOML parse error at line 3, column 1
|
3 | fake = 1
| ^^^^
unknown field `fake`, expected `real`
",
error.to_string(),
);
}

0 comments on commit 8462fda

Please sign in to comment.