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
|
use expect_test::{expect, Expect};
fn check(input: &str, expect: Expect) {
let fixture = test_utils::fixture::Fixture::parse(input);
let document = fixture.make_params().unwrap().0.document;
let data = crate::find_all(document);
expect.assert_debug_eq(&data);
}
#[test]
fn test_latex() {
check(
r#"
%! main.tex
\begin{document}
\section{Foo}
foo
\subsection{Bar}
bar
\section{Baz}
baz
\section{Qux}
\end{document}
|"#,
expect![[r#"
[
FoldingRange {
range: 16..116,
kind: Environment,
},
FoldingRange {
range: 34..76,
kind: Section,
},
FoldingRange {
range: 63..76,
kind: Section,
},
FoldingRange {
range: 89..102,
kind: Section,
},
FoldingRange {
range: 115..116,
kind: Section,
},
]
"#]],
);
}
#[test]
fn test_bibtex() {
check(
r#"
%! main.bib
some junk
here
@article{foo,
author = {bar},
title = {baz}
}
@string{foo = "bar"}
@comment{foo,
author = {bar},
title = {baz}
}
@preamble{"foo"}
|"#,
expect![[r#"
[
FoldingRange {
range: 28..68,
kind: Entry,
},
FoldingRange {
range: 82..90,
kind: Entry,
},
]
"#]],
);
}
|