8000 test: Add hyperlink test · Muscraft/annotate-snippets-rs@359a6ed · GitHub
[go: up one dir, main page]

Skip to content 10000

Commit 359a6ed

Browse files
committed
test: Add hyperlink test
1 parent 24c8eaa commit 359a6ed

File tree

3 files changed

+79
-0
lines changed

3 files changed

+79
-0
lines changed

examples/id_hyperlink.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
use annotate_snippets::renderer::OutputTheme;
2+
use annotate_snippets::{AnnotationKind, Group, Level, Renderer, Snippet};
3+
4+
fn main() {
5+
let source = r#"//@ compile-flags: -Zterminal-urls=yes
6+
fn main() {
7+
let () = 4; //~ ERROR
8+
}
9+
"#;
10+
11+
let message = Level::ERROR.header("mismatched types").id("E0308").group(
12+
Group::new().element(
13+
Snippet::source(source)
14+
.line_start(1)
15+
.path("$DIR/terminal_urls.rs")
16+
.fold(true)
17+
.annotation(
18+
AnnotationKind::Primary
19+
.span(59..61)
20+
.label("expected integer, found `()`"),
21+
)
22+
.annotation(
23+
AnnotationKind::Context
24+
.span(64..65)
25+
.label("this expression has type `{integer}`"),
26+
),
27+
),
28+
);
29+
30+
let renderer = Renderer::styled().theme(OutputTheme::Unicode);
31+
anstream::println!("{}", renderer.render(message));
32+
}

examples/id_hyperlink.svg

Lines changed: 40 additions & 0 deletions
Loading

tests/examples.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ fn highlight_title() {
4949
assert_example(target, expected);
5050
}
5151

52+
#[test]
53+
fn id_hyperlink() {
54+
let target = "id_hyperlink";
55+
let expected = snapbox::file!["../examples/id_hyperlink.svg": TermSvg];
56+
assert_example(target, expected);
57+
}
58+
5259
#[test]
5360
fn multislice() {
5461
let target = "multislice";

0 commit comments

Comments
 (0)
0