summaryrefslogtreecommitdiffstats
path: root/vendor/toml_edit-0.19.11/tests/testsuite/stackoverflow.rs
blob: de4c72262af5a51fbd044026bb9393ca3114e33b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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);
    }
}