diff options
author | Pádraig Brady <P@draigBrady.com> | 2015-06-22 02:12:32 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2015-06-22 02:21:02 +0100 |
commit | bc9d16b79f4e8c25e13be63f846cfd7152b65da1 (patch) | |
tree | f59de970119880a9a860a2ca258c4ad64677a0c3 /tests | |
parent | a3c3e1e9e6d2d953692f1eb24efa9ac7c7448044 (diff) | |
download | coreutils-bc9d16b79f4e8c25e13be63f846cfd7152b65da1.tar.xz |
numfmt: handle leading zeros correctly
* src/numfmt.c (simple_strtod_int): Don't count leading zeros
as significant digits. Also have leading zeros as optional
for floating point numbers.
* tests/misc/numfmt.pl: Add test cases.
* NEWS: Mention the fix.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/misc/numfmt.pl | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/misc/numfmt.pl b/tests/misc/numfmt.pl index 25bba61b2..a6432a76c 100755 --- a/tests/misc/numfmt.pl +++ b/tests/misc/numfmt.pl @@ -659,6 +659,19 @@ my @Tests = ['large-15',$limits->{INTMAX_OFLOW}, {OUT=>$limits->{INTMAX_OFLOW}}], ['large-16','9.300000000000000000', {OUT=>'9.300000000000000000'}], + # Leading zeros weren't handled appropriately before 8.24 + ['leading-1','0000000000000000000000000001', {OUT=>"1"}], + ['leading-2','.1', {OUT=>"0.1"}], + ['leading-3','bad.1', + {ERR => "$prog: invalid number: 'bad.1'\n"}, + {EXIT => 2}], + ['leading-4','..1', + {ERR => "$prog: invalid suffix in input: '..1'\n"}, + {EXIT => 2}], + ['leading-5','1.', + {ERR => "$prog: invalid number: '1.'\n"}, + {EXIT => 2}], + # precision override ['precision-1','--format=%.4f 9991239123 --to=si', {OUT=>"9.9913G"}], ['precision-2','--format=%.1f 9991239123 --to=si', {OUT=>"10.0G"}], |