.
[coreutils.git] / tests / wc / Test.pm
blob11607b03564cf13b8d21580db10a82af36ed62e8
1 package Test;
2 require 5.002;
3 use strict;
5 $Test::input_via_stdin = 1;
7 my @tv = (
8 # test flags input expected output expected return code
9 ['a0', '-c', '', " 0\n", 0],
10 ['a1', '-l', '', " 0\n", 0],
11 ['a2', '-w', '', " 0\n", 0],
12 ['a3', '-c', 'x', " 1\n", 0],
13 ['a4', '-w', 'x', " 1\n", 0],
14 ['a5', '-w', "x y\n", " 2\n", 0],
15 ['a6', '-w', "x y\nz", " 3\n", 0],
16 # Remember, -l counts *newline* bytes, not logical lines.
17 ['a7', '-l', "x y", " 0\n", 0],
18 ['a8', '-l', "x y\n", " 1\n", 0],
19 ['a9', '-l', "x\ny\n", " 2\n", 0],
20 ['b0', '', "", " 0 0 0\n", 0],
21 ['b1', '', "a b\nc\n", " 2 3 6\n", 0],
22 ['c0', '-L', "1\n12\n", " 2\n", 0],
23 ['c1', '-L', "1\n123\n1\n", " 3\n", 0],
24 ['c2', '-L', "\n123456", " 6\n", 0],
27 sub test_vector
29 my $t;
30 foreach $t (@tv)
32 my ($test_name, $flags, $in, $exp, $ret) = @$t;
33 # By default, test both stdin-redirection and input from a pipe.
34 $Test::input_via{$test_name} = {REDIR => 0, PIPE => 0};
36 # But if test name ends with `-file', test only with file arg(s).
37 # FIXME: unfortunately, invoking wc like `wc FILE' makes it put
38 # FILE in the ouput -- and FILE is different depending on $srcdir.
39 $Test::input_via{$test_name} = {FILE => 0}
40 if $test_name =~ /-file$/;
43 return @tv;