forked from movabletype/movabletype
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-serialize.t
35 lines (33 loc) · 920 Bytes
/
01-serialize.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl
# $Id: 01-serialize.t 1100 2007-12-12 01:48:53Z hachi $
use strict;
use warnings;
use lib 't/lib', 'extlib', 'lib', '../lib', '../extlib';
use Test::More tests => 73;
use_ok 'MT::Serialize';
use MT;
my @TESTS = (
{ },
{ foo => undef },
{ '' => 'bar' },
{ foo => '' },
{ foo => 0 },
{ foo => 'bar' },
{ foo => 'bar', baz => 'quux' },
);
for my $meth (qw( Storable MT )) {
my $ser = MT::Serialize->new($meth);
isa_ok($ser, 'MT::Serialize', "with $meth");
for my $hash (@TESTS) {
my $res = $ser->serialize(\$hash);
ok($res, 'serialize');
my $thawed = $ser->unserialize($res);
ok($thawed, 'unserialize');
is(ref($thawed), 'REF', 'REF');
my $hash2 = $$thawed;
is(ref($hash2), 'HASH', 'HASH');
for my $key (keys %$hash) {
is($hash->{$key}, $hash2->{$key}, "'$key' values");
}
}
}