diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index 7daa80e3a..588e3b59a 100755 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -244,3 +244,24 @@ hello ", ); } + +#[test] +fn test_bad_utf8() { + let bytes = b"\xfc\x80\x80\x80\x80\xaf"; + new_ucmd!() + .args(&["-c", "6"]) + .pipe_in(*bytes) + .succeeds() + .stdout_is_bytes(bytes); +} + +#[test] +fn test_bad_utf8_lines() { + let input = b"\xfc\x80\x80\x80\x80\xaf\nb\xfc\x80\x80\x80\x80\xaf\nb\xfc\x80\x80\x80\x80\xaf"; + let output = b"\xfc\x80\x80\x80\x80\xaf\nb\xfc\x80\x80\x80\x80\xaf\n"; + new_ucmd!() + .args(&["-n", "2"]) + .pipe_in(*input) + .succeeds() + .stdout_is_bytes(output); +} \ No newline at end of file