File: 15_utf8.t

package info (click to toggle)
libdata-messagepack-perl 1.02-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,060 kB
  • sloc: ansic: 5,697; perl: 1,123; makefile: 10
file content (33 lines) | stat: -rw-r--r-- 647 bytes parent folder | download | duplicates (7)
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 -w
use strict;
use Test::More;
use Data::MessagePack;
use utf8;

my $data = [42, undef, 'foo', "\x{99f1}\x{99dd}"];
my $packed = Data::MessagePack->pack($data) x 2;

my $u = Data::MessagePack::Unpacker->new()->utf8();
my $p = 0;
for(1 .. 2) {
    ok $u->get_utf8();
    $p = $u->execute($packed, $p);
    my $d = $u->data();
    $u->reset();
    is_deeply $d, $data, 'decoded';
}

is $u->utf8(0), $u, 'utf8(0)';
$p = 0;
for(1 .. 2) {
    ok !$u->get_utf8();
    $p = $u->execute($packed, $p);
    my $d = $u->data();
    $u->reset();
    my $s = $data->[3];
    utf8::encode($s);
    is_deeply $d->[3], $s, 'not decoded';
}

done_testing;