summaryrefslogtreecommitdiff
path: root/tests/wc/Test.pm
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1997-07-13 19:45:14 +0000
committerJim Meyering <jim@meyering.net>1997-07-13 19:45:14 +0000
commit7e73237bac16bce0cdd82527bd1cf0f729efeeba (patch)
tree1b7ae8d2b0850d4b4065f1c62ee7cbf47d4041e8 /tests/wc/Test.pm
parent8568fe543ba5631ec9afb31b7ceab77b84ce364f (diff)
downloadcoreutils-7e73237bac16bce0cdd82527bd1cf0f729efeeba.tar.xz
.
Diffstat (limited to 'tests/wc/Test.pm')
-rwxr-xr-xtests/wc/Test.pm42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/wc/Test.pm b/tests/wc/Test.pm
new file mode 100755
index 000000000..0f7de7831
--- /dev/null
+++ b/tests/wc/Test.pm
@@ -0,0 +1,42 @@
+package Test;
+require 5.002;
+use strict;
+
+$Test::input_via_stdin = 1;
+
+my @tv = (
+# test flags input expected output expected return code
+['a0', '-c', '', " 0\n", 0],
+['a1', '-l', '', " 0\n", 0],
+['a2', '-w', '', " 0\n", 0],
+['a3', '-c', 'x', " 1\n", 0],
+['a4', '-w', 'x', " 1\n", 0],
+['a5', '-w', "x y\n", " 2\n", 0],
+['a6', '-w', "x y\nz", " 3\n", 0],
+['a7', '-l', "x y", " 1\n", 0],
+['a8', '-l', "x y\n", " 1\n", 0],
+['a9', '-l', "x\ny\n", " 2\n", 0],
+['b0', '', "", " 0 0 0\n", 0],
+['b1', '', "a b\nc\n", " 2 3 6\n", 0],
+);
+
+sub test_vector
+{
+ my $t;
+ foreach $t (@tv)
+ {
+ my ($test_name, $flags, $in, $exp, $ret) = @$t;
+ # By default, test both stdin-redirection and input from a pipe.
+ $Test::input_via{$test_name} = {REDIR => 0, PIPE => 0};
+
+ # But if test name ends with `-file', test only with file arg(s).
+ # FIXME: unfortunately, invoking wc like `wc FILE' makes it put
+ # FILE in the ouput -- and FILE is different depending on $srcdir.
+ $Test::input_via{$test_name} = {FILE => 0}
+ if $test_name =~ /-file$/;
+ }
+
+ return @tv;
+}
+
+1;