tests: uniq: check diagnostics for invalid -f, -s and -w values

* tests/uniq/uniq.pl (147, 148, 149, 150, 151): New tests.
Ensure each option has its own message and that the value
is printed as given, including empty values and spaces.
https://github.com/uutils/coreutils/pull/15971

Link: https://github.com/coreutils/coreutils/pull/452
This commit is contained in:
Sylvestre Ledru authored and Pádraig Brady committed 2026-11-09 00:13:34 +00:00
1 parent fc65b03e3f
commit f7c67505cb
1 file changed
+14 -2
+14 -2
View File
@@ -237,6 +237,17 @@ my @Tests =
# Test for read buffer overrun.
do { my $longline = "\360\237\230\200" . "A" x 255 . "\n";
['146', '-w256', {IN => $longline x 2}, {OUT => $longline}] },
# Invalid -f, -s and -w values; the value is printed as given.
['147', '-f x', {IN=>""}, {EXIT=>1},
{ERR=>"$prog: 'x': invalid number of fields to skip\n"}],
['148', '-s x', {IN=>""}, {EXIT=>1},
{ERR=>"$prog: 'x': invalid number of bytes to skip\n"}],
['149', '-w x', {IN=>""}, {EXIT=>1},
{ERR=>"$prog: 'x': invalid number of bytes to compare\n"}],
['150', '--skip-fields=', {IN=>""}, {EXIT=>1},
{ERR=>"$prog: '': invalid number of fields to skip\n"}],
['151', "-f 'a b'", {IN=>""}, {EXIT=>1},
{ERR=>"$prog: 'a b': invalid number of fields to skip\n"}],
);
# Locale related tests
@@ -283,7 +294,7 @@ if ($mb_locale ne 'C')
my @new_t = @$t;
my $test_name = shift @new_t;
# In test #145, replace the each ‘...’ by '...'.
# In test #145, replace each ‘...’ by '...'.
if ($test_name =~ "145")
{
my $sub = { ERR_SUBST => "s/‘([^’]+)’/'\$1'/g"};
@@ -292,7 +303,8 @@ if ($mb_locale ne 'C')
}
next if ( $test_name =~ "schar"
or $test_name =~ "^obs-plus"
or $test_name =~ "119");
or $test_name =~ "119"
or grep { $test_name eq $_ } (147..151));
push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}];
}
push @Tests, @new;