This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
utf8n_to_uvuni: Avoid reading outside of buffer
[perl5.git] / ext / XS-APItest / t / utf8.t
CommitLineData
fed3ba5d
NC
1#!perl -w
2
3use strict;
4use Test::More;
5
6use XS::APItest;
7
8foreach ([0, '', '', 'empty'],
9 [0, 'N', 'N', '1 char'],
10 [1, 'NN', 'N', '1 char substring'],
11 [-2, 'Perl', 'Rules', 'different'],
12 [0, chr 163, chr 163, 'pound sign'],
13 [1, chr (163) . 10, chr (163) . 1, '10 pounds is more than 1 pound'],
14 [1, chr(163) . chr(163), chr 163, '2 pound signs are more than 1'],
15 [-2, ' $!', " \x{1F42B}!", 'Camels are worth more than 1 dollar'],
16 [-1, '!', "!\x{1F42A}", 'Initial substrings match'],
17 ) {
18 my ($expect, $left, $right, $desc) = @$_;
19 my $copy = $right;
20 utf8::encode($copy);
21 is(bytes_cmp_utf8($left, $copy), $expect, $desc);
22 next if $right =~ tr/\0-\377//c;
23 utf8::encode($left);
24 is(bytes_cmp_utf8($right, $left), -$expect, "$desc reversed");
25}
26
27done_testing;