summaryrefslogtreecommitdiffstats
path: root/vendor/toml_edit-0.19.11/tests/testsuite/stackoverflow.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/toml_edit-0.19.11/tests/testsuite/stackoverflow.rs')
-rw-r--r--vendor/toml_edit-0.19.11/tests/testsuite/stackoverflow.rs54
1 files changed, 54 insertions, 0 deletions
diff --git a/vendor/toml_edit-0.19.11/tests/testsuite/stackoverflow.rs b/vendor/toml_edit-0.19.11/tests/testsuite/stackoverflow.rs
new file mode 100644
index 000000000..de4c72262
--- /dev/null
+++ b/vendor/toml_edit-0.19.11/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);
+ }
+}