|
Revision 5090, 0.9 kB
(checked in by takayama, 4 days ago)
|
|
* Fixed to work unit test.
|
-
Property svn:mime-type set to
text/plain
|
| Line | |
|---|
| 1 | #!/usr/bin/perl |
|---|
| 2 | # $Id: 01-serialize.t 1100 2007-12-12 01:48:53Z hachi $ |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | use lib 't/lib', 'extlib', 'lib', '../lib', '../extlib'; |
|---|
| 6 | use Test::More tests => 73; |
|---|
| 7 | use_ok 'MT::Serialize'; |
|---|
| 8 | use MT; |
|---|
| 9 | |
|---|
| 10 | my @TESTS = ( |
|---|
| 11 | { }, |
|---|
| 12 | { foo => undef }, |
|---|
| 13 | { '' => 'bar' }, |
|---|
| 14 | { foo => '' }, |
|---|
| 15 | { foo => 0 }, |
|---|
| 16 | { foo => 'bar' }, |
|---|
| 17 | { foo => 'bar', baz => 'quux' }, |
|---|
| 18 | ); |
|---|
| 19 | |
|---|
| 20 | for my $meth (qw( Storable MT )) { |
|---|
| 21 | my $ser = MT::Serialize->new($meth); |
|---|
| 22 | isa_ok($ser, 'MT::Serialize', "with $meth"); |
|---|
| 23 | for my $hash (@TESTS) { |
|---|
| 24 | my $res = $ser->serialize(\$hash); |
|---|
| 25 | ok($res, 'serialize'); |
|---|
| 26 | my $thawed = $ser->unserialize($res); |
|---|
| 27 | ok($thawed, 'unserialize'); |
|---|
| 28 | is(ref($thawed), 'REF', 'REF'); |
|---|
| 29 | my $hash2 = $$thawed; |
|---|
| 30 | is(ref($hash2), 'HASH', 'HASH'); |
|---|
| 31 | for my $key (keys %$hash) { |
|---|
| 32 | is($hash->{$key}, $hash2->{$key}, "'$key' values"); |
|---|
| 33 | } |
|---|
| 34 | } |
|---|
| 35 | } |
|---|