File: incomplete.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 (27 lines) | stat: -rw-r--r-- 569 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
#! 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_utf8 slurp];


for (my $cp = 0x80; $cp < 0x10FFFF; $cp += 0x1000) {
    my $sequence = substr(pack_utf8($cp), 0, -1);

    my $name = sprintf 'reading incomplete UTF-8 sequence <%s> throws an exception',
      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;