coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] tests: add tests for basename's --zero option


From: Bernhard Voelker
Subject: [PATCH] tests: add tests for basename's --zero option
Date: Thu, 20 Dec 2012 15:49:55 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0

basename accepts the --zero option since March. Therefore, it's time to
add some tests. With these, basename's coverage is up to 100% again. ;-)

Have a nice day,
Berny


>From 1946c600e917113c70b687fef797ff8f94d24897 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker <address@hidden>
Date: Thu, 20 Dec 2012 15:48:44 +0100
Subject: [PATCH] tests: add tests for basename's --zero option

The -z option has been introduced in commit v8.15-60-ga3eb71a,
i.e. in coreutils-8.16.  Time to add some tests for it.

* tests/misc/basename.pl: Add tests exercising the -z option.
In the foreach loop to append a newline to the end of each
expected 'OUT' string, skip the -z tests.
---
 tests/misc/basename.pl |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)

diff --git a/tests/misc/basename.pl b/tests/misc/basename.pl
index d0ab57b..734ea83 100755
--- a/tests/misc/basename.pl
+++ b/tests/misc/basename.pl
@@ -61,9 +61,17 @@ my @Tests =
      ['8', qw(fs x),       {OUT => 'fs'}],
      ['9', qw(fs ''),      {OUT => 'fs'}],
      ['10', qw(fs/ s/),    {OUT => 'fs'}],
+
+     # Exercise -z option.
+     ['z0', qw(-z a),       {OUT => "a\0"}],
+     ['z1', qw(--zero a),   {OUT => "a\0"}],
+     ['z2', qw(-za a b),    {OUT => "a\0b\0"}],
+     ['z3', qw(-z ba a),    {OUT => "b\0"}],
+     ['z4', qw(-z -s a ba), {OUT => "b\0"}],
    );

 # Append a newline to end of each expected 'OUT' string.
+# Skip -z tests, i.e. those whose name matches /^z/.
 my $t;
 foreach $t (@Tests)
   {
@@ -72,7 +80,8 @@ foreach $t (@Tests)
     foreach $e (@$t)
       {
         $e->{OUT} = "$e->{OUT}\n"
-          if ref $e eq 'HASH' and exists $e->{OUT};
+          if ref $e eq 'HASH' and exists $e->{OUT}
+          and not $t->[0] =~ /^z/;
       }
   }

-- 
1.7.7



reply via email to

[Prev in Thread] Current Thread [Next in Thread]