X-Git-Url: http://git.shiar.nl/wormy.git/blobdiff_plain/7c64957ec9a87cf71ccf5fa7c28bb8c37b27efc6..3f547138025ead9303d443e1d41e5e4c884c570d:/t/parser.t diff --git a/t/parser.t b/t/parser.t new file mode 100644 index 0000000..cebd099 --- /dev/null +++ b/t/parser.t @@ -0,0 +1,33 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use Test::More; +use Data::Dumper; + +plan tests => 5; + +use_ok('Parse::Binary::Nested'); + +my $example = Parse::Binary::Nested->new([ + foos => [ + 'C', + message => 'Z*', + period => 'C', + ], + trail => 'a*', +]); +ok($example, 'example parser'); +my $data = $example->unpackf("\2foo\0!\0.rest"); +is(ref $data, 'HASH', 'output structure'); +is($data->{foos}->[1]->{period}, ord '.', 'sample element'); + +is_deeply( + Parse::Binary::Nested->new( + [ lstr => 'Ca3', rest => 'a*' ] + )->unpackf("\2quux"), + { lstr => 'qu', rest => 'x' }, + 'length string' +); +