Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 22e7a13

Browse files
authored
Merge pull request rust-lang#313 from Muscraft/test_highlight_source
test: Highlight source on all AnnotationKind
2 parents 7b2d100 + ba88d2c commit 22e7a13

File tree

4 files changed

+120
-0
lines changed

4 files changed

+120
-0
lines changed
Lines changed: 38 additions & 0 deletions
Loading[フレーム]

‎tests/color/highlight_source.rs‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
use annotate_snippets::{renderer::DecorStyle, AnnotationKind, Level, Renderer, Snippet};
2+
3+
use snapbox::{assert_data_eq, file};
4+
5+
#[test]
6+
fn case() {
7+
let source = r#"
8+
[workspace.lints.rust]
9+
rust_2018_idioms = { level = "warn", priority = -1 }
10+
unnameable_types = "warn"
11+
unreachable_pub = "warn"
12+
unsafe_op_in_unsafe_fn = "warn"
13+
unused_lifetimes = "warn"
14+
unused_macro_rules = "warn"
15+
unused_qualifications = "warn"
16+
"#;
17+
18+
let input = &[Level::ERROR
19+
.primary_title("all annotation kinds have a highlighted source")
20+
.element(
21+
Snippet::source(source)
22+
.path("Cargo.toml")
23+
.annotation(
24+
AnnotationKind::Primary
25+
.span(214..235)
26+
.highlight_source(true),
27+
)
28+
.annotation(
29+
AnnotationKind::Context
30+
.span(238..244)
31+
.highlight_source(true),
32+
)
33+
.annotation(AnnotationKind::Visible.span(2..22).highlight_source(true)),
34+
)];
35+
36+
let expected_ascii = file!["highlight_source.ascii.term.svg": TermSvg];
37+
let renderer = Renderer::styled();
38+
assert_data_eq!(renderer.render(input), expected_ascii);
39+
40+
let expected_unicode = file!["highlight_source.unicode.term.svg": TermSvg];
41+
let renderer = renderer.decor_style(DecorStyle::Unicode);
42+
assert_data_eq!(renderer.render(input), expected_unicode);
43+
}
Lines changed: 38 additions & 0 deletions
Loading[フレーム]

‎tests/color/main.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ mod fold_ann_multiline;
99
mod fold_bad_origin_line;
1010
mod fold_leading;
1111
mod fold_trailing;
12+
mod highlight_source;
1213
mod issue_9;
1314
mod multiline_removal_suggestion;
1415
mod multiple_annotations;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /