Skip to content

Commit

Permalink
lib/locale.t: Fix tests, add a test
Browse files Browse the repository at this point in the history
The tests assumed that the lowest collating non-NUL control was \001.
This isn't necessarily true, and in a few locales caused the test to
fail.
  • Loading branch information
khwilliamson committed Jul 19, 2016
1 parent 91c0e2e commit 620f73f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/locale.t
Expand Up @@ -1738,11 +1738,22 @@ foreach my $Locale (@Locale) {

use locale;

my @sorted_controls = sort @{$posixes{'cntrl'}};
debug "sorted :cntrl: = ", disp_chars(@sorted_controls), "\n";

++$locales_test_number;
$test_names{$locales_test_number}
= 'Verify that \0 sorts before any other control';
my $ok = $sorted_controls[0] eq "\0";
report_result($Locale, $locales_test_number, $ok);
shift @sorted_controls;
my $lowest_control = $sorted_controls[0];

++$locales_test_number;
$test_names{$locales_test_number}
= 'Skip in locales where \001 has primary sorting weight; '
= 'Skip in locales where all controls have primary sorting weight; '
. 'otherwise verify that \0 doesn\'t have primary sorting weight';
if ("a\001c" lt "ab") {
if ("a${lowest_control}c" lt "ab") {
report_result($Locale, $locales_test_number, 1);
}
else {
Expand All @@ -1753,14 +1764,14 @@ foreach my $Locale (@Locale) {
++$locales_test_number;
$test_names{$locales_test_number}
= 'Verify that strings with embedded NUL collate';
my $ok = "a\0a\0a" lt "a\001a\001a";
$ok = "a\0a\0a" lt "a${lowest_control}a${lowest_control}a";
report_result($Locale, $locales_test_number, $ok);

++$locales_test_number;
$test_names{$locales_test_number}
= 'Verify that strings with embedded NUL and '
. 'extra trailing NUL collate';
$ok = "a\0a\0" lt "a\001a\001";
$ok = "a\0a\0" lt "a${lowest_control}a${lowest_control}";
report_result($Locale, $locales_test_number, $ok);

++$locales_test_number;
Expand Down

0 comments on commit 620f73f

Please sign in to comment.