From c1f518e5864417e3db0a1dd84cd3e8438be3b089 Mon Sep 17 00:00:00 2001 From: Chad Brewbaker Date: Tue, 4 Aug 2020 16:35:35 -0500 Subject: [PATCH] Adding failing GNU head tests (#1579) Co-authored-by: Chad Brewbaker --- tests/by-util/test_head.rs | 71 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index 999b442679..66d7dacf94 100644 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -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(""); +}