X-Git-Url: http://git.rot13.org/?p=perl-Redis.git;a=blobdiff_plain;f=t%2F01-Redis.t;h=3e6e62bd8efac2f6d53cc8830068f993c21e7ccd;hp=0eace1596ec331bb759948674fba1711b8940086;hb=158e8571dfb13b4cf308b1b00866c6557593336d;hpb=17bcbd7825f411e1b55e15b4e034433a9b1c4811 diff --git a/t/01-Redis.t b/t/01-Redis.t index 0eace15..3e6e62b 100755 --- a/t/01-Redis.t +++ b/t/01-Redis.t @@ -3,7 +3,7 @@ use warnings; use strict; -use Test::More tests => 55; +use Test::More tests => 66; use lib 'lib'; @@ -80,10 +80,25 @@ diag "dbsize: $nr_keys"; diag "Commands operating on lists"; -ok( $o->rpush( 'test-list' => 'foo' ), 'rpush' ); +my $list = 'test-list'; -ok( $o->lpush( 'test-list' => 'foo' ), 'lpush' ); +$o->del($list) && diag "cleanup $list from last run"; +ok( $o->rpush( $list => "r$_" ), 'rpush' ) foreach ( 1 .. 3 ); +ok( $o->lpush( $list => "l$_" ), 'lpush' ) foreach ( 1 .. 2 ); + +cmp_ok( $o->llen($list), '==', 5, 'llen' ); + +is_deeply( [ $o->lrange( $list, 0, 1 ) ], [ 'l2', 'l1' ], 'lrange' ); + +ok( $o->ltrim( $list, 1, 2 ), 'ltrim' ); +cmp_ok( $o->llen($list), '==', 2, 'llen after ltrim' ); + +cmp_ok( $o->lindex( $list, 0 ), 'eq', 'l1', 'lindex' ); +cmp_ok( $o->lindex( $list, 1 ), 'eq', 'r1', 'lindex' ); + +ok( $o->lset( $list, 0, 'foo' ), 'lset' ); +cmp_ok( $o->lindex( $list, 0 ), 'eq', 'foo', 'verified' ); ok( $o->quit, 'quit' );