File: 080_super.t

package info (click to toggle)
libunicode-utf8-perl 0.62-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 492 kB
  • sloc: perl: 2,365; sh: 6; makefile: 3
file content (35 lines) | stat: -rwxr-xr-x 690 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!perl

use strict;
use warnings;
use lib 't';

use Test::More tests => 1537;
use Util       qw[throws_ok];

BEGIN {
    use_ok('Unicode::UTF8', qw[ encode_utf8 ]);
}

my @SUPER = ();
{
    for (my $i = 0x0011_0000; $i < 0x7FFF_FFFF; $i += 0x200000) {
        push @SUPER, $i;
    }
    for (my $i = 0x8000_0000; $i < 0xFFFF_FFFF; $i += 0x400000) {
        push @SUPER, $i;
    }
}

foreach my $cp (@SUPER) {
    my $name = sprintf 'encode_utf8("\\x{%.4X}") super U-%.8X',
      $cp, $cp;

    my $string = do { no warnings 'utf8'; pack('U', $cp) };

    throws_ok { 
        use warnings FATAL => 'utf8';
        encode_utf8($string);
    } qr/Can't represent super code point/, $name;
}