3 |
use warnings; |
use warnings; |
4 |
use strict; |
use strict; |
5 |
|
|
6 |
use Test::More tests => 80; |
use Test::More tests => 92; |
7 |
|
|
8 |
use lib 'lib'; |
use lib 'lib'; |
9 |
|
|
15 |
|
|
16 |
ok( $o->ping, 'ping' ); |
ok( $o->ping, 'ping' ); |
17 |
|
|
18 |
|
diag "Commands operating on string values"; |
19 |
|
|
20 |
ok( $o->set( foo => 'bar' ), 'set foo => bar' ); |
ok( $o->set( foo => 'bar' ), 'set foo => bar' ); |
21 |
|
|
22 |
eval { $o->set( foo => 'bar', 1 ) }; |
eval { $o->set( foo => 'bar', 1 ) }; |
117 |
|
|
118 |
ok( ! $o->rpop( $list ), 'rpop' ); |
ok( ! $o->rpop( $list ), 'rpop' ); |
119 |
|
|
120 |
# Commands operating on sets |
|
121 |
|
diag "Commands operating on sets"; |
122 |
|
|
123 |
my $set = 'test-set'; |
my $set = 'test-set'; |
124 |
$o->del($set); |
$o->del($set); |
125 |
|
|
126 |
ok( $o->sadd( $set, 'foo' ), 'sadd' ); |
ok( $o->sadd( $set, 'foo' ), 'sadd' ); |
127 |
ok( ! $o->sadd( $set, 'foo' ), 'sadd' ); |
ok( ! $o->sadd( $set, 'foo' ), 'sadd' ); |
128 |
|
cmp_ok( $o->scard( $set ), '==', 1, 'scard' ); |
129 |
|
ok( $o->sismember( $set, 'foo' ), 'sismember' ); |
130 |
|
|
131 |
cmp_ok( $o->type( $set ), 'eq', 'set', 'type is set' ); |
cmp_ok( $o->type( $set ), 'eq', 'set', 'type is set' ); |
132 |
|
|
133 |
ok( $o->srem( $set, 'foo' ), 'srem' ); |
ok( $o->srem( $set, 'foo' ), 'srem' ); |
134 |
ok( ! $o->srem( $set, 'foo' ), 'srem again' ); |
ok( ! $o->srem( $set, 'foo' ), 'srem again' ); |
135 |
|
cmp_ok( $o->scard( $set ), '==', 0, 'scard' ); |
136 |
|
|
137 |
|
$o->sadd( 'test-set1', $_ ) foreach ( 'foo', 'bar', 'baz' ); |
138 |
|
$o->sadd( 'test-set2', $_ ) foreach ( 'foo', 'baz', 'xxx' ); |
139 |
|
|
140 |
|
my $inter = [ 'baz', 'foo' ]; |
141 |
|
|
142 |
|
is_deeply( [ $o->sinter( 'test-set1', 'test-set2' ) ], $inter, 'siter' ); |
143 |
|
|
144 |
|
ok( $o->sinterstore( 'test-set-inter', 'test-set1', 'test-set2' ), 'sinterstore' ); |
145 |
|
|
146 |
|
cmp_ok( $o->scard( 'test-set-inter' ), '==', $#$inter + 1, 'cardinality of intersection' ); |
147 |
|
|
148 |
|
|
149 |
|
diag "Multiple databases handling commands"; |
150 |
|
|
151 |
|
ok( $o->select( 1 ), 'select' ); |
152 |
|
ok( $o->select( 0 ), 'select' ); |
153 |
|
|
154 |
|
ok( $o->move( 'foo', 1 ), 'move' ); |
155 |
|
ok( ! $o->exists( 'foo' ), 'gone' ); |
156 |
|
|
157 |
|
ok( $o->select( 1 ), 'select' ); |
158 |
|
ok( $o->exists( 'foo' ), 'exists' ); |
159 |
|
|
160 |
|
diag "Connection handling"; |
161 |
|
|
162 |
ok( $o->quit, 'quit' ); |
ok( $o->quit, 'quit' ); |