From f7c67505cba6735ea7d6a3365a588ddf32966dba Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 8 Nov 2026 22:19:26 +0100 Subject: [PATCH] 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 --- tests/uniq/uniq.pl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/tests/uniq/uniq.pl b/tests/uniq/uniq.pl index 0df7ec62d..809ffefc4 100755 --- a/tests/uniq/uniq.pl +++ b/tests/uniq/uniq.pl @@ -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;