/[Redis.pre-github]/t/01-Redis.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /t/01-Redis.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 18 by dpavlin, Sun Mar 22 09:44:30 2009 UTC revision 28 by dpavlin, Sun Mar 22 15:02:42 2009 UTC
# Line 3  Line 3 
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6  use Test::More tests => 54;  use Test::More tests => 75;
7    
8  use lib 'lib';  use lib 'lib';
9    
# Line 26  ok( $o->set( foo => 'baz' ), 'set foo => Line 26  ok( $o->set( foo => 'baz' ), 'set foo =>
26    
27  cmp_ok( $o->get( 'foo' ), 'eq', 'baz', 'get foo = baz' );  cmp_ok( $o->get( 'foo' ), 'eq', 'baz', 'get foo = baz' );
28    
29    ok( $o->set( 'test-undef' => 42 ), 'set test-undef' );
30    ok( $o->set( 'test-undef' => undef ), 'set undef' );
31    ok( ! defined $o->get( 'test-undef' ), 'get undef' );
32    diag $o->exists( 'test-undef' );
33    ok( $o->exists( 'test-undef' ), 'exists undef' );
34    
35  $o->del('non-existant');  $o->del('non-existant');
36    
37  ok( ! $o->exists( 'non-existant' ), 'exists non-existant' );  ok( ! $o->exists( 'non-existant' ), 'exists non-existant' );
# Line 80  diag "dbsize: $nr_keys"; Line 86  diag "dbsize: $nr_keys";
86    
87  diag "Commands operating on lists";  diag "Commands operating on lists";
88    
89  ok( $o->rpush( 'test-list' => 'foo' ), 'rpush' );  my $list = 'test-list';
90    
91    $o->del($list) && diag "cleanup $list from last run";
92    
93    ok( $o->rpush( $list => "r$_" ), 'rpush' ) foreach ( 1 .. 3 );
94    
95    ok( $o->lpush( $list => "l$_" ), 'lpush' ) foreach ( 1 .. 2 );
96    
97    cmp_ok( $o->type($list), 'eq', 'list', 'type' );
98    cmp_ok( $o->llen($list), '==', 5, 'llen' );
99    
100    is_deeply( [ $o->lrange( $list, 0, 1 ) ], [ 'l2', 'l1' ], 'lrange' );
101    
102    ok( $o->ltrim( $list, 1, 2 ), 'ltrim' );
103    cmp_ok( $o->llen($list), '==', 2, 'llen after ltrim' );
104    
105    cmp_ok( $o->lindex( $list, 0 ), 'eq', 'l1', 'lindex' );
106    cmp_ok( $o->lindex( $list, 1 ), 'eq', 'r1', 'lindex' );
107    
108    ok( $o->lset( $list, 0, 'foo' ), 'lset' );
109    cmp_ok( $o->lindex( $list, 0 ), 'eq', 'foo', 'verified' );
110    
111    ok( $o->lrem( $list, 1, 'foo' ), 'lrem' );
112    cmp_ok( $o->llen( $list ), '==', 1, 'llen after lrem' );
113    
114    cmp_ok( $o->lpop( $list ), 'eq', 'r1', 'lpop' );
115    
116    ok( ! $o->rpop( $list ), 'rpop' );
117    
118  ok( $o->quit, 'quit' );  ok( $o->quit, 'quit' );

Legend:
Removed from v.18  
changed lines
  Added in v.28

  ViewVC Help
Powered by ViewVC 1.1.26