2020-05-25 17:05:26 +00:00
|
|
|
use crate::common::util::*;
|
2015-11-16 05:25:01 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_default() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.pipe_in_fixture("lorem_ipsum.txt")
|
|
|
|
.run()
|
|
|
|
.stdout_is(" 13 109 772\n");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
2021-02-16 12:36:49 +00:00
|
|
|
#[test]
|
|
|
|
fn test_utf8() {
|
|
|
|
new_ucmd!()
|
|
|
|
.args(&["-lwmcL"])
|
|
|
|
.pipe_in_fixture("UTF_8_test.txt")
|
|
|
|
.run()
|
2021-03-31 09:25:23 +00:00
|
|
|
.stdout_is(" 300 4969 22781 22213 79\n");
|
2021-02-16 12:36:49 +00:00
|
|
|
// GNU returns " 300 2086 22219 22781 79"
|
|
|
|
// TODO: we should fix that to match GNU's behavior
|
|
|
|
}
|
|
|
|
|
2021-02-08 20:54:48 +00:00
|
|
|
#[test]
|
|
|
|
fn test_stdin_line_len_regression() {
|
|
|
|
new_ucmd!()
|
|
|
|
.args(&["-L"])
|
|
|
|
.pipe_in("\n123456")
|
|
|
|
.run()
|
2021-03-30 18:53:02 +00:00
|
|
|
.stdout_is("6\n");
|
2021-02-08 20:54:48 +00:00
|
|
|
}
|
|
|
|
|
2015-11-16 05:25:01 +00:00
|
|
|
#[test]
|
|
|
|
fn test_stdin_only_bytes() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["-c"])
|
|
|
|
.pipe_in_fixture("lorem_ipsum.txt")
|
|
|
|
.run()
|
2021-03-30 18:53:02 +00:00
|
|
|
.stdout_is("772\n");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_stdin_all_counts() {
|
2020-04-13 18:36:03 +00:00
|
|
|
new_ucmd!()
|
|
|
|
.args(&["-c", "-m", "-l", "-L", "-w"])
|
2016-08-13 21:59:21 +00:00
|
|
|
.pipe_in_fixture("alice_in_wonderland.txt")
|
|
|
|
.run()
|
|
|
|
.stdout_is(" 5 57 302 302 66\n");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_default() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.arg("moby_dick.txt")
|
|
|
|
.run()
|
|
|
|
.stdout_is(" 18 204 1115 moby_dick.txt\n");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_only_lines() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-l", "moby_dick.txt"])
|
|
|
|
.run()
|
2021-03-30 18:53:02 +00:00
|
|
|
.stdout_is("18 moby_dick.txt\n");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_single_all_counts() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&["-c", "-l", "-L", "-m", "-w", "alice_in_wonderland.txt"])
|
|
|
|
.run()
|
2016-08-13 21:59:21 +00:00
|
|
|
.stdout_is(" 5 57 302 302 66 alice_in_wonderland.txt\n");
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_multiple_default() {
|
2016-08-23 11:52:43 +00:00
|
|
|
new_ucmd!()
|
2020-04-13 18:36:03 +00:00
|
|
|
.args(&[
|
|
|
|
"lorem_ipsum.txt",
|
|
|
|
"moby_dick.txt",
|
|
|
|
"alice_in_wonderland.txt",
|
|
|
|
])
|
|
|
|
.run()
|
2016-08-13 21:59:21 +00:00
|
|
|
.stdout_is(
|
2020-04-13 18:36:03 +00:00
|
|
|
" 13 109 772 lorem_ipsum.txt\n 18 204 1115 moby_dick.txt\n 5 57 302 \
|
2021-03-18 09:24:30 +00:00
|
|
|
alice_in_wonderland.txt\n 36 370 2189 total\n",
|
2020-04-13 18:36:03 +00:00
|
|
|
);
|
2015-11-16 05:25:01 +00:00
|
|
|
}
|