2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
2015-11-16 05:25:01 +00:00
|
|
|
|
2022-09-10 16:38:14 +00:00
|
|
|
#[test]
|
|
|
|
fn test_invalid_arg() {
|
|
|
|
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
|
|
|
}
|
|
|
|
|
2015-11-16 05:25:01 +00:00
|
|
|
#[test]
|
|
|
|
fn test_bsd_single_file() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-07-29 21:26:32 +00:00
|
|
|
.arg("lorem_ipsum.txt")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("bsd_single_file.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_bsd_multiple_files() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-07-29 21:26:32 +00:00
|
|
|
.arg("lorem_ipsum.txt")
|
|
|
|
.arg("alice_in_wonderland.txt")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("bsd_multiple_files.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_bsd_stdin() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-07-29 21:26:32 +00:00
|
|
|
.pipe_in_fixture("lorem_ipsum.txt")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("bsd_stdin.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_sysv_single_file() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.arg("-s")
|
|
|
|
.arg("lorem_ipsum.txt")
|
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("sysv_single_file.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_sysv_multiple_files() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-07-29 21:26:32 +00:00
|
|
|
.arg("-s")
|
|
|
|
.arg("lorem_ipsum.txt")
|
|
|
|
.arg("alice_in_wonderland.txt")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("sysv_multiple_files.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_sysv_stdin() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2016-07-29 21:26:32 +00:00
|
|
|
.arg("-s")
|
|
|
|
.pipe_in_fixture("lorem_ipsum.txt")
|
2020-04-13 18:36:03 +00:00
|
|
|
.succeeds()
|
|
|
|
.stdout_only_fixture("sysv_stdin.expected");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
2021-03-29 11:03:56 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_invalid_file() {
|
|
|
|
let (at, mut ucmd) = at_and_ucmd!();
|
|
|
|
|
|
|
|
at.mkdir("a");
|
|
|
|
|
2021-09-03 14:10:39 +00:00
|
|
|
ucmd.arg("a").fails().stderr_is("sum: a: Is a directory");
|
2021-03-29 11:03:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_invalid_metadata() {
|
|
|
|
let (_, mut ucmd) = at_and_ucmd!();
|
|
|
|
|
|
|
|
ucmd.arg("b")
|
|
|
|
.fails()
|
2021-09-03 14:10:39 +00:00
|
|
|
.stderr_is("sum: b: No such file or directory");
|
2021-03-29 11:03:56 +00:00
|
|
|
}
|