mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
wc: add tests for edge cases for wc on files
This commit is contained in:
parent
0a3e2216d7
commit
0cafe2b70d
6 changed files with 160 additions and 0 deletions
|
@ -112,3 +112,60 @@ fn test_multiple_default() {
|
||||||
alice_in_wonderland.txt\n 36 370 2189 total\n",
|
alice_in_wonderland.txt\n 36 370 2189 total\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Test for an empty file.
|
||||||
|
#[test]
|
||||||
|
fn test_file_empty() {
|
||||||
|
// TODO There is a leading space in the output that should be
|
||||||
|
// removed; see issue #2173.
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-clmwL", "emptyfile.txt"])
|
||||||
|
.run()
|
||||||
|
.stdout_is(" 0 0 0 0 0 emptyfile.txt\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test for an file containing a single non-whitespace character
|
||||||
|
/// *without* a trailing newline.
|
||||||
|
#[test]
|
||||||
|
fn test_file_single_line_no_trailing_newline() {
|
||||||
|
// TODO There is a leading space in the output that should be
|
||||||
|
// removed; see issue #2173.
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-clmwL", "notrailingnewline.txt"])
|
||||||
|
.run()
|
||||||
|
.stdout_is(" 1 1 2 2 1 notrailingnewline.txt\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test for a file that has 100 empty lines (that is, the contents of
|
||||||
|
/// the file are the newline character repeated one hundred times).
|
||||||
|
#[test]
|
||||||
|
fn test_file_many_empty_lines() {
|
||||||
|
// TODO There is a leading space in the output that should be
|
||||||
|
// removed; see issue #2173.
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-clmwL", "manyemptylines.txt"])
|
||||||
|
.run()
|
||||||
|
.stdout_is(" 100 0 100 100 0 manyemptylines.txt\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test for a file that has one long line comprising only spaces.
|
||||||
|
#[test]
|
||||||
|
fn test_file_one_long_line_only_spaces() {
|
||||||
|
// TODO There is a leading space in the output that should be
|
||||||
|
// removed; see issue #2173.
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-clmwL", "onelongemptyline.txt"])
|
||||||
|
.run()
|
||||||
|
.stdout_is(" 1 0 10001 10001 10000 onelongemptyline.txt\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Test for a file that has one long line comprising a single "word".
|
||||||
|
#[test]
|
||||||
|
fn test_file_one_long_word() {
|
||||||
|
// TODO There is a leading space in the output that should be
|
||||||
|
// removed; see issue #2173.
|
||||||
|
new_ucmd!()
|
||||||
|
.args(&["-clmwL", "onelongword.txt"])
|
||||||
|
.run()
|
||||||
|
.stdout_is(" 1 1 10001 10001 10000 onelongword.txt\n");
|
||||||
|
}
|
||||||
|
|
0
tests/fixtures/wc/emptyfile.txt
vendored
Normal file
0
tests/fixtures/wc/emptyfile.txt
vendored
Normal file
100
tests/fixtures/wc/manyemptylines.txt
vendored
Normal file
100
tests/fixtures/wc/manyemptylines.txt
vendored
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
1
tests/fixtures/wc/notrailingnewline.txt
vendored
Normal file
1
tests/fixtures/wc/notrailingnewline.txt
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
a
|
1
tests/fixtures/wc/onelongemptyline.txt
vendored
Normal file
1
tests/fixtures/wc/onelongemptyline.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
1
tests/fixtures/wc/onelongword.txt
vendored
Normal file
1
tests/fixtures/wc/onelongword.txt
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue