/[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 5 by dpavlin, Sat Mar 21 22:20:51 2009 UTC revision 13 by dpavlin, Sat Mar 21 23:26:46 2009 UTC
# Line 3  Line 3 
3  use warnings;  use warnings;
4  use strict;  use strict;
5    
6  use Test::More tests => 18;  use Test::More tests => 49;
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    $o->del('non-existant');
30    
31    ok( ! $o->exists( 'non-existant' ), 'exists non-existant' );
32  ok( ! $o->get( 'non-existant' ), 'get non-existant' );  ok( ! $o->get( 'non-existant' ), 'get non-existant' );
33    
34  foreach ( 0 .. 3 ) {  ok( $o->set('key-next' => 0), 'key-next = 0' );
35          ok(     $o->set( "key-$_" => $_ ),           "set key-$_" );  
36          cmp_ok( $o->get( "key-$_"       ), 'eq', $_, "get key-$_" );  my $key_next = 3;
37    
38    ok( $o->set('key-left' => $key_next), 'key-left' );
39    
40    my @keys;
41    
42    foreach ( 0 .. $key_next ) {
43            my $key = 'key-' . $_;
44            push @keys, $key;
45            ok(     $o->set( $key => $_ ),           "set $key" );
46            ok(  $o->exists( $key       ),           "exists $key" );
47            cmp_ok( $o->get( $key       ), 'eq', $_, "get $key" );
48            cmp_ok( $o->incr( 'key-next' ), '==', $_ + 1, 'incr' );
49            cmp_ok( $o->decr( 'key-left' ), '==', $key_next - $_ - 1, 'decr' );
50    }
51    
52    cmp_ok( $o->get( 'key-next' ), '==', $key_next + 1, 'key-next' );
53    
54    ok( $o->set('test-incrby', 0), 'test-incrby' );
55    ok( $o->set('test-decrby', 0), 'test-decry' );
56    foreach ( 1 .. 3 ) {
57            cmp_ok( $o->incr('test-incrby', 3), '==', $_ * 3, 'incrby 3' );
58            cmp_ok( $o->decr('test-decrby', 7), '==', -( $_ * 7 ), 'decrby 7' );
59  }  }
60    
61    ok( $o->del( $_ ), "del $_" ) foreach map { "key-$_" } ( 'next', 'left' );
62    ok( ! $o->del('non-existing' ), 'del non-existing' );
63    
64    cmp_ok( $o->type('foo'), 'eq', 'string', 'type' );
65    
66    cmp_ok( $o->keys('key-*'), '==', $key_next + 1, 'key-*' );
67    is_deeply( [ $o->keys('key-*') ], [ @keys ], 'keys' );
68    
69    ok( my $key = $o->randomkey, 'randomkey' );
70    diag "key: $key";
71    
72  ok( $o->quit, 'quit' );  ok( $o->quit, 'quit' );

Legend:
Removed from v.5  
changed lines
  Added in v.13

  ViewVC Help
Powered by ViewVC 1.1.26