Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid roundtrip scenario, outputting invalid tables #799

Open
epage opened this issue Oct 7, 2024 · 0 comments
Open

Invalid roundtrip scenario, outputting invalid tables #799

epage opened this issue Oct 7, 2024 · 0 comments
Labels
A-edit Area: TOML editing API A-output Area: Outputting TOML C-bug Category: Things not working as expected

Comments

@epage
Copy link
Member

epage commented Oct 7, 2024

#[test]
fn fuzzed_42537130() {
    let data = r#"
[_.s.K]
[_]
s.0.0=2
[_.s.0.1]
[_.s]
"#;
    let doc = data.parse::<toml_edit::DocumentMut>().unwrap();
    let toml = doc.to_string();
    let doc = toml.parse::<toml_edit::DocumentMut>();
    assert!(
        doc.is_ok(),
        "parse error: {}

data:
```toml
{data}
```

doc.to_string():
```toml
{}
```",
        doc.unwrap_err(),
        toml
    );
    let doc = doc.unwrap();
    assert_eq!(
        doc.to_string(),
        toml,
        "data:
```toml
{data}
```
"
    );
}
---- invalid::fuzzed_42537130 stdout ----
thread 'invalid::fuzzed_42537130' panicked at crates/toml_edit/tests/testsuite/invalid.rs:316:5:
parse error: TOML parse error at line 6, column 1
  |
6 | 0.0=2
  | ^
duplicate key `0`

data:

[_.s.K]
[_]
s.0.0=2
[_.s.0.1]
[_.s]

doc.to_string():

[_.s.K]
[_]
[_.s.0.1]
[_.s]
0.0=2
@epage epage added C-bug Category: Things not working as expected A-output Area: Outputting TOML A-edit Area: TOML editing API labels Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-edit Area: TOML editing API A-output Area: Outputting TOML C-bug Category: Things not working as expected
Projects
None yet
Development

No branches or pull requests

1 participant