X-Git-Url: http://git.rot13.org/?p=perl-Redis.git;a=blobdiff_plain;f=t%2F01-Redis.t;h=24806956941df18cd8139ccbbd459c6077531b30;hp=3fb3565426829fdeec96c72e76e8ea6638b22dec;hb=64af4a24c8afba6e53561caa02d0c0f840c14dda;hpb=14f9ac6110d126004b38b292b3e7002f84519629 diff --git a/t/01-Redis.t b/t/01-Redis.t index 3fb3565..2480695 100755 --- a/t/01-Redis.t +++ b/t/01-Redis.t @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More tests => 84; +use Test::More tests => 92; use lib 'lib'; @@ -15,6 +15,8 @@ ok( my $o = Redis->new(), 'new' ); ok( $o->ping, 'ping' ); +diag "Commands operating on string values"; + ok( $o->set( foo => 'bar' ), 'set foo => bar' ); eval { $o->set( foo => 'bar', 1 ) }; @@ -115,7 +117,8 @@ cmp_ok( $o->lpop( $list ), 'eq', 'r1', 'lpop' ); ok( ! $o->rpop( $list ), 'rpop' ); -# Commands operating on sets + +diag "Commands operating on sets"; my $set = 'test-set'; $o->del($set); @@ -134,6 +137,26 @@ cmp_ok( $o->scard( $set ), '==', 0, 'scard' ); $o->sadd( 'test-set1', $_ ) foreach ( 'foo', 'bar', 'baz' ); $o->sadd( 'test-set2', $_ ) foreach ( 'foo', 'baz', 'xxx' ); -is_deeply( [ $o->sinter( 'test-set1', 'test-set2' ) ], [ 'baz', 'foo' ], 'siter' ); +my $inter = [ 'baz', 'foo' ]; + +is_deeply( [ $o->sinter( 'test-set1', 'test-set2' ) ], $inter, 'siter' ); + +ok( $o->sinterstore( 'test-set-inter', 'test-set1', 'test-set2' ), 'sinterstore' ); + +cmp_ok( $o->scard( 'test-set-inter' ), '==', $#$inter + 1, 'cardinality of intersection' ); + + +diag "Multiple databases handling commands"; + +ok( $o->select( 1 ), 'select' ); +ok( $o->select( 0 ), 'select' ); + +ok( $o->move( 'foo', 1 ), 'move' ); +ok( ! $o->exists( 'foo' ), 'gone' ); + +ok( $o->select( 1 ), 'select' ); +ok( $o->exists( 'foo' ), 'exists' ); + +diag "Connection handling"; ok( $o->quit, 'quit' );