|
4 | 4 | // file that was distributed with this source code. |
5 | 5 | // spell-checker:ignore (words) reallylongexecutable nbaz |
6 | 6 |
|
7 | | -#[cfg(any(unix, target_os = "redox"))] |
8 | | -use std::ffi::OsStr; |
9 | 7 | use uutests::new_ucmd; |
10 | 8 |
|
11 | 9 | #[test] |
@@ -138,20 +136,25 @@ fn test_too_many_args_output() { |
138 | 136 | .usage_error("extra operand 'c'"); |
139 | 137 | } |
140 | 138 |
|
141 | | -#[cfg(any(unix, target_os = "redox"))] |
142 | | -fn test_invalid_utf8_args(os_str: &OsStr) { |
143 | | - let test_vec = vec![os_str.to_os_string()]; |
144 | | - new_ucmd!().args(&test_vec).succeeds().stdout_is("fo�o\n"); |
145 | | -} |
146 | | - |
147 | 139 | #[cfg(any(unix, target_os = "redox"))] |
148 | 140 | #[test] |
149 | | -fn invalid_utf8_args_unix() { |
150 | | - use std::os::unix::ffi::OsStrExt; |
| 141 | +fn test_invalid_utf8_args() { |
| 142 | + let param = uucore::os_str_from_bytes(b"/tmp/some-\xc0-file.k\xf3") |
| 143 | + .expect("Only unix platforms can test non-unicode names"); |
| 144 | + |
| 145 | + new_ucmd!() |
| 146 | + .arg(¶m) |
| 147 | + .succeeds() |
| 148 | + .stdout_is_bytes(b"some-\xc0-file.k\xf3\n"); |
| 149 | + |
| 150 | + let suffix = uucore::os_str_from_bytes(b".k\xf3") |
| 151 | + .expect("Only unix platforms can test non-unicode names"); |
151 | 152 |
|
152 | | - let source = [0x66, 0x6f, 0x80, 0x6f]; |
153 | | - let os_str = OsStr::from_bytes(&source[..]); |
154 | | - test_invalid_utf8_args(os_str); |
| 153 | + new_ucmd!() |
| 154 | + .arg(¶m) |
| 155 | + .arg(&suffix) |
| 156 | + .succeeds() |
| 157 | + .stdout_is_bytes(b"some-\xc0-file\n"); |
155 | 158 | } |
156 | 159 |
|
157 | 160 | #[test] |
|
0 commit comments