mirror of
https://github.com/uutils/coreutils.git
synced 2025-12-23 08:47:37 +00:00
split: bring back the test
This commit is contained in:
parent
1c5b95d1bb
commit
0a7ea78733
2 changed files with 25 additions and 2 deletions
|
|
@ -881,4 +881,4 @@ fn test_head_non_utf8_paths() {
|
|||
assert!(output.contains("line2"));
|
||||
assert!(output.contains("line3"));
|
||||
}
|
||||
// Test that head handles non-UTF-8 file names without crashing
|
||||
// Test that head handles non-UTF-8 file names without crashing
|
||||
|
|
|
|||
|
|
@ -1711,7 +1711,7 @@ fn test_split_invalid_input() {
|
|||
/// Test if there are invalid (non UTF-8) in the arguments - unix
|
||||
/// clap is expected to fail/panic
|
||||
#[test]
|
||||
#[cfg(unix)]
|
||||
#[cfg(target_os = "linux")]
|
||||
fn test_split_non_utf8_argument_unix() {
|
||||
use std::ffi::OsStr;
|
||||
use std::os::unix::ffi::OsStrExt;
|
||||
|
|
@ -1729,6 +1729,29 @@ fn test_split_non_utf8_argument_unix() {
|
|||
ucmd.args(&[opt, opt_value, name]).succeeds();
|
||||
}
|
||||
|
||||
/// Test if there are invalid (non UTF-8) in the arguments - windows
|
||||
/// clap is expected to fail/panic
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn test_split_non_utf8_argument_windows() {
|
||||
use std::ffi::OsString;
|
||||
use std::os::windows::ffi::OsStringExt;
|
||||
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let name = "test_split_non_utf8_argument";
|
||||
let opt = OsString::from("--additional-suffix");
|
||||
RandomFile::new(&at, name).add_lines(2000);
|
||||
// Here the values 0x0066 and 0x006f correspond to 'f' and 'o'
|
||||
// respectively. The value 0xD800 is a lone surrogate half, invalid
|
||||
// in a UTF-16 sequence.
|
||||
let opt_value = [0x0066, 0x006f, 0xD800, 0x006f];
|
||||
let opt_value = OsString::from_wide(&opt_value[..]);
|
||||
let name = OsString::from(name);
|
||||
ucmd.args(&[opt, opt_value, name])
|
||||
.fails()
|
||||
.stderr_contains("error: invalid UTF-8 was detected in one or more arguments");
|
||||
}
|
||||
|
||||
// Test '--separator' / '-t' option following GNU tests example
|
||||
// test separators: '\n' , '\0' , ';'
|
||||
// test with '--lines=2' , '--line-bytes=4' , '--number=l/3' , '--number=r/3' , '--number=l/1/3' , '--number=r/1/3'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue