Skip to content

Commit

Permalink
Merge pull request #409 from epage/test
Browse files Browse the repository at this point in the history
test(parser): Check  more overflow cases
  • Loading branch information
epage committed Dec 28, 2022
2 parents ce27cd7 + 87ee5f2 commit b0ad923
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions crates/toml_edit/tests/stackoverflow.rs
Expand Up @@ -19,3 +19,36 @@ fn inline_table_recursion_limit() {
assert_eq!(document.is_ok(), is_ok, "depth: {}", depth);
}
}

#[test]
#[cfg(not(feature = "unbounded"))]
fn table_key_recursion_limit() {
let depths = [(1, true), (20, true), (300, false)];
for (depth, is_ok) in depths {
let input = format!("[x{}]", &".x".repeat(depth));
let document = input.parse::<toml_edit::Document>();
assert_eq!(document.is_ok(), is_ok, "depth: {}", depth);
}
}

#[test]
#[cfg(not(feature = "unbounded"))]
fn dotted_key_recursion_limit() {
let depths = [(1, true), (20, true), (300, false)];
for (depth, is_ok) in depths {
let input = format!("x{} = true", &".x".repeat(depth));
let document = input.parse::<toml_edit::Document>();
assert_eq!(document.is_ok(), is_ok, "depth: {}", depth);
}
}

#[test]
#[cfg(not(feature = "unbounded"))]
fn inline_dotted_key_recursion_limit() {
let depths = [(1, true), (20, true), (300, false)];
for (depth, is_ok) in depths {
let input = format!("x = {{ x{} = true }}", &".x".repeat(depth));
let document = input.parse::<toml_edit::Document>();
assert_eq!(document.is_ok(), is_ok, "depth: {}", depth);
}
}

0 comments on commit b0ad923

Please sign in to comment.