1 #[test]
2 #[cfg(not(feature = "unbounded"))]
array_recursion_limit()3 fn array_recursion_limit() {
4 let depths = [(1, true), (20, true), (300, false)];
5 for (depth, is_ok) in depths {
6 let input = format!("x={}{}", &"[".repeat(depth), &"]".repeat(depth));
7 let document = input.parse::<toml_edit::DocumentMut>();
8 assert_eq!(document.is_ok(), is_ok, "depth: {}", depth);
9 }
10 }
11
12 #[test]
13 #[cfg(not(feature = "unbounded"))]
inline_table_recursion_limit()14 fn inline_table_recursion_limit() {
15 let depths = [(1, true), (20, true), (300, false)];
16 for (depth, is_ok) in depths {
17 let input = format!("x={}true{}", &"{ x = ".repeat(depth), &"}".repeat(depth));
18 let document = input.parse::<toml_edit::DocumentMut>();
19 assert_eq!(document.is_ok(), is_ok, "depth: {}", depth);
20 }
21 }
22
23 #[test]
24 #[cfg(not(feature = "unbounded"))]
table_key_recursion_limit()25 fn table_key_recursion_limit() {
26 let depths = [(1, true), (20, true), (300, false)];
27 for (depth, is_ok) in depths {
28 let input = format!("[x{}]", &".x".repeat(depth));
29 let document = input.parse::<toml_edit::DocumentMut>();
30 assert_eq!(document.is_ok(), is_ok, "depth: {}", depth);
31 }
32 }
33
34 #[test]
35 #[cfg(not(feature = "unbounded"))]
dotted_key_recursion_limit()36 fn dotted_key_recursion_limit() {
37 let depths = [(1, true), (20, true), (300, false)];
38 for (depth, is_ok) in depths {
39 let input = format!("x{} = true", &".x".repeat(depth));
40 let document = input.parse::<toml_edit::DocumentMut>();
41 assert_eq!(document.is_ok(), is_ok, "depth: {}", depth);
42 }
43 }
44
45 #[test]
46 #[cfg(not(feature = "unbounded"))]
inline_dotted_key_recursion_limit()47 fn inline_dotted_key_recursion_limit() {
48 let depths = [(1, true), (20, true), (300, false)];
49 for (depth, is_ok) in depths {
50 let input = format!("x = {{ x{} = true }}", &".x".repeat(depth));
51 let document = input.parse::<toml_edit::DocumentMut>();
52 assert_eq!(document.is_ok(), is_ok, "depth: {}", depth);
53 }
54 }
55