diff options
author | Norbert Preining <norbert@preining.info> | 2020-05-28 03:03:21 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2020-05-28 03:03:21 +0000 |
commit | 745892fbddea56040139108277e728b53fd8fc11 (patch) | |
tree | 15e55e299b38fccdabce8364f1fbf4f02ef37994 /support/texlab/tests/integration/highlight.rs | |
parent | 195ca7e0c377d83455867bdd8e409d4e1cf024ea (diff) |
CTAN sync 202005280303
Diffstat (limited to 'support/texlab/tests/integration/highlight.rs')
-rw-r--r-- | support/texlab/tests/integration/highlight.rs | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/support/texlab/tests/integration/highlight.rs b/support/texlab/tests/integration/highlight.rs new file mode 100644 index 0000000000..ba77a7b8e3 --- /dev/null +++ b/support/texlab/tests/integration/highlight.rs @@ -0,0 +1,83 @@ +use indoc::indoc; +use texlab::{ + protocol::{DocumentHighlight, DocumentHighlightKind, Range, RangeExt}, + test::{TestBedBuilder, PULL_CAPABILITIES}, +}; + +#[tokio::test] +async fn empty_latex_document() { + let mut test_bed = TestBedBuilder::new().file("main.tex", "").build().await; + test_bed.spawn(); + test_bed.initialize(PULL_CAPABILITIES.clone()).await; + test_bed.open("main.tex").await; + + let actual_highlights = test_bed.document_highlight("main.tex", 0, 0).await.unwrap(); + + test_bed.shutdown().await; + + assert!(actual_highlights.is_empty()); +} + +#[tokio::test] +async fn empty_bibtex_document() { + let mut test_bed = TestBedBuilder::new().file("main.bib", "").build().await; + test_bed.spawn(); + test_bed.initialize(PULL_CAPABILITIES.clone()).await; + test_bed.open("main.bib").await; + + let actual_highlights = test_bed.document_highlight("main.bib", 0, 0).await.unwrap(); + + test_bed.shutdown().await; + + assert!(actual_highlights.is_empty()); +} + +#[tokio::test] +async fn label() { + let mut test_bed = TestBedBuilder::new() + .file( + "main.tex", + indoc!( + r#" + \label{foo} + \ref{foo} + "# + ), + ) + .build() + .await; + test_bed.spawn(); + test_bed.initialize(PULL_CAPABILITIES.clone()).await; + test_bed.open("main.tex").await; + + let actual_highlights = test_bed.document_highlight("main.tex", 0, 7).await.unwrap(); + + let expected_highlights = vec![ + DocumentHighlight { + range: Range::new_simple(0, 7, 0, 10), + kind: Some(DocumentHighlightKind::Write), + }, + DocumentHighlight { + range: Range::new_simple(1, 5, 1, 8), + kind: Some(DocumentHighlightKind::Read), + }, + ]; + + test_bed.shutdown().await; + + assert_eq!(actual_highlights, expected_highlights); +} + +#[tokio::test] +async fn unknown_file() { + let mut test_bed = TestBedBuilder::new().build().await; + + test_bed.spawn(); + test_bed.initialize(PULL_CAPABILITIES.clone()).await; + + let actual_highlights = test_bed.document_highlight("main.tex", 0, 0).await; + + test_bed.shutdown().await; + + assert_eq!(actual_highlights, None); +} |