Skip to content

Commit

Permalink
Adding failing GNU head tests (#1579)
Browse files Browse the repository at this point in the history
Co-authored-by: Chad Brewbaker <chad@flyingdogsolutions.com>
  • Loading branch information
2 people authored and rivy committed Aug 9, 2020
1 parent ba6b55f commit c1f518e
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions tests/by-util/test_head.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,74 @@ fn test_verbose() {
.run()
.stdout_is_fixture("lorem_ipsum_verbose.expected");
}

#[test]
fn test_spams_newline() {
new_ucmd!()
.pipe_in("a")
.succeeds()
.stdout_is("a\n");
}

#[test]
fn test_unsupported_byte_syntax() {
new_ucmd!()
.args(&["-1c"])
.pipe_in("abc")
.fails()
//GNU head returns "a"
.stdout_is("")
.stderr_is("head: error: Unrecognized option: \'1\'");
}

#[test]
fn test_unsupported_line_syntax() {
new_ucmd!()
.args(&["-n", "2048m"])
.pipe_in("a\n")
.fails()
//.stdout_is("a\n"); What GNU head returns.
.stdout_is("")
.stderr_is("head: error: invalid line count \'2048m\': invalid digit found in string");
}

#[test]
fn test_unsupported_zero_terminated_syntax() {
new_ucmd!()
.args(&["-z -n 1"])
.pipe_in("x\0y")
.fails()
//GNU Head returns "x\0"
.stderr_is("head: error: Unrecognized option: \'z\'");
}

#[test]
fn test_unsupported_zero_terminated_syntax_2() {
new_ucmd!()
.args(&["-z -n 2"])
.pipe_in("x\0y")
.fails()
//GNU Head returns "x\0y"
.stderr_is("head: error: Unrecognized option: \'z\'");
}


#[test]
fn test_unsupported_negative_byte_syntax() {
new_ucmd!()
.args(&["--bytes=-2"])
.pipe_in("a\n")
.fails()
//GNU Head returns ""
.stderr_is("head: error: invalid byte count \'-2\': invalid digit found in string");
}

#[test]
fn test_bug_in_negative_zero_lines() {
new_ucmd!()
.args(&["--lines=-0"])
.pipe_in("a\nb\n")
.succeeds()
//GNU Head returns "a\nb\n"
.stdout_is("");
}

0 comments on commit c1f518e

Please sign in to comment.