tests: run locale tests on more systems

* tests/misc/numfmt.pl: Determine the thousands grouping character
in use, rather than skipping locale tests when it's not a space.
For example fr_FR.UTF-8 uses "NARROW NO-BREAK SPACE" as the grouping
char on modern glibc systems at least.
* tests/sort/sort-h-thousands-sep.sh: Likewise.
This commit is contained in:
Pádraig Brady committed 2023-12-29 18:04:29 +00:00
1 parent 4dda343663
commit ebb985dc41
2 files changed
+30 -19

No files matched your search

+19 -9
View File
@@ -1011,6 +1011,15 @@ my @Limit_Tests =
(system "$prog ---debug 1 2>&1|grep 'MAX_UNSCALED_DIGITS: 18' > /dev/null") == 0
and push @Tests, @Limit_Tests;
my $lg = ' ';
if ($locale ne 'C')
{
open(LOC_GRP, "env LC_ALL=$locale printf \"%'d\" 1111|tr -d 1|")
or die "Can't fork command: $!";
$lg = <LOC_GRP>;
close(LOC_GRP) || die "Failed to read locale grouping from printf";
}
my @Locale_Tests =
(
# Locale that supports grouping, but without '--grouping' parameter
@@ -1018,11 +1027,12 @@ my @Locale_Tests =
{ENV=>"LC_ALL=$locale"}],
# Locale with grouping
['lcl-grp-2', '--from=si --grouping 7M', {OUT=>"7 000 000"},
['lcl-grp-2', '--from=si --grouping 7M', {OUT=>"7${lg}000${lg}000"},
{ENV=>"LC_ALL=$locale"}],
# Locale with grouping and debug - no debug warning message
['lcl-grp-3', '--from=si --debug --grouping 7M', {OUT=>"7 000 000"},
['lcl-grp-3', '--from=si --debug --grouping 7M',
{OUT=>"7${lg}000${lg}000"},
{ENV=>"LC_ALL=$locale"}],
# Input with locale'd decimal-point
@@ -1033,21 +1043,21 @@ my @Locale_Tests =
{ENV=>"LC_ALL=$locale"}],
# Format + Grouping
['lcl-fmt-1', '--format "%\'f" 50000',{OUT=>"50 000"},
['lcl-fmt-1', '--format "%\'f" 50000',{OUT=>"50${lg}000"},
{ENV=>"LC_ALL=$locale"}],
['lcl-fmt-2', '--format "--%\'10f--" 50000', {OUT=>"-- 50 000--"},
['lcl-fmt-2', '--format "--%\'10f--" 50000', {OUT=>"-- 50${lg}000--"},
{ENV=>"LC_ALL=$locale"}],
['lcl-fmt-3', '--format "--%\'-10f--" 50000',{OUT=>"--50 000 --"},
['lcl-fmt-3', '--format "--%\'-10f--" 50000',{OUT=>"--50${lg}000 --"},
{ENV=>"LC_ALL=$locale"}],
['lcl-fmt-4', '--format "--%-10f--" --to=si 5000000',
{OUT=>"--5,0M --"},
{ENV=>"LC_ALL=$locale"}],
# handle zero/grouping in combination
['lcl-fmt-5', '--format="%\'06f" 1234',{OUT=>"01 234"},
['lcl-fmt-5', '--format="%\'06f" 1234',{OUT=>"01${lg}234"},
{ENV=>"LC_ALL=$locale"}],
['lcl-fmt-6', '--format="%0\'6f" 1234',{OUT=>"01 234"},
['lcl-fmt-6', '--format="%0\'6f" 1234',{OUT=>"01${lg}234"},
{ENV=>"LC_ALL=$locale"}],
['lcl-fmt-7', '--format="%0\'\'6f" 1234',{OUT=>"01 234"},
['lcl-fmt-7', '--format="%0\'\'6f" 1234',{OUT=>"01${lg}234"},
{ENV=>"LC_ALL=$locale"}],
);
@@ -1059,7 +1069,7 @@ if ($locale ne 'C')
or die "Can't fork command: $!";
my $loc_num = <LOC_NUM>;
close(LOC_NUM) || die "Failed to read grouped number from printf";
if ($loc_num ne '1 234')
if ($loc_num ne "1${lg}234")
{
warn "skipping locale grouping tests as 1234 groups like $loc_num\n";
$locale = 'C';
+11 -10
View File
@@ -21,25 +21,26 @@ print_ver_ sort
TEST_LOCALE='sv_SE'
test "$(LC_ALL="$TEST_LOCALE" locale thousands_sep)" = ' ' ||
lg="$(LC_ALL="$TEST_LOCALE" locale thousands_sep)"
test "$lg" ||
skip_ 'The Swedish locale with blank thousands separator is unavailable.'
tee exp1 exp3 > in << _EOF_
1 1k 1 M 4 003 1M
2k 2M 2 k 4 002 2
3M 3 3 G 4 001 3k
1 1k 1 M 4${lg}003 1M
2k 2M 2 k 4${lg}002 2
3M 3 3 G 4${lg}001 3k
_EOF_
cat > exp2 << _EOF_
3M 3 3 G 4 001 3k
1 1k 1 M 4 003 1M
2k 2M 2 k 4 002 2
3M 3 3 G 4${lg}001 3k
1 1k 1 M 4${lg}003 1M
2k 2M 2 k 4${lg}002 2
_EOF_
cat > exp5 << _EOF_
3M 3 3 G 4 001 3k
2k 2M 2 k 4 002 2
1 1k 1 M 4 003 1M
3M 3 3 G 4${lg}001 3k
2k 2M 2 k 4${lg}002 2
1 1k 1 M 4${lg}003 1M
_EOF_
for i in 1 2 3 5; do