From 25294b734d61fd800922059df0d74bf0bcee592c Mon Sep 17 00:00:00 2001 From: Ed Page Date: Wed, 18 Jan 2023 12:14:37 -0600 Subject: [PATCH] test(de): Verify #425 is fixed by #457 PR #457 changed out the parser to `toml_edit` which had a lot of span improvements done, including addressing this. Fixes #425 --- crates/toml/tests/testsuite/spanned.rs | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/crates/toml/tests/testsuite/spanned.rs b/crates/toml/tests/testsuite/spanned.rs index 430dd5ba..760c73aa 100644 --- a/crates/toml/tests/testsuite/spanned.rs +++ b/crates/toml/tests/testsuite/spanned.rs @@ -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::( + 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(), + ); +}