summaryrefslogtreecommitdiff
path: root/t/incrdecr.t
diff options
context:
space:
mode:
authorBrad Fitzpatrick <brad@danga.com>2006-09-05 05:55:12 +0000
committerBrad Fitzpatrick <brad@danga.com>2006-09-05 05:55:12 +0000
commit61c41eeffc853ce38432ff46dc558909e46bca0a (patch)
tree28719b84192cc141a64c16f032358c91dc683bb7 /t/incrdecr.t
parent4b329cd1361edf929d3f802bd3fb50ae2acf7073 (diff)
downloadmemcached-61c41eeffc853ce38432ff46dc558909e46bca0a.tar.gz
rename 'test' to 't'.
git-svn-id: http://code.sixapart.com/svn/memcached/trunk/server@370 b0b603af-a30f-0410-a34e-baf09ae79d0b
Diffstat (limited to 't/incrdecr.t')
-rwxr-xr-xt/incrdecr.t44
1 files changed, 44 insertions, 0 deletions
diff --git a/t/incrdecr.t b/t/incrdecr.t
new file mode 100755
index 0000000..4abd691
--- /dev/null
+++ b/t/incrdecr.t
@@ -0,0 +1,44 @@
+#!/usr/bin/perl
+
+use strict;
+use Test::More tests => 13;
+use FindBin qw($Bin);
+use lib "$Bin/lib";
+use MemcachedTest;
+
+my $server = new_memcached();
+my $sock = $server->sock;
+
+print $sock "set num 0 0 1\r\n1\r\n";
+is(scalar <$sock>, "STORED\r\n", "stored num");
+mem_get_is($sock, "num", 1, "stored 1");
+
+print $sock "incr num 1\r\n";
+is(scalar <$sock>, "2\r\n", "+ 1 = 2");
+mem_get_is($sock, "num", 2);
+
+print $sock "incr num 8\r\n";
+is(scalar <$sock>, "10\r\n", "+ 8 = 10");
+mem_get_is($sock, "num", 10);
+
+print $sock "decr num 1\r\n";
+is(scalar <$sock>, "9\r\n", "- 1 = 9");
+
+print $sock "decr num 9\r\n";
+is(scalar <$sock>, "0\r\n", "- 9 = 0");
+
+print $sock "decr num 5\r\n";
+is(scalar <$sock>, "0\r\n", "- 5 = 0");
+
+print $sock "decr bogus 5\r\n";
+is(scalar <$sock>, "NOT_FOUND\r\n", "can't decr bogus key");
+
+print $sock "decr incr 5\r\n";
+is(scalar <$sock>, "NOT_FOUND\r\n", "can't incr bogus key");
+
+print $sock "set text 0 0 2\r\nhi\r\n";
+is(scalar <$sock>, "STORED\r\n", "stored text");
+print $sock "incr text 1\r\n";
+is(scalar <$sock>, "1\r\n", "hi - 1 = 0");
+
+