comparison t/incrdecr.t @ 0:30782bb1fc04 MEMCACHED_1_2_3

memcached-1.2.3
author Maxim Dounin <mdounin@mdounin.ru>
date Sun, 23 Sep 2007 03:58:34 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:30782bb1fc04
1 #!/usr/bin/perl
2
3 use strict;
4 use Test::More tests => 13;
5 use FindBin qw($Bin);
6 use lib "$Bin/lib";
7 use MemcachedTest;
8
9 my $server = new_memcached();
10 my $sock = $server->sock;
11
12 print $sock "set num 0 0 1\r\n1\r\n";
13 is(scalar <$sock>, "STORED\r\n", "stored num");
14 mem_get_is($sock, "num", 1, "stored 1");
15
16 print $sock "incr num 1\r\n";
17 is(scalar <$sock>, "2\r\n", "+ 1 = 2");
18 mem_get_is($sock, "num", 2);
19
20 print $sock "incr num 8\r\n";
21 is(scalar <$sock>, "10\r\n", "+ 8 = 10");
22 mem_get_is($sock, "num", 10);
23
24 print $sock "decr num 1\r\n";
25 is(scalar <$sock>, "9\r\n", "- 1 = 9");
26
27 print $sock "decr num 9\r\n";
28 is(scalar <$sock>, "0\r\n", "- 9 = 0");
29
30 print $sock "decr num 5\r\n";
31 is(scalar <$sock>, "0\r\n", "- 5 = 0");
32
33 print $sock "decr bogus 5\r\n";
34 is(scalar <$sock>, "NOT_FOUND\r\n", "can't decr bogus key");
35
36 print $sock "decr incr 5\r\n";
37 is(scalar <$sock>, "NOT_FOUND\r\n", "can't incr bogus key");
38
39 print $sock "set text 0 0 2\r\nhi\r\n";
40 is(scalar <$sock>, "STORED\r\n", "stored text");
41 print $sock "incr text 1\r\n";
42 is(scalar <$sock>, "1\r\n", "hi - 1 = 0");
43
44