diff options
author | Jim Meyering <jim@meyering.net> | 2007-05-13 11:08:01 +0200 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-05-13 11:29:54 +0200 |
commit | 16385191ced6aeaf41f5669f723ade59a12b0e5d (patch) | |
tree | bf70e2c7378cca9905363535dcc6daf25656cde9 | |
parent | e06252480ac023b8c5f03ee1a8ab43d386fefd46 (diff) | |
download | coreutils-16385191ced6aeaf41f5669f723ade59a12b0e5d.tar.xz |
Test uniq's new --zero-terminated (-z) option.
* tests/uniq/Test.pm: When possible, create a "-z"-testing variant
of each existing test.
(2z, 3z, 4z, 5z, 20z, 122, 123): New tests from James Youngman.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | tests/uniq/Test.pm | 38 |
2 files changed, 42 insertions, 3 deletions
@@ -1,3 +1,10 @@ +2007-05-13 Jim Meyering <jim@meyering.net> + + Test uniq's new --zero-terminated (-z) option. + * tests/uniq/Test.pm: When possible, create a "-z"-testing variant + of each existing test. + (2z, 3z, 4z, 5z, 20z, 122, 123): New tests from James Youngman. + 2007-05-12 James Youngman <jay@gnu.org> Add -z option to uniq. Originally proposed by Egmont Koblinger. diff --git a/tests/uniq/Test.pm b/tests/uniq/Test.pm index 1eda7e224..ddc67ac6a 100644 --- a/tests/uniq/Test.pm +++ b/tests/uniq/Test.pm @@ -1,7 +1,6 @@ # Test "uniq". -# Copyright (C) 1998, 1999, 2001, 2002, 2003, 2004, 2005, 2006 Free -# Software Foundation, Inc. +# Copyright (C) 1998, 1999, 2001-2007 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -34,6 +33,14 @@ my @tv = ( ['5', '', "a\na\nb", "a\nb\n", 0], ['6', '', "b\na\na\n", "b\na\n", 0], ['7', '', "a\nb\nc\n", "a\nb\nc\n", 0], + +# Ensure that newlines are not interpreted with -z. +['2z', '-z', "a\na\n", "a\na\n\0", 0], +['3z', '-z', "a\na", "a\na\0", 0], +['4z', '-z', "a\nb", "a\nb\0", 0], +['5z', '-z', "a\na\nb", "a\na\nb\0", 0], +['20z','-dz', "a\na\n", "", 0], + # Make sure that eight bit characters work ['8', '', "ö\nv\n", "ö\nv\n", 0], # Test output of -u option; only unique lines @@ -107,10 +114,15 @@ my @tv = ( ['120', '-d -u', "a\na\n\b", "", 0], ['121', '-d -u -w340282366920938463463374607431768211456', "a\na\n\b", "", 0], +# Check that --zero-terminated is synonymous with -z. +['122', '--zero-terminated', "a\na\nb", "a\na\nb\0", 0], +['123', '--zero-terminated', "a\0a\0b", "a\0b\0", 0], ); sub test_vector { + my @new; + my $t; foreach $t (@tv) { @@ -122,9 +134,29 @@ sub test_vector $ret and $Test::input_via{$test_name} = {REDIR => 0}; + + push @new, $t; + + ########################################################### + # When possible, create a "-z"-testing variant of each test. + + # skip any test whose input or output already contains a NUL byte + $in =~ /\0/ || $exp =~ /\0/ + and next; + # skip any test that uses the -z option + $flags =~ /z/ + and next; + # skip the obsolete-syntax tests + $test_name =~ /^obs-plus/ + and next; + + (my $inz = $in) =~ tr/\n/\0/; + (my $expz = $exp) =~ tr/\n/\0/; + my $t2 = ["$test_name-z", "-z $flags", $inz, $expz, $ret]; + push @new, $t2; } - return @tv; + return @new; } 1; |