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.
This commit is contained in:
parent
01eb939a06
commit
42985b00ea
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user