summaryrefslogtreecommitdiff
path: root/tests/pr
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2005-03-15 18:09:05 +0000
committerJim Meyering <jim@meyering.net>2005-03-15 18:09:05 +0000
commitfd304f1e0e121f7ff61fd2dc578b92e63ea4ccc5 (patch)
tree0957f364525d749fdb78173503b19506c0eed053 /tests/pr
parent6d9f816b5c21fc8ae9574db21e517a5a3785e41c (diff)
downloadcoreutils-fd304f1e0e121f7ff61fd2dc578b92e63ea4ccc5.tar.xz
Both `pr -0' and e.g., `pr -03' would evoke `column count too large'.
`pr -0' should give a better diagnostic and `pr -03' should be equivalent to `pr -3'. (parse_column_count): Change return type to void. Call error (EXIT_FAILURE, ... for an invalid string. (main): Allocate space for column_count_string using malloc. Accumulate all old-style column-count digits before converting. When the number of columns is specified via both old-style, (e.g., -3), and a long option (--columns=5), ensure that only the last one specified takes effect. Add tests for the above.
Diffstat (limited to 'tests/pr')
-rw-r--r--tests/pr/Test.pm10
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/pr/Test.pm b/tests/pr/Test.pm
index 8512bbf70..066212d44 100644
--- a/tests/pr/Test.pm
+++ b/tests/pr/Test.pm
@@ -346,6 +346,15 @@ my @tv = (
# This test would fail with textutils-2.1 and earlier.
['col-last', '-W3 -t2', "a\nb\nc\n", "a c\nb\n", 0],
+# Make sure that -02 is treated just like -2.
+['col-02', '-W3 -t -02', "a\nb\nc\n", "a c\nb\n", 0],
+# The -2 must override preceding column-count-specifying options.
+['col-2', '-W3 -t -4 --columns=1 -2', "a\nb\nc\n", "a c\nb\n", 0],
+# The --columns=2 must override preceding column-count-specifying options.
+['col-long', '-W3 -t -1 --columns=2', "a\nb\nc\n", "a c\nb\n", 0],
+# Make sure these fail.
+['col-0', '-0', '', '', 1],
+['col-inval', '-'.'9'x100, '', '', 1],
);
#']]);
@@ -364,6 +373,7 @@ sub test_vector
$flags = "$common_option_prefix$sep$flags";
push (@new_tv, [$test_name, $flags, $in, $exp, $ret]);
+ # For any use of -N, create an identical test with --columns=N.
(my $new_flags = $flags) =~ s/(^| )-(\d+)( |$)/$1--columns=$2$3/g;
$new_flags ne $flags
and push (@new_tv, ["$test_name.C", $new_flags, $in, $exp, $ret]);