Unverified Commit 42985b00 authored by Harkrishn Patro's avatar Harkrishn Patro Committed by GitHub
Browse files

Test coverage for incr/decr operation on robj encoding type optimization (#12435)

Additional test coverage for incr/decr operation.

integer number could be present in raw encoding format due to operation like append. A incr/decr operation following it optimize the string to int encoding format.
parent 01eb939a
......@@ -182,4 +182,33 @@ start_server {tags {"incr"}} {
r incrbyfloat foo [expr double(-1)/41]
r get foo
} {0}
foreach cmd {"incr" "decr" "incrby" "decrby"} {
test "$cmd operation should update encoding from raw to int" {
set res {}
set expected {1 12}
if {[string match {*incr*} $cmd]} {
lappend expected 13
} else {
lappend expected 11
}
r set foo 1
assert_encoding "int" foo
lappend res [r get foo]
r append foo 2
assert_encoding "raw" foo
lappend res [r get foo]
if {[string match {*by*} $cmd]} {
r $cmd foo 1
} else {
r $cmd foo
}
assert_encoding "int" foo
lappend res [r get foo]
assert_equal $res $expected
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment