mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-19 21:18:23 +01:00
Add tests
This commit is contained in:
parent
c10eb2c17b
commit
2b65f81e23
@ -1,15 +1,16 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Data::MessagePack;
|
||||
use Test::More tests => 9;
|
||||
use Test::More tests => 61;
|
||||
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","","","",
|
||||
-2147483648,0.0,-0.0, 3.14,-3.14,"a","a","a","","","",
|
||||
[0],[0],[0],[],[],[],{},{},{},
|
||||
{"a" => 97},{"a" => 97},{"a" => 97},[[]],[["a"]]
|
||||
{"a" => 97},{"abc" => 97},{"xyz" => 97},[[]], [["foo"], ["bar"]],
|
||||
[["foo", true, false, null, 42]],
|
||||
];
|
||||
|
||||
my $packed = Data::MessagePack->pack($input);
|
||||
@ -40,4 +41,21 @@ is_deeply(Data::MessagePack->unpack($packed), $input);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
my $s = '';
|
||||
foreach my $datum(reverse @{$input}) {
|
||||
$s .= Data::MessagePack->pack($datum);
|
||||
}
|
||||
|
||||
my $up = Data::MessagePack::Unpacker->new();
|
||||
|
||||
my $offset = 0;
|
||||
for my $datum(reverse @{$input}) {
|
||||
note "offset: $offset/".length($s);
|
||||
|
||||
$offset = $up->execute($s, $offset);
|
||||
is_deeply $up->data, $datum;
|
||||
$up->reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user