From 07f744c4bafa82a58d67c27fe19d3689b62fdaf4 Mon Sep 17 00:00:00 2001 From: Mikadore Date: Thu, 3 Jun 2021 23:38:31 +0200 Subject: [PATCH 1/3] added invalid utf8 tests --- tests/by-util/test_head.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 From afd7acb456c4602b7895acbae0a64da3a1390956 Mon Sep 17 00:00:00 2001 From: Mikadore Date: Thu, 3 Jun 2021 23:39:47 +0200 Subject: [PATCH 2/3] fmt --- tests/by-util/test_head.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index 588e3b59a..a7a5a3b07 100755 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -264,4 +264,4 @@ fn test_bad_utf8_lines() { .pipe_in(*input) .succeeds() .stdout_is_bytes(output); -} \ No newline at end of file +} From 4a84c15955aef3d6220a0575f1099bbb5ca6a797 Mon Sep 17 00:00:00 2001 From: Mikadore Date: Fri, 4 Jun 2021 00:19:44 +0200 Subject: [PATCH 3/3] fix minrustv build error --- tests/by-util/test_head.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/by-util/test_head.rs b/tests/by-util/test_head.rs index a7a5a3b07..2d6d60d15 100755 --- a/tests/by-util/test_head.rs +++ b/tests/by-util/test_head.rs @@ -247,21 +247,21 @@ hello #[test] fn test_bad_utf8() { - let bytes = b"\xfc\x80\x80\x80\x80\xaf"; + let bytes: &[u8] = b"\xfc\x80\x80\x80\x80\xaf"; new_ucmd!() .args(&["-c", "6"]) - .pipe_in(*bytes) + .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 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) + .pipe_in(input) .succeeds() .stdout_is_bytes(output); }