Add failing tests

This commit is contained in:
gfx 2010-09-15 15:25:48 +09:00
parent a11165830b
commit f8ee79ab72

View File

@ -3,7 +3,7 @@ use warnings;
use Data::MessagePack;
use Test::More tests => 6;
my $input = [(undef)x16];
my $input = [42, "foo", { x => [ (undef)x16 ] }, 3.14 ];
my $packed = Data::MessagePack->pack($input);
is_deeply(Data::MessagePack->unpack($packed), $input);
@ -17,9 +17,33 @@ is_deeply(Data::MessagePack->unpack($packed), $input);
{
my $up = Data::MessagePack::Unpacker->new();
is $up->execute(substr($packed, 0, 3), 0), 3;
ok !$up->is_finished;
$up->execute($packed, 3);
ok $up->is_finished;
is_deeply $up->data, $input;
}
{
my $up = Data::MessagePack::Unpacker->new();
my $offset = 0;
my $size = 5;
note "length: ", length($packed);
while(not $up->is_finished) {
note "offset: ", $offset;
my $bytes = substr($packed, $offset, $size);
note join " ", map { unpack 'H2', $_ } split //, $bytes;
my $x = $up->execute($bytes, 0);
if($x <= 0) {
diag "Something's wrong: $x";
last;
}
else {
$offset += $x;
}
}
ok $up->is_finished;
is_deeply $up->data, $input;
}