Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/by-util/test_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,3 +438,21 @@ fn test_read_backwards_bytes_sys_kernel_profiling() {
assert_eq!(stdout_str.len(), 1);
assert!(stdout_str == "0" || stdout_str == "1");
}

#[test]
fn test_value_too_large() {
const MAX: u64 = u64::MAX;

new_ucmd!()
.args(&["-n", format!("{MAX}0").as_str(), "lorem_ipsum.txt"])
.fails()
.stderr_contains("Value too large for defined data type");
}

#[test]
fn test_all_but_last_lines() {
new_ucmd!()
.args(&["-n", "-15", "lorem_ipsum.txt"])
.succeeds()
.stdout_is_fixture("lorem_ipsum_backwards_15_lines.expected");
}
9 changes: 9 additions & 0 deletions tests/fixtures/head/lorem_ipsum_backwards_15_lines.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Lorem ipsum dolor sit amet,
consectetur adipiscing elit.
Nunc interdum suscipit sem vel ornare.
Proin euismod,
justo sed mollis dictum,
eros urna ultricies augue,
eu pharetra mi ex id ante.
Duis convallis porttitor aliquam.
Nunc vitae tincidunt ex.