mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
test_basename: Fix test_invalid_utf8_args
The test was not really testing for the right thing. If a non-unicode string is passed, the basename should be printed as-is.
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
// file that was distributed with this source code.
|
||||
// spell-checker:ignore (words) reallylongexecutable nbaz
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
use std::ffi::OsStr;
|
||||
use uutests::new_ucmd;
|
||||
|
||||
#[test]
|
||||
@@ -138,20 +136,25 @@ fn test_too_many_args_output() {
|
||||
.usage_error("extra operand 'c'");
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
fn test_invalid_utf8_args(os_str: &OsStr) {
|
||||
let test_vec = vec![os_str.to_os_string()];
|
||||
new_ucmd!().args(&test_vec).succeeds().stdout_is("fo�o\n");
|
||||
}
|
||||
|
||||
#[cfg(any(unix, target_os = "redox"))]
|
||||
#[test]
|
||||
fn invalid_utf8_args_unix() {
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
fn test_invalid_utf8_args() {
|
||||
let param = uucore::os_str_from_bytes(b"/tmp/some-\xc0-file.k\xf3")
|
||||
.expect("Only unix platforms can test non-unicode names");
|
||||
|
||||
let source = [0x66, 0x6f, 0x80, 0x6f];
|
||||
let os_str = OsStr::from_bytes(&source[..]);
|
||||
test_invalid_utf8_args(os_str);
|
||||
new_ucmd!()
|
||||
.arg(¶m)
|
||||
.succeeds()
|
||||
.stdout_is_bytes(b"some-\xc0-file.k\xf3\n");
|
||||
|
||||
let suffix = uucore::os_str_from_bytes(b".k\xf3")
|
||||
.expect("Only unix platforms can test non-unicode names");
|
||||
|
||||
new_ucmd!()
|
||||
.arg(¶m)
|
||||
.arg(&suffix)
|
||||
.succeeds()
|
||||
.stdout_is_bytes(b"some-\xc0-file\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user