Skip to content

Commit

Permalink
test(de): Verify #425 is fixed by #457
Browse files Browse the repository at this point in the history
PR #457 changed out the parser to `toml_edit` which had a lot of span improvements done, including addressing this.

Fixes #425
  • Loading branch information
epage committed Jan 18, 2023
1 parent 21fdbab commit 25294b7
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 25294b7

Please sign in to comment.