summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWen Hui <wen.hui.ware@gmail.com>2023-04-19 02:55:56 -0400
committerGitHub <noreply@github.com>2023-04-19 09:55:56 +0300
commit091412cf62f90c38cee20c1de2aa1016040d0e99 (patch)
tree18e6eb9a76d47f4e191424685f26c441bf4b22b2
parente5882da92bd0f39e74bf306ab34280e992956952 (diff)
downloadredis-091412cf62f90c38cee20c1de2aa1016040d0e99.tar.gz
add test cases for decr decrby on missing key (#12070)
Minor test case addition for DECR and DECRBY. Currently DECR and DECRBY do not have test case coverage for the scenarios where they run on a non-existing key.
-rw-r--r--tests/unit/type/incr.tcl11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/unit/type/incr.tcl b/tests/unit/type/incr.tcl
index a64f357ae..c09f2e8b2 100644
--- a/tests/unit/type/incr.tcl
+++ b/tests/unit/type/incr.tcl
@@ -13,6 +13,12 @@ start_server {tags {"incr"}} {
r decr novar
} {1}
+ test {DECR against key is not exist and incr} {
+ r del novar_not_exist
+ assert_equal {-1} [r decr novar_not_exist]
+ assert_equal {0} [r incr novar_not_exist]
+ }
+
test {INCR against key originally set with SET} {
r set novar 100
r incr novar
@@ -64,6 +70,11 @@ start_server {tags {"incr"}} {
r decrby novar 17179869185
} {-1}
+ test {DECRBY against key is not exist} {
+ r del key_not_exist
+ assert_equal {-1} [r decrby key_not_exist 1]
+ }
+
test {INCR uses shared objects in the 0-9999 range} {
r set foo -1
r incr foo