From 672663e1b0afd68a10d991527fd5021c40c99acc Mon Sep 17 00:00:00 2001 From: Assaf Gordon Date: Fri, 8 Jan 2016 13:55:12 -0500 Subject: 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. --- tests/misc/numfmt.pl | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests') 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}; -- cgit v1.2.3-54-g00ecf