/[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

Annotation of /t/01-Redis.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 10 - (hide annotations)
Sat Mar 21 23:05:02 2009 UTC (10 years, 4 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1474 byte(s)
del, small refacture into sock_result
1 dpavlin 2 #!/usr/bin/perl
2    
3     use warnings;
4     use strict;
5    
6 dpavlin 10 use Test::More tests => 43;
7 dpavlin 2
8     use lib 'lib';
9    
10     BEGIN {
11     use_ok( 'Redis' );
12     }
13    
14     ok( my $o = Redis->new(), 'new' );
15    
16     ok( $o->ping, 'ping' );
17    
18 dpavlin 5 ok( $o->set( foo => 'bar' ), 'set foo => bar' );
19 dpavlin 3
20 dpavlin 5 eval { $o->set( foo => 'bar', 1 ) };
21     ok( $@, 'set foo => bar new again failed' );
22    
23     cmp_ok( $o->get( 'foo' ), 'eq', 'bar', 'get foo = bar' );
24    
25     ok( $o->set( foo => 'baz' ), 'set foo => baz' );
26    
27     cmp_ok( $o->get( 'foo' ), 'eq', 'baz', 'get foo = baz' );
28    
29 dpavlin 10 $o->del('non-existant');
30    
31 dpavlin 9 ok( ! $o->exists( 'non-existant' ), 'exists non-existant' );
32 dpavlin 4 ok( ! $o->get( 'non-existant' ), 'get non-existant' );
33    
34 dpavlin 7 ok( $o->set('key-next' => 0), 'key-next = 0' );
35    
36     my $key_next = 3;
37    
38 dpavlin 8 ok( $o->set('key-left' => $key_next), 'key-left' );
39    
40 dpavlin 7 foreach ( 0 .. $key_next ) {
41 dpavlin 4 ok( $o->set( "key-$_" => $_ ), "set key-$_" );
42 dpavlin 9 ok( $o->exists( "key-$_" ), "exists key-$_" );
43 dpavlin 4 cmp_ok( $o->get( "key-$_" ), 'eq', $_, "get key-$_" );
44 dpavlin 7 cmp_ok( $o->incr( 'key-next' ), '==', $_ + 1, 'incr' );
45 dpavlin 8 cmp_ok( $o->decr( 'key-left' ), '==', $key_next - $_ - 1, 'decr' );
46 dpavlin 4 }
47    
48 dpavlin 7 cmp_ok( $o->get( 'key-next' ), '==', $key_next + 1, 'key-next' );
49    
50     ok( $o->set('test-incrby', 0), 'test-incrby' );
51 dpavlin 8 ok( $o->set('test-decrby', 0), 'test-decry' );
52 dpavlin 7 foreach ( 1 .. 3 ) {
53     cmp_ok( $o->incr('test-incrby', 3), '==', $_ * 3, 'incrby 3' );
54 dpavlin 8 cmp_ok( $o->decr('test-decrby', 7), '==', -( $_ * 7 ), 'decrby 7' );
55 dpavlin 7 }
56    
57 dpavlin 10 ok( $o->del('key-next' ), 'del' );
58    
59 dpavlin 2 ok( $o->quit, 'quit' );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26