mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 01:38:04 +00:00
Merge pull request #944 from nathanross/tests-cut-incr-feature-coverage
tests/cut: positive testcases for feature complete
This commit is contained in:
commit
b290ab2ca5
22 changed files with 142 additions and 41 deletions
5
tests/fixtures/cut/delimiter_specified.expected
vendored
Normal file
5
tests/fixtures/cut/delimiter_specified.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
foo:bar:qux
|
||||
one:two:four:six:seven
|
||||
alpha:beta:delta:zeta:eta:iota:kappa:lambda:mu
|
||||
the quick brown fox jumps over the lazy dog
|
||||
sally sells seashells down by the seashore where are the seashells sally sells
|
1
tests/fixtures/cut/lists.txt
vendored
1
tests/fixtures/cut/lists.txt
vendored
|
@ -2,3 +2,4 @@ foo:bar:baz:qux:quux
|
|||
one:two:three:four:five:six:seven
|
||||
alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
the quick brown fox jumps over the lazy dog
|
||||
sally sells seashells down by the seashore where are the seashells sally sells
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
bar#baz#qux#quux
|
||||
two#three#four#five#six#seven
|
||||
beta#gamma#delta#epsilon#zeta#eta#theta#iota#kappa#lambda#mu
|
||||
the quick brown fox jumps over the lazy dog
|
4
tests/fixtures/cut/lists_char_range.expected
vendored
4
tests/fixtures/cut/lists_char_range.expected
vendored
|
@ -1,4 +0,0 @@
|
|||
:bar:ba
|
||||
:two:th
|
||||
ha:beta
|
||||
quick
|
|
@ -1,4 +0,0 @@
|
|||
quux
|
||||
five:six:seven
|
||||
epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
the quick brown fox jumps over the lazy dog
|
|
@ -1,4 +0,0 @@
|
|||
foo:baz
|
||||
one:three
|
||||
alpha:gamma
|
||||
the quick brown fox jumps over the lazy dog
|
4
tests/fixtures/cut/lists_prefix.expected
vendored
4
tests/fixtures/cut/lists_prefix.expected
vendored
|
@ -1,4 +0,0 @@
|
|||
foo:bar:ba
|
||||
one:two:th
|
||||
alpha:beta
|
||||
the quick
|
4
tests/fixtures/cut/lists_tail.expected
vendored
4
tests/fixtures/cut/lists_tail.expected
vendored
|
@ -1,4 +0,0 @@
|
|||
bar:baz:qux:quux
|
||||
two:three:four:five:six:seven
|
||||
beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
the quick brown fox jumps over the lazy dog
|
5
tests/fixtures/cut/output_delimiter.expected
vendored
Normal file
5
tests/fixtures/cut/output_delimiter.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
foo@bar@qux
|
||||
one@two@four@six@seven
|
||||
alpha@beta@delta@zeta@eta@iota@kappa@lambda@mu
|
||||
the quick brown fox jumps over the lazy dog
|
||||
sally sells seashells down by the seashore where are the seashells sally sells
|
5
tests/fixtures/cut/sequences/byte_aggregate.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/byte_aggregate.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
fo:arbaz:qux:quux
|
||||
on:wothree:four:five:six:seven
|
||||
alh:bta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
th uik brown fox jumps over the lazy dog
|
||||
sal slls seashells down by the seashore where are the seashells sally sells
|
5
tests/fixtures/cut/sequences/byte_prefix.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/byte_prefix.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
fo
|
||||
on
|
||||
al
|
||||
th
|
||||
sa
|
5
tests/fixtures/cut/sequences/byte_range.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/byte_range.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
oo:
|
||||
ne:
|
||||
lph
|
||||
he
|
||||
all
|
5
tests/fixtures/cut/sequences/byte_singular.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/byte_singular.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
o
|
||||
n
|
||||
l
|
||||
h
|
||||
a
|
5
tests/fixtures/cut/sequences/byte_subsumed.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/byte_subsumed.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
oo:bar:baz:qux:quux
|
||||
ne:two:three:four:five:six:seven
|
||||
lpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
he quick brown fox jumps over the lazy dog
|
||||
ally sells seashells down by the seashore where are the seashells sally sells
|
5
tests/fixtures/cut/sequences/byte_suffix.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/byte_suffix.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
oo:bar:baz:qux:quux
|
||||
ne:two:three:four:five:six:seven
|
||||
lpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
he quick brown fox jumps over the lazy dog
|
||||
ally sells seashells down by the seashore where are the seashells sally sells
|
5
tests/fixtures/cut/sequences/field_aggregate.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/field_aggregate.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
foo:bar:baz:qux:quux
|
||||
one:two:three:four:five:six:seven
|
||||
alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
the quick brown fox jumps over the lazy dog
|
||||
sally sells down the seashore are the seashells sally sells
|
5
tests/fixtures/cut/sequences/field_prefix.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/field_prefix.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
foo:bar:baz:qux:quux
|
||||
one:two:three:four:five:six:seven
|
||||
alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
the quick brown fox jumps over the lazy dog
|
||||
sally sells
|
5
tests/fixtures/cut/sequences/field_range.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/field_range.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
foo:bar:baz:qux:quux
|
||||
one:two:three:four:five:six:seven
|
||||
alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
the quick brown fox jumps over the lazy dog
|
||||
sells seashells down
|
|
@ -1,4 +1,5 @@
|
|||
foo:bar:baz:qux:quux
|
||||
one:two:three:four:five:six:seven
|
||||
alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
brown
|
||||
the quick brown fox jumps over the lazy dog
|
||||
sells
|
5
tests/fixtures/cut/sequences/field_subsumed.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/field_subsumed.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
foo:bar:baz:qux:quux
|
||||
one:two:three:four:five:six:seven
|
||||
alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
the quick brown fox jumps over the lazy dog
|
||||
sells seashells down by the seashore where are the seashells sally sells
|
5
tests/fixtures/cut/sequences/field_suffix.expected
vendored
Normal file
5
tests/fixtures/cut/sequences/field_suffix.expected
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
foo:bar:baz:qux:quux
|
||||
one:two:three:four:five:six:seven
|
||||
alpha:beta:gamma:delta:epsilon:zeta:eta:theta:iota:kappa:lambda:mu
|
||||
the quick brown fox jumps over the lazy dog
|
||||
sells seashells down by the seashore where are the seashells sally sells
|
|
@ -7,40 +7,98 @@ fn new_ucmd() -> UCommand {
|
|||
|
||||
static INPUT: &'static str = "lists.txt";
|
||||
|
||||
struct TestedSequence<'b> {
|
||||
name : &'b str,
|
||||
sequence: &'b str
|
||||
}
|
||||
|
||||
static EXAMPLE_SEQUENCES: &'static [TestedSequence<'static>] = &[
|
||||
TestedSequence{ name: "singular", sequence:"2" },
|
||||
TestedSequence{ name: "prefix", sequence: "-2" },
|
||||
TestedSequence{ name: "suffix", sequence: "2-" },
|
||||
TestedSequence{ name: "range", sequence: "2-4" },
|
||||
TestedSequence{ name: "aggregate", sequence: "9-,6-7,-2,4" },
|
||||
TestedSequence{ name: "subsumed", sequence: "2-,3" }
|
||||
];
|
||||
|
||||
static COMPLEX_SEQUENCE: &'static TestedSequence<'static> = &TestedSequence{ name: "", sequence: "9-,6-7,-2,4" };
|
||||
|
||||
#[test]
|
||||
fn test_prefix() {
|
||||
new_ucmd().args(&["-c", "-10", INPUT]).run().stdout_is_fixture("lists_prefix.expected");
|
||||
fn test_byte_sequence() {
|
||||
for param in vec!["-b", "--bytes"] {
|
||||
for example_seq in EXAMPLE_SEQUENCES {
|
||||
new_ucmd().args(&[param, example_seq.sequence, INPUT])
|
||||
.succeeds().stdout_only_fixture(format!("sequences/byte_{}.expected", example_seq.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
|
||||
#[test]
|
||||
fn test_char_sequence() {
|
||||
for param in vec!["-c", "--characters"] {
|
||||
for example_seq in EXAMPLE_SEQUENCES {
|
||||
//as of coreutils 8.25 a char range is effectively the same as a byte range; there is no distinct treatment of utf8 chars.
|
||||
new_ucmd().args(&[param, example_seq.sequence, INPUT])
|
||||
.succeeds().stdout_only_fixture(format!("sequences/byte_{}.expected", example_seq.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_char_range() {
|
||||
new_ucmd().args(&["-c", "4-10", INPUT]).run().stdout_is_fixture("lists_char_range.expected");
|
||||
fn test_field_sequence() {
|
||||
for param in vec!["-f", "--fields"] {
|
||||
for example_seq in EXAMPLE_SEQUENCES {
|
||||
new_ucmd().args(&[param, example_seq.sequence, INPUT])
|
||||
.succeeds().stdout_only_fixture(format!("sequences/field_{}.expected", example_seq.name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_column_to_end_of_line() {
|
||||
new_ucmd().args(&["-d", ":", "-f", "5-", INPUT]).run().stdout_is_fixture("lists_column_to_end_of_line.expected");
|
||||
fn test_specify_delimiter() {
|
||||
for param in vec!["-d", "--delimiter"] {
|
||||
new_ucmd().args(&[param, ":", "-f", COMPLEX_SEQUENCE.sequence, INPUT])
|
||||
.succeeds().stdout_only_fixture("delimiter_specified.expected");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_specific_field() {
|
||||
new_ucmd().args(&["-d", " ", "-f", "3", INPUT]).run().stdout_is_fixture("lists_specific_field.expected");
|
||||
fn test_output_delimiter() {
|
||||
// we use -d here to ensure output delimiter
|
||||
// is applied to the current, and not just the default, input delimiter
|
||||
new_ucmd().args(&["-d:", "--output-delimiter=@", "-f", COMPLEX_SEQUENCE.sequence, INPUT])
|
||||
.succeeds().stdout_only_fixture("output_delimiter.expected");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_multiple_fields() {
|
||||
new_ucmd().args(&["-d", ":", "-f", "1,3", INPUT]).run().stdout_is_fixture("lists_multiple_fields.expected");
|
||||
fn test_complement() {
|
||||
new_ucmd().args(&["-d_","--complement", "-f", "2"])
|
||||
.pipe_in("9_1\n8_2\n7_3")
|
||||
.succeeds().stdout_only("9\n8\n7\n");
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
|
||||
#[test]
|
||||
fn test_zero_terminated() {
|
||||
new_ucmd().args(&["-d_","-z", "-f", "1"])
|
||||
.pipe_in("9_1\n8_2\n\07_3")
|
||||
.succeeds().stdout_only("9\07\0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_tail() {
|
||||
new_ucmd().args(&["-d", ":", "--complement", "-f", "1", INPUT]).run().stdout_is_fixture("lists_tail.expected");
|
||||
fn test_only_delimited() {
|
||||
for param in vec!["-s", "--only-delimited"] {
|
||||
new_ucmd().args(&["-d_", param, "-f", "1"])
|
||||
.pipe_in("91\n82\n7_3")
|
||||
.succeeds().stdout_only("7\n");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg_attr(not(feature="test_unimplemented"),ignore)]
|
||||
#[test]
|
||||
fn test_change_delimiter() {
|
||||
new_ucmd()
|
||||
.args(&["-d", ":", "--complement", "--output-delimiter=#", "-f", "1", INPUT])
|
||||
.run().stdout_is_fixture("lists_change_delimiter.expected");
|
||||
fn test_zero_terminated_only_delimited() {
|
||||
new_ucmd().args(&["-d_","-z", "-s", "-f", "1"])
|
||||
.pipe_in("91\n\082\n7_3")
|
||||
.succeeds().stdout_only("82\n7\0");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue