1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-08-07 09:11:11 +02:00

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.
This commit is contained in:
Bernhard Voelker
2012-12-20 16:38:56 +01:00
parent c388053e14
commit 0568f72d2a
+10 -1
View File
@@ -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 'OUT' string has a trailing '\0'.
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 $e->{OUT} =~ /\0$/;
}
}