Skip to content

Commit

Permalink
test: Add a test case for issue 57
Browse files Browse the repository at this point in the history
  • Loading branch information
chengr4 committed Aug 20, 2024
1 parent 38ba420 commit 4ba7683
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,3 +905,25 @@ error: unused optional dependency
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input).to_string(), expected);
}

// for issue 57
#[test]
fn test_line_number_0() {
let input = Level::Error.title("dummy").snippet(
Snippet::source("foo")
.origin("file/path")
.line_start(0)
.annotation(Level::Error.span(2..3)), // bar\nbaz
);

let expected = str![[r#"
error: dummy
--> file/path:0:3
|
0 | foo
| ^
|
"#]];
let renderer = Renderer::plain();
assert_data_eq!(renderer.render(input).to_string(), expected);
}

0 comments on commit 4ba7683

Please sign in to comment.