1
#[cfg(feature = "indexmap")]
2
use ron::{de::from_str, Value};
3

            
4
#[test]
5
#[cfg(feature = "indexmap")]
6
2
fn test_order_preserved() {
7
2
    let file = r#"(
8
2
tasks: {
9
2
    "debug message": Dbg(
10
2
      msg: "test message. some text after it."
11
2
    ),
12
2
    "shell command": Shell(
13
2
      command: "ls",
14
2
      args: Some([
15
2
        "-l",
16
2
        "-h",
17
2
      ]),
18
2
      ch_dir: Some("/"),
19
2
    ),
20
2
},
21
2
)
22
2
"#;
23
2

            
24
2
    let value: Value = from_str(file).unwrap();
25
2
    match value {
26
2
        Value::Map(map) => match &map[&Value::String("tasks".to_owned())] {
27
2
            Value::Map(map) => {
28
2
                assert_eq!(
29
2
                    *map.keys().next().unwrap(),
30
2
                    Value::String("debug message".to_string())
31
2
                );
32
2
                assert_eq!(
33
2
                    *map.keys().nth(1).unwrap(),
34
2
                    Value::String("shell command".to_string())
35
2
                );
36
            }
37
            _ => panic!(), // GRCOV_EXCL_LINE
38
        },
39
        _ => panic!(), // GRCOV_EXCL_LINE
40
    }
41

            
42
2
    let file = r#"(
43
2
tasks: {
44
2
    "shell command": Shell(
45
2
      command: "ls",
46
2
      args: Some([
47
2
        "-l",
48
2
        "-h",
49
2
      ]),
50
2
      ch_dir: Some("/")
51
2
    ),
52
2
    "debug message": Dbg(
53
2
      msg: "test message. some text after it."
54
2
    ),
55
2
}
56
2
)
57
2
"#;
58
2

            
59
2
    let value: Value = from_str(file).unwrap();
60
2
    match value {
61
2
        Value::Map(map) => match &map[&Value::String("tasks".to_owned())] {
62
2
            Value::Map(map) => {
63
2
                assert_eq!(
64
2
                    *map.keys().next().unwrap(),
65
2
                    Value::String("shell command".to_string())
66
2
                );
67
2
                assert_eq!(
68
2
                    *map.keys().nth(1).unwrap(),
69
2
                    Value::String("debug message".to_string())
70
2
                );
71
            }
72
            _ => panic!(), // GRCOV_EXCL_LINE
73
        },
74
        _ => panic!(), // GRCOV_EXCL_LINE
75
    }
76
2
}