mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
sort: Support check
This commit is contained in:
parent
3bc5a5f769
commit
3fd8136423
3 changed files with 57 additions and 13 deletions
8
tests/fixtures/sort/check_fail.txt
vendored
Normal file
8
tests/fixtures/sort/check_fail.txt
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
1
|
||||
2
|
||||
3
|
||||
4
|
||||
6
|
||||
5
|
||||
9
|
||||
8
|
|
@ -58,15 +58,35 @@ fn test_multiple_files() {
|
|||
ucmd.arg("-n");
|
||||
ucmd.arg("multiple_files1.txt");
|
||||
ucmd.arg("multiple_files2.txt");
|
||||
let out = ucmd.run().stdout;
|
||||
assert_eq!(out, at.read("multiple_files.expected"));
|
||||
let res = ucmd.run();
|
||||
assert_eq!(res.success, true);
|
||||
assert_eq!(res.stdout, at.read("multiple_files.expected"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_check() {
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.arg("-c");
|
||||
let res = ucmd.arg("check_fail.txt").run();
|
||||
|
||||
assert_eq!(res.success, false);
|
||||
assert_eq!(res.stdout, "sort: disorder in line 4\n");
|
||||
|
||||
let (_, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.arg("-c");
|
||||
let res = ucmd.arg("multiple_files.expected").run();
|
||||
|
||||
assert_eq!(res.success, true);
|
||||
assert_eq!(res.stdout, "");
|
||||
}
|
||||
|
||||
fn test_helper(file_name: &str, args: &str) {
|
||||
let (at, mut ucmd) = testing(UTIL_NAME);
|
||||
ucmd.arg(args);
|
||||
let out = ucmd.arg(format!("{}{}", file_name, ".txt")).run().stdout;
|
||||
let res = ucmd.arg(format!("{}{}", file_name, ".txt")).run();
|
||||
|
||||
assert_eq!(res.success, true);
|
||||
|
||||
let filename = format!("{}{}", file_name, ".expected");
|
||||
assert_eq!(out, at.read(&filename));
|
||||
assert_eq!(res.stdout, at.read(&filename));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue