From: Pádraig Brady
Date: Wed, 27 Aug 2025 13:34:46 +0000 (+0100) Subject: tests: fold: add tests for multi-byte width X-Git-Tag: v9.8~87 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4b35a3b9201742ddff56062a13cf20ce4e9bc9be;p=thirdparty%2Fcoreutils.git tests: fold: add tests for multi-byte width * tests/fold/fold.pl: The i18n patch didn't actually test folding of multi-byte characters, so add tests for various multi-byte forms. --- diff --git a/tests/fold/fold.pl b/tests/fold/fold.pl index de34177fda..ea9bc5c6af 100755 --- a/tests/fold/fold.pl +++ b/tests/fold/fold.pl @@ -50,12 +50,25 @@ my @Tests = {OUT=>"123456\n7890\nabcdef\nghij\n123456\n7890"}], ); +# define UTF-8 encoded multi-byte characters for tests +my $eaC = "\xC3\xA9"; # e acute NFC form +my $eaD = "\x65\xCC\x81"; # e acute NFD form (zero width combining) +my $eFW = "\xEF\xBD\x85"; # e fullwidth + +my @mbTests = + ( + ['smb1', '-w2', {IN=>$eaC x 3}, {OUT=>$eaC x 2 . "\n" . $eaC}], + ['smb2', '-w2', {IN=>$eaD x 3}, {OUT=>$eaD x 2 . "\n" . $eaD}], + ['smb3', '-w2', {IN=>$eFW x 2}, {OUT=>$eFW . "\n" . $eFW}], + ); + if ($mb_locale ne 'C') { # Duplicate each test vector, appending "-mb" to the test name and # inserting {ENV => "LC_ALL=$mb_locale"} in the copy, so that we # provide coverage for multi-byte code paths. my @new; + foreach my $t (@Tests) { my @new_t = @$t; @@ -64,6 +77,15 @@ if ($mb_locale ne 'C') push @new, ["$test_name-mb", @new_t, {ENV => "LC_ALL=$mb_locale"}]; } push @Tests, @new; + + @new = (); + foreach my $t (@mbTests) + { + my @new_t = @$t; + + push @new, [@new_t, {ENV => "LC_ALL=$mb_locale"}]; + } + push @Tests, @new; } @Tests = triple_test \@Tests;