From 2b65f81e23063cded71dda7b78cbab7f92671a8b Mon Sep 17 00:00:00 2001 From: "Fuji, Goro" Date: Tue, 12 Oct 2010 22:58:53 +0900 Subject: [PATCH] Add tests --- perl/t/06_stream_unpack2.t | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/perl/t/06_stream_unpack2.t b/perl/t/06_stream_unpack2.t index bb6fe93d..11e3c61e 100644 --- a/perl/t/06_stream_unpack2.t +++ b/perl/t/06_stream_unpack2.t @@ -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(); + } +}