diff options
Diffstat (limited to 'vendor/toml_edit/tests/testsuite/stackoverflow.rs')
-rw-r--r-- | vendor/toml_edit/tests/testsuite/stackoverflow.rs | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/toml_edit/tests/testsuite/stackoverflow.rs b/vendor/toml_edit/tests/testsuite/stackoverflow.rs new file mode 100644 index 0000000..de4c722 --- /dev/null +++ b/vendor/toml_edit/tests/testsuite/stackoverflow.rs @@ -0,0 +1,54 @@ +#[test] +#[cfg(not(feature = "unbounded"))] +fn array_recursion_limit() { + let depths = [(1, true), (20, true), (300, false)]; + for (depth, is_ok) in depths { + let input = format!("x={}{}", &"[".repeat(depth), &"]".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_table_recursion_limit() { + let depths = [(1, true), (20, true), (300, false)]; + for (depth, is_ok) in depths { + let input = format!("x={}true{}", &"{ x = ".repeat(depth), &"}".repeat(depth)); + let document = input.parse::<toml_edit::Document>(); + 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); + } +} |