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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
mod check_gir;
mod errors;
mod utils;
pub use check_gir::{check_gir_content, check_gir_file};
pub use errors::Errors;
#[test]
fn simple_check() {
let content = r#"something = [
test1,
test3,
test2,
]"#;
let errors = check_gir_content(content);
assert_eq!(errors.nb_errors, 1);
}
#[test]
fn simple_check2() {
let content = r#"
[[object]]
name = "abc"
[[object.func]]
data = "lol"
[[object]]
name = "aac"
[[object.func]]
data = "another"
"#;
let errors = check_gir_content(content);
assert_eq!(errors.nb_errors, 1);
}
#[test]
fn simple_check3() {
let content = r#"something = [
test1,
test2,
test2
]"#;
let errors = check_gir_content(content);
assert_eq!(errors.nb_errors, 0);
}
#[test]
fn simple_check4() {
let content = r#"something = [
"test1",
"test3",
"test2",
]"#;
let errors = check_gir_content(content);
assert_eq!(errors.nb_errors, 1);
}
#[test]
fn check_order_with_comments() {
let content = r#"something = [
"test1",
#just a comment
# on multiple lines
"test3",
"test2",
]"#;
let errors = check_gir_content(content);
assert_eq!(errors.nb_errors, 1);
assert_eq!(
errors.to_string(),
r#"ERROR: "test3" should be after "test2"
== Expected output ==
something = [
"test1",
"test2",
#just a comment
# on multiple lines
"test3",
]"#
);
}
#[test]
fn check_order_with_comments2() {
let content = r#"something = [
#just a comment
# on multiple lines
"test3",
"test1",
"test2",
]"#;
let errors = check_gir_content(content);
assert_eq!(errors.nb_errors, 1);
assert_eq!(
errors.to_string(),
r#"ERROR: "test3" should be after "test1"
== Expected output ==
something = [
"test1",
"test2",
#just a comment
# on multiple lines
"test3",
]"#
);
}