summaryrefslogtreecommitdiff
path: root/support/texlab/crates/folding/src/tests.rs
diff options
context:
space:
mode:
Diffstat (limited to 'support/texlab/crates/folding/src/tests.rs')
-rw-r--r--support/texlab/crates/folding/src/tests.rs88
1 files changed, 88 insertions, 0 deletions
diff --git a/support/texlab/crates/folding/src/tests.rs b/support/texlab/crates/folding/src/tests.rs
new file mode 100644
index 0000000000..405b56bda1
--- /dev/null
+++ b/support/texlab/crates/folding/src/tests.rs
@@ -0,0 +1,88 @@
+use expect_test::{expect, Expect};
+
+fn check(input: &str, expect: Expect) {
+ let fixture = test_utils::fixture::Fixture::parse(input);
+ let workspace = &fixture.workspace;
+ let document = workspace.lookup(&fixture.documents[0].uri).unwrap();
+ 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,
+ },
+ ]
+ "#]],
+ );
+}