Skip to content

Commit 35a7203

Browse files
committed
test: Annotate newline empty span
1 parent 66e67f5 commit 35a7203

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/formatter.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,37 @@ error:
439439
assert_data_eq!(renderer.render(snippets), expected);
440440
}
441441

442+
#[test]
443+
fn annotate_newline_empty_span() {
444+
let message = &[Group::with_title(Level::ERROR.title("bad")).element(
445+
Snippet::source("\n\n\n\n\n\n\n")
446+
.path("test.txt")
447+
.annotation(AnnotationKind::Primary.span(0..0)),
448+
)];
449+
450+
let expected_ascii = str![[r#"
451+
error: bad
452+
--> test.txt:1:1
453+
|
454+
1 |
455+
| ^
456+
"#]];
457+
458+
let renderer = Renderer::plain();
459+
assert_data_eq!(renderer.render(message), expected_ascii);
460+
461+
let expected_unicode = str![[r#"
462+
error: bad
463+
╭▸ test.txt:1:1
464+
465+
1 │
466+
╰╴━
467+
"#]];
468+
469+
let renderer = renderer.theme(OutputTheme::Unicode);
470+
assert_data_eq!(renderer.render(message), expected_unicode);
471+
}
472+
442473
#[test]
443474
fn annotate_eol() {
444475
let source = "a\r\nb";

0 commit comments

Comments
 (0)