X-Git-Url: http://git.rot13.org/?p=Biblio-RFID.git;a=blobdiff_plain;f=t%2F05-RFID501.t;h=5df40fec534ff91f613ca2a2cca99d45bdea9f5d;hp=d8e15e9297c6864b529311d1f62649ac8cced6ba;hb=85092c9643bc97fbacab4113f1de90311c00e37d;hpb=58fb6517969546d2b7b85bddf8b708e0c2c1df5a diff --git a/t/05-RFID501.t b/t/05-RFID501.t index d8e15e9..5df40fe 100755 --- a/t/05-RFID501.t +++ b/t/05-RFID501.t @@ -1,17 +1,48 @@ #!/usr/bin/perl -use Test::More tests => 3; +use Test::More tests => 8; use Data::Dump qw(dump); use lib 'lib'; BEGIN { - use_ok( 'RFID::Serial::Decode::RFID501' ); + use_ok( 'Biblio::RFID::RFID501' ); } -ok( my $hash = RFID::Serial::Decode::RFID501->to_hash( "\x04\x11\x00\x00200912310123\x00\x00\x00\x00" ), 'decode_tag' ); -diag dump $hash; +my $tags = +[ [ + "\4\21\0\0", + 2009, + "0101", + "0123", + "\0\0\0\0", + "\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( my $hash = RFID::Serial::Decode::RFID501->to_hash( "\x04\x11\x00\x011301234567\x00\x00\x00\x00\x00\x00" ), 'decode_tag' ); -diag dump $hash; +foreach my $tag ( @$tags ) { + + ok( $hash = Biblio::RFID::RFID501->to_hash( $tag ), 'to_hash' ); + diag dump $hash; + + ok( $bytes = Biblio::RFID::RFID501->from_hash( $hash ), 'from_hash' ); + my $orig = join('', @$tag); + cmp_ok( $bytes, 'eq', $orig, 'roundtrip' ); + + diag dump( $orig, $bytes ); + +} + +ok( my $bytes = Biblio::RFID::RFID501->blank, 'blank' ); +diag dump $bytes;