1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #2342 from Mikadore/master

Test `head` being able to work on invalid utf8
This commit is contained in:
Sylvestre Ledru 2021-07-04 11:58:10 +02:00 committed by GitHub
commit aa79e7a8c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -250,6 +250,27 @@ hello
);
}
#[test]
fn test_bad_utf8() {
let bytes: &[u8] = 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: &[u8] = 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);
}
#[test]
fn test_head_invalid_num() {
new_ucmd!()