summaryrefslogtreecommitdiff
path: root/tests/misc/cut.pl
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2015-07-17 23:30:30 -0400
committerAssaf Gordon <assafgordon@gmail.com>2015-09-12 02:27:32 +0000
commitbd1bc2b3fe1c87744cc251334cc1c804075b027c (patch)
tree5baeb6bacf915762980ff3e87cd4f203814ffc28 /tests/misc/cut.pl
parent5bbdcd2a02d9686edb788c46fc953192acdc6796 (diff)
downloadcoreutils-bd1bc2b3fe1c87744cc251334cc1c804075b027c.tar.xz
cut: refactor into set-fields module
Extract the functionality of parsing --field=LIST into a separate module, to be used by other programs. * src/cut.c: move field parsing code from here ... * src/set-fields.{c,h}: ... to here. (set_fields): generalize by supporting multiple parsing/reporting options. (struct range_pair): rename to field_range_pair. * src/local.mk: link cut with set-field. * po/POTFILES.in: add set-field.c * tests/misc/cut.pl: update wording of error messages
Diffstat (limited to 'tests/misc/cut.pl')
-rwxr-xr-xtests/misc/cut.pl27
1 files changed, 16 insertions, 11 deletions
diff --git a/tests/misc/cut.pl b/tests/misc/cut.pl
index 23e9ce36f..a6239d629 100755
--- a/tests/misc/cut.pl
+++ b/tests/misc/cut.pl
@@ -29,8 +29,10 @@ my $mb_locale = $ENV{LOCALE_FR_UTF8};
my $prog = 'cut';
my $try = "Try '$prog --help' for more information.\n";
-my $from_1 = "$prog: fields and positions are numbered from 1\n$try";
-my $inval = "$prog: invalid byte, character or field list\n$try";
+my $from_field1 = "$prog: fields are numbered from 1\n$try";
+my $from_pos1 = "$prog: byte/character positions are numbered from 1\n$try";
+my $inval_fld = "$prog: invalid field range\n$try";
+my $inval_pos = "$prog: invalid byte or character range\n$try";
my $no_endpoint = "$prog: invalid range with no endpoint: -\n$try";
my $nofield = "$prog: an input delimiter may be specified only when " .
"operating on fields\n$try";
@@ -42,16 +44,16 @@ my @Tests =
# This failed (as it should) even before coreutils-6.9.90,
# but cut from 6.9.90 produces a more useful diagnostic.
- ['zero-1', '-b0', {ERR=>$from_1}, {EXIT => 1} ],
+ ['zero-1', '-b0', {ERR=>$from_pos1}, {EXIT => 1} ],
# Up to coreutils-6.9, specifying a range of 0-2 was not an error.
# It was treated just like "-2".
- ['zero-2', '-f0-2', {ERR=>$from_1}, {EXIT => 1} ],
+ ['zero-2', '-f0-2', {ERR=>$from_field1}, {EXIT => 1} ],
# Up to coreutils-8.20, specifying a range of 0- was not an error.
- ['zero-3b', '-b0-', {ERR=>$from_1}, {EXIT => 1} ],
- ['zero-3c', '-c0-', {ERR=>$from_1}, {EXIT => 1} ],
- ['zero-3f', '-f0-', {ERR=>$from_1}, {EXIT => 1} ],
+ ['zero-3b', '-b0-', {ERR=>$from_pos1}, {EXIT => 1} ],
+ ['zero-3c', '-c0-', {ERR=>$from_pos1}, {EXIT => 1} ],
+ ['zero-3f', '-f0-', {ERR=>$from_field1}, {EXIT => 1} ],
['1', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
['2', '-d:', '-f1,3-', {IN=>"a:b:c\n"}, {OUT=>"a:c\n"}],
@@ -101,13 +103,16 @@ my @Tests =
{ERR=>"$prog: you must specify a list of bytes, characters, or fields\n$try"}
],
# Empty field list
- ['empty-fl', qw(-f ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$from_1}],
+ ['empty-fl', qw(-f ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1},
+ {ERR=>$from_field1}],
# Missing field list
- ['missing-fl', qw(-f --), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$inval}],
+ ['missing-fl', qw(-f --), {IN=>":\n"}, {OUT=>""}, {EXIT=>1},
+ {ERR=>$inval_fld}],
# Empty byte list
- ['empty-bl', qw(-b ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$from_1}],
+ ['empty-bl', qw(-b ''), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$from_pos1}],
# Missing byte list
- ['missing-bl', qw(-b --), {IN=>":\n"}, {OUT=>""}, {EXIT=>1}, {ERR=>$inval}],
+ ['missing-bl', qw(-b --), {IN=>":\n"}, {OUT=>""}, {EXIT=>1},
+ {ERR=>$inval_pos}],
# This test fails with cut from textutils-1.22.
['empty-f1', '-f1', {IN=>""}, {OUT=>""}],