1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

wc: implement --total

This commit is contained in:
Daniel Hofstetter 2023-03-31 08:16:46 +02:00
parent 5d0f0144c1
commit 0fa08757fa
2 changed files with 125 additions and 14 deletions

View file

@ -464,3 +464,59 @@ fn test_files0_from_with_stdin_try_read_from_stdin() {
.stderr_contains(MSG)
.stdout_is("");
}
#[test]
fn test_total_auto() {
new_ucmd!()
.args(&["lorem_ipsum.txt", "--total=auto"])
.run()
.stdout_is(" 13 109 772 lorem_ipsum.txt\n");
new_ucmd!()
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=auto"])
.run()
.stdout_is(
" 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 31 313 1887 total\n",
);
}
#[test]
fn test_total_always() {
new_ucmd!()
.args(&["lorem_ipsum.txt", "--total=always"])
.run()
.stdout_is(" 13 109 772 lorem_ipsum.txt\n 13 109 772 total\n");
new_ucmd!()
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=always"])
.run()
.stdout_is(
" 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 31 313 1887 total\n",
);
}
#[test]
fn test_total_never() {
new_ucmd!()
.args(&["lorem_ipsum.txt", "--total=never"])
.run()
.stdout_is(" 13 109 772 lorem_ipsum.txt\n");
new_ucmd!()
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=never"])
.run()
.stdout_is(" 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n");
}
#[test]
fn test_total_only() {
new_ucmd!()
.args(&["lorem_ipsum.txt", "--total=only"])
.run()
.stdout_is("13 109 772\n");
new_ucmd!()
.args(&["lorem_ipsum.txt", "moby_dick.txt", "--total=only"])
.run()
.stdout_is("31 313 1887\n");
}