summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2014-10-03 12:28:56 +0100
committerantirez <antirez@gmail.com>2014-10-03 12:28:56 +0100
commit389ec305b3e984422b91eca112e4ce37728fba20 (patch)
treeb0b5f8b34bf3b2f95e99acf8263eeb891a132709
parent16559b461521625271430d7d4926b632f3a326dd (diff)
downloadredis-389ec305b3e984422b91eca112e4ce37728fba20.tar.gz
Test: check that INCR object sharing works as expected.
-rw-r--r--tests/unit/basic.tcl23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit/basic.tcl b/tests/unit/basic.tcl
index 110376087..90a5b4cc3 100644
--- a/tests/unit/basic.tcl
+++ b/tests/unit/basic.tcl
@@ -150,6 +150,29 @@ start_server {tags {"basic"}} {
r decrby novar 17179869185
} {-1}
+ test {INCR uses shared objects in the 0-9999 range} {
+ r set foo -1
+ r incr foo
+ assert {[r object refcount foo] > 1}
+ r set foo 9998
+ r incr foo
+ assert {[r object refcount foo] > 1}
+ r incr foo
+ assert {[r object refcount foo] == 1}
+ }
+
+ test {INCR can modify objects in-place} {
+ r set foo 20000
+ r incr foo
+ assert {[r object refcount foo] == 1}
+ set old [lindex [split [r debug object foo]] 1]
+ r incr foo
+ set new [lindex [split [r debug object foo]] 1]
+ assert {[string range $old 0 2] eq "at:"}
+ assert {[string range $new 0 2] eq "at:"}
+ assert {$old eq $new}
+ }
+
test {INCRBYFLOAT against non existing key} {
r del novar
list [roundFloat [r incrbyfloat novar 1]] \