msgpack/perl/t/10_splitted_bytes.t

41 lines
1002 B
Perl
Raw Normal View History

2010-09-17 13:10:54 +09:00
#!perl
# This feature is not yet supported, but 0.23 (or former) caused SEGV in this code,
# so we put it here.
use strict;
use warnings;
use Data::MessagePack;
use Test::More;
use t::Util;
my $input = [
false,true,null,0,0,0,0,0,0,0,0,0,-1,-1,-1,-1,-1,
127,127,255,65535,4294967295,-32,-32,-128,-32768,
-2147483648,0.0,-0.0,1.0,-1.0,"a","a","a","","","",
[0],[0],[0],[],[],[],{},{},{},
{"a" => 97},{"a" => 97},{"a" => 97},[[]],[["a"]]
];
my $packed = Data::MessagePack->pack($input);
foreach my $size(1 .. 16) {
my $up = Data::MessagePack::Unpacker->new();
open my $stream, '<:bytes :scalar', \$packed;
binmode $stream;
my $buff;
2010-09-18 09:44:32 +09:00
my $done = 0;
2010-09-17 13:10:54 +09:00
while( read($stream, $buff, $size) ) {
note "buff: ", join " ", map { unpack 'H2', $_ } split //, $buff;
2010-09-17 13:10:54 +09:00
2010-09-18 09:44:32 +09:00
$done = $up->execute($buff);
2010-09-17 13:10:54 +09:00
}
2010-09-18 09:44:32 +09:00
is $done, length($packed);
ok $up->is_finished, "is_finished: $size";
2010-09-17 13:10:54 +09:00
my $data = $up->data;
is_deeply $data, $input;
}
done_testing;