File: non-shortest-form.t

package info (click to toggle)
libperlio-utf8-strict-perl 0.010-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 724 kB
  • sloc: perl: 278; makefile: 3
file content (33 lines) | stat: -rw-r--r-- 670 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
#! perl

use strict;
use warnings;
use utf8;

use Test::More 0.88;
use Test::Exception;
use lib 't/lib';
use Util qw[fh_with_octets pack_overlong_utf8 slurp];

my @tests = (
      0x00,
      0x80,
     0x800,
    0x1000,
);

foreach my $cp (@tests) {
    foreach my $sequence (pack_overlong_utf8($cp)) {
        my $name = sprintf 'reading non-shortest form representation of U+%.4X <%s> throws an exception',
          $cp, join ' ', map { sprintf '%.2X', ord $_ } split //, $sequence;

        my $fh = fh_with_octets($sequence);

        throws_ok {
            slurp($fh);
        } qr/^Can't decode ill-formed UTF-8 octet sequence/, $name;
    }
}

done_testing;