Skip to content

Commit

Permalink
Merge pull request #436 from epage/error
Browse files Browse the repository at this point in the history
test(edit): Check specific parse errors
  • Loading branch information
epage authored Jan 13, 2023
2 parents 7b8138b + 831106e commit 3666e77
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
44 changes: 44 additions & 0 deletions crates/toml_edit/tests/testsuite/invalid.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#[test]
fn incomplete_inline_table_issue_296() {
let err = "native = {".parse::<toml_edit::Document>().unwrap_err();
snapbox::assert_eq(
r#"TOML parse error at line 1, column 11
|
1 | native = {
| ^
Invalid inline table
Expected `}`
"#,
err.to_string(),
);
}

#[test]
fn bare_value_disallowed_issue_293() {
let err = "value=zzz".parse::<toml_edit::Document>().unwrap_err();
snapbox::assert_eq(
r#"TOML parse error at line 1, column 7
|
1 | value=zzz
| ^
Invalid string
Expected `"`, `'`
"#,
err.to_string(),
);
}

#[test]
fn bare_value_in_array_disallowed_issue_293() {
let err = "value=[zzz]".parse::<toml_edit::Document>().unwrap_err();
snapbox::assert_eq(
r#"TOML parse error at line 1, column 8
|
1 | value=[zzz]
| ^
Invalid array
Expected `]`
"#,
err.to_string(),
);
}
1 change: 1 addition & 0 deletions crates/toml_edit/tests/testsuite/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ mod convert;
mod edit;
mod enum_external_deserialize;
mod formatter;
mod invalid;
mod macros;
mod parse;
mod pretty;
Expand Down

0 comments on commit 3666e77

Please sign in to comment.