diff --git a/crates/toml_edit/tests/stackoverflow.rs b/crates/toml_edit/tests/stackoverflow.rs index aa308086..de4c7226 100644 --- a/crates/toml_edit/tests/stackoverflow.rs +++ b/crates/toml_edit/tests/stackoverflow.rs @@ -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::(); + 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::(); + 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::(); + assert_eq!(document.is_ok(), is_ok, "depth: {}", depth); + } +}