summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2016-01-08 13:55:12 -0500
committerPádraig Brady <P@draigBrady.com>2016-01-13 11:11:36 +0000
commit672663e1b0afd68a10d991527fd5021c40c99acc (patch)
treee5ca8c84fbb1b863ab1ae5f9692e7da63e6a0585 /tests
parent8297568ec60103d95a56cf142d534f215086fe2b (diff)
downloadcoreutils-672663e1b0afd68a10d991527fd5021c40c99acc.tar.xz
numfmt: add the -z,--zero-terminated option
* doc/coreutils.texi (numfmt invocation): Reference the description. * src/numfmt.c: Parameterize '\n' references. * tests/misc/numfmt.pl: Add tests for character and field processing. * NEWS: Mention the new feature.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/misc/numfmt.pl29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/misc/numfmt.pl b/tests/misc/numfmt.pl
index 451bb34ab..3f2d6cc66 100755
--- a/tests/misc/numfmt.pl
+++ b/tests/misc/numfmt.pl
@@ -804,6 +804,32 @@ my @Tests =
{EXIT => 2}],
);
+# test null-terminated lines
+my @NullDelim_Tests =
+ (
+ # Input from STDIN
+ ['z1', '-z --to=iec',
+ {IN_PIPE => "1025\x002048\x00"}, {OUT=>"1.1K\x002.0K\x00"}],
+
+ # Input from the commandline - terminated by NULL vs NL
+ ['z3', ' --to=iec 1024', {OUT=>"1.0K\n"}],
+ ['z2', '-z --to=iec 1024', {OUT=>"1.0K\x00"}],
+
+ # Input from STDIN, with fields
+ ['z4', '-z --field=3 --to=si',
+ {IN_PIPE => "A B 1001 C\x00" .
+ "D E 2002 F\x00"},
+ {OUT => "A B 1.1K C\x00" .
+ "D E 2.1K F\x00"}],
+
+ # Input from STDIN, with fields and embedded NL
+ ['z5', '-z --field=3 --to=si',
+ {IN_PIPE => "A\nB 1001 C\x00" .
+ "D E\n2002 F\x00"},
+ {OUT => "A B 1.1K C\x00" .
+ "D E 2.1K F\x00"}],
+ );
+
my @Limit_Tests =
(
# Large Values
@@ -1080,6 +1106,9 @@ foreach $t (@Tests)
}
}
+# Add test for null-terminated lines (after adjusting the OUT string, above).
+push @Tests, @NullDelim_Tests;
+
my $save_temps = $ENV{SAVE_TEMPS};
my $verbose = $ENV{VERBOSE};