X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;ds=sidebyside;f=t%2F05-RFID501.t;h=b4010d89c00c2a3e3841e01589366b3c14d04337;hb=ce9d70e4bf2232ea3d444c1930cb6fd8be34096c;hp=19e470fd38ab56197cc209dc9055b7f06bb1618f;hpb=324de0d12567568b5c2ef6b6e4c8babb5ff01d48;p=Biblio-RFID.git diff --git a/t/05-RFID501.t b/t/05-RFID501.t index 19e470f..b4010d8 100755 --- a/t/05-RFID501.t +++ b/t/05-RFID501.t @@ -1,6 +1,6 @@ #!/usr/bin/perl -use Test::More tests => 4; +use Test::More tests => 7; use Data::Dump qw(dump); use lib 'lib'; @@ -9,13 +9,8 @@ BEGIN { use_ok( 'RFID::Biblio::RFID501' ); } -ok( my $hash = RFID::Biblio::RFID501->to_hash( "\x04\x11\x00\x00200912310123\x00\x00\x00\x00" ), 'decode_tag' ); -diag dump $hash; - -ok( $hash = RFID::Biblio::RFID501->to_hash( "\x04\x11\x00\x011301234567\x00\x00\x00\x00\x00\x00" ), 'decode_tag' ); -diag dump $hash; - -my $tag = [ +my $tags = +[ [ "\4\21\0\0", 2009, "0101", @@ -24,8 +19,27 @@ my $tag = [ "\xFF\xFF\xFF\xFF", "\x7F\xFF\xFF\xFF", "\0\0\0\0", -]; +],[ + "\4\21\0\1", + 1302, + "0037", + "67\0\0", + "\0\0\0\0", + "\0\0\0\0", + "\0\0\0\0", + "\0\0\0\0", +] ]; -ok( $hash = RFID::Biblio::RFID501->to_hash( $tag ), 'decode_tag' ); -diag dump $hash; +foreach my $tag ( @$tags ) { + + ok( $hash = RFID::Biblio::RFID501->to_hash( $tag ), 'to_hash' ); + diag dump $hash; + + ok( $bytes = RFID::Biblio::RFID501->from_hash( $hash ), 'from_hash' ); + my $orig = join('', @$tag); + cmp_ok( $bytes, 'eq', $orig, 'roundtrip' ); + + diag dump( $orig, $bytes ); + +}