mirror of
https://github.com/crate-ci/typos.git
synced 2024-12-23 08:02:15 -05:00
test(cli): Cover extract_line
This commit is contained in:
parent
d7978658d4
commit
f36bdc895f
1 changed files with 35 additions and 0 deletions
35
src/file.rs
35
src/file.rs
|
@ -672,4 +672,39 @@ mod test {
|
|||
);
|
||||
assert_eq!(actual, "foo happy world");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extract_line_single_line() {
|
||||
let (line, offset) = extract_line(b"hello world", 6);
|
||||
assert_eq!(line, b"hello world");
|
||||
assert_eq!(offset, 6);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extract_line_first() {
|
||||
let (line, offset) = extract_line(b"1\n2\n3", 0);
|
||||
assert_eq!(line, b"1");
|
||||
assert_eq!(offset, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extract_line_middle() {
|
||||
let (line, offset) = extract_line(b"1\n2\n3", 2);
|
||||
assert_eq!(line, b"2");
|
||||
assert_eq!(offset, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extract_line_end() {
|
||||
let (line, offset) = extract_line(b"1\n2\n3", 4);
|
||||
assert_eq!(line, b"3");
|
||||
assert_eq!(offset, 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_extract_line_offset_change() {
|
||||
let (line, offset) = extract_line(b"1\nhello world\n2", 8);
|
||||
assert_eq!(line, b"hello world");
|
||||
assert_eq!(offset, 6);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue