Skip to content

Commit cc495a3

Browse files
committed
test: non-utf8 file
1 parent 0865da4 commit cc495a3

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tests/by-util/test_sort.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1851,6 +1851,25 @@ fn test_files0_from_2a() {
18511851
.stdout_only("a\na\n");
18521852
}
18531853

1854+
#[test]
1855+
// Test for GNU tests/sort/sort-files0-from.pl "non-utf8"
1856+
#[cfg(unix)]
1857+
fn test_files0_from_non_utf8() {
1858+
use std::os::unix::ffi::OsStringExt;
1859+
let (at, mut ucmd) = at_and_ucmd!();
1860+
1861+
// non-UTF-8 bytes (0xFF)
1862+
let filename = std::ffi::OsString::from_vec(vec![b'a', 0xFF, b'b']);
1863+
std::fs::write(at.plus(&filename), b"20\n10\n").unwrap();
1864+
1865+
let list_contents = vec![b'a', 0xFF, b'b', 0];
1866+
at.write_bytes("list0", &list_contents);
1867+
1868+
ucmd.args(&["--files0-from", "list0"])
1869+
.succeeds()
1870+
.stdout_only("10\n20\n");
1871+
}
1872+
18541873
#[test]
18551874
// Test for GNU tests/sort/sort-files0-from.pl "zero-len"
18561875
fn test_files0_from_zero_length() {

0 commit comments

Comments
 (0)