From: rkinyon Date: Wed, 22 Mar 2006 03:33:30 +0000 (+0000) Subject: Added more tests X-Git-Tag: 0-99_01~48 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4c3601d754673225a9765153161e2f5d9ab115f2;p=dbsrgits%2FDBM-Deep.git Added more tests --- diff --git a/t/lib/TestSimpleHash.pm b/t/lib/TestSimpleHash.pm index 4dd36eb..7e036c6 100644 --- a/t/lib/TestSimpleHash.pm +++ b/t/lib/TestSimpleHash.pm @@ -10,32 +10,41 @@ use Test::Exception; use base 'TestBase'; -sub A_assignment : Test( no_plan ) { +sub A_assignment : Test( 23 ) { my $self = shift; my $db = $self->{db}; - my $rotate = 0; + my @keys = keys %{$self->{data}}; + + push @keys, $keys[0] while @keys < 3; - while ( my ($k,$v) = each %{$self->{data}} ) { - $rotate = ++$rotate % 3; + #die "@keys\n"; - if ( $rotate == 0 ) { - $db->{$k} = $v; - } - elsif ( $rotate == 1 ) { - $db->put( $k => $v ); - } - else { - $db->store( $k => $v ); - } + cmp_ok( keys %$db, '==', 0 ); + + foreach my $k ( @keys[0..2] ) { + ok( !exists $db->{$k} ); + ok( !$db->exists( $k ) ); + } + $db->{$keys[0]} = $self->{data}{$keys[0]}; + $db->put( $keys[1] => $self->{data}{$keys[1]} ); + $db->store( $keys[2] => $self->{data}{$keys[2]} ); + + foreach my $k ( @keys[0..2] ) { ok( $db->exists( $k ) ); ok( exists $db->{$k} ); - is( $db->{$k}, $v ); - is( $db->get($k), $v ); - is( $db->fetch($k), $v ); + is( $db->{$k}, $self->{data}{$k} ); + is( $db->get($k), $self->{data}{$k} ); + is( $db->fetch($k), $self->{data}{$k} ); + } + + if ( @keys > 3 ) { + $db->{$_} = $self->{data}{$_} for @keys[3..$#keys]; } + + cmp_ok( keys %$db, '==', @keys ); } sub B_check_keys : Test( 1 ) { @@ -79,7 +88,7 @@ sub E_delete : Test( 12 ) { my $db = $self->{db}; my @keys = keys %{$self->{data}}; - cmp_ok( scalar(keys %$db), '==', scalar(@keys) ); + cmp_ok( keys %$db, '==', @keys ); my $key1 = $keys[0]; ok( exists $db->{$key1} ); @@ -97,7 +106,7 @@ sub E_delete : Test( 12 ) { @{$db}{ @keys[0,1] } = @{$self->{data}}{@keys[0,1]}; - cmp_ok( scalar(keys %$db), '==', scalar(@keys) ); + cmp_ok( keys %$db, '==', @keys ); } sub F_clear : Test( 3 ) { @@ -105,14 +114,14 @@ sub F_clear : Test( 3 ) { my $db = $self->{db}; my @keys = keys %{$self->{data}}; - cmp_ok( scalar(keys %$db), '==', scalar(@keys) ); + cmp_ok( keys %$db, '==', @keys ); %$db = (); cmp_ok( keys %$db, '==', 0 ); %$db = %{$self->{data}}; - cmp_ok( scalar(keys %$db), '==', scalar(@keys) ); + cmp_ok( keys %$db, '==', @keys ); } sub G_reassign_and_close : Test( 4 ) { diff --git a/t/run.t b/t/run.t index 6683064..39ecc93 100644 --- a/t/run.t +++ b/t/run.t @@ -9,7 +9,7 @@ use DBM::Deep; use Test1; -my $test = Test1->new( +my $test1 = Test1->new( data => { key1 => 'value1', key2 => undef, @@ -17,4 +17,14 @@ my $test = Test1->new( }, ); -$test->runtests; +my %test2; +$test2{"key $_"} = "value $_" for 1 .. 4000; + +my $test2 = Test1->new( + data => \%test2, +); + +Test::Class->runtests( + $test1, +# $test2, +);