This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
XS-APItest/t/utf8.t: Test with longest possible overlong
authorKarl Williamson <khw@cpan.org>
Fri, 28 Oct 2016 14:46:53 +0000 (08:46 -0600)
committerKarl Williamson <khw@cpan.org>
Sat, 29 Oct 2016 14:54:44 +0000 (08:54 -0600)
As part of testing, certain malformations are perturbed to also be
overlong to see that the combination of them is properly handled.  To do
this, the code will take a test case and calculate an overlong that is
longer than it.  However if the test case is as long as the overlong
would be, this can't be done, and is skipped.  This commit now
uses a longer overlong than previously (now the maximum possible) so
that fewer tests have to be skipped.

ext/XS-APItest/t/utf8.t

index 4ec38fa..fc04dfc 100644 (file)
@@ -1985,10 +1985,10 @@ foreach my $test (@tests) {
 
                         foreach my $overlong ("", "overlong") {
 
-                            # Our hard-coded overlong starts with \xFE, so
+                            # If we're already at the longest possible, we
+                            # can't create an overlong (which would be longer)
                             # can't handle anything larger.
-                            next if $overlong
-                            && ord native_to_I8(substr($bytes, 0, 1)) >= 0xFE;
+                            next if $overlong && $expected_len >= $max_bytes;
 
                             my @malformations;
                             my @expected_errors;
@@ -2030,12 +2030,12 @@ foreach my $test (@tests) {
                                     # to the exact same code point as the
                                     # original.
                                     $this_bytes
-                                    = I8_to_native("\xfe")
+                                    = I8_to_native("\xff")
                                     . (I8_to_native(chr $first_continuation)
-                                       x ( 6 - length($this_bytes)))
+                                       x ( $max_bytes - 1 - length($this_bytes)))
                                     . $this_bytes;
                                     $this_length = length($this_bytes);
-                                    $this_expected_len = 7;
+                                    $this_expected_len = $max_bytes;
                                     push @expected_errors, $UTF8_GOT_LONG;
                                 }
                                 if ($malformations_name =~ /short/) {