Skip to content

Commit 5d17bf7

Browse files
jadijadiBenWiederhake
authored andcommitted
head: two new tests. Improves function coverage from 38 to 75
1 parent 415de28 commit 5d17bf7

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tests/by-util/test_head.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,3 +438,21 @@ fn test_read_backwards_bytes_sys_kernel_profiling() {
438438
assert_eq!(stdout_str.len(), 1);
439439
assert!(stdout_str == "0" || stdout_str == "1");
440440
}
441+
442+
#[test]
443+
fn test_value_too_large() {
444+
const MAX: u64 = u64::MAX;
445+
446+
new_ucmd!()
447+
.args(&["-n", format!("{MAX}0").as_str(), "lorem_ipsum.txt"])
448+
.fails()
449+
.stderr_contains("Value too large for defined data type");
450+
}
451+
452+
#[test]
453+
fn test_all_but_last_lines() {
454+
new_ucmd!()
455+
.args(&["-n", "-15", "lorem_ipsum.txt"])
456+
.succeeds()
457+
.stdout_is_fixture("lorem_ipsum_backwards_15_lines.expected");
458+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Lorem ipsum dolor sit amet,
2+
consectetur adipiscing elit.
3+
Nunc interdum suscipit sem vel ornare.
4+
Proin euismod,
5+
justo sed mollis dictum,
6+
eros urna ultricies augue,
7+
eu pharetra mi ex id ante.
8+
Duis convallis porttitor aliquam.
9+
Nunc vitae tincidunt ex.

0 commit comments

Comments
 (0)