mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 16:18:28 -05:00
Add fuzzy test for SETBIT
This commit is contained in:
parent
30407e1f4f
commit
e983cf34be
@ -422,6 +422,24 @@ start_server {tags {"basic"}} {
|
|||||||
assert_error "*out of range*" {r setbit mykey 0 20}
|
assert_error "*out of range*" {r setbit mykey 0 20}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "SETBIT fuzzing" {
|
||||||
|
set str ""
|
||||||
|
set len [expr 256*8]
|
||||||
|
r del mykey
|
||||||
|
|
||||||
|
for {set i 0} {$i < 2000} {incr i} {
|
||||||
|
set bitnum [randomInt $len]
|
||||||
|
set bitval [randomInt 2]
|
||||||
|
set fmt [format "%%-%ds%%d%%-s" $bitnum]
|
||||||
|
set head [string range $str 0 $bitnum-1]
|
||||||
|
set tail [string range $str $bitnum+1 end]
|
||||||
|
set str [string map {" " 0} [format $fmt $head $bitval $tail]]
|
||||||
|
|
||||||
|
r setbit mykey $bitnum $bitval
|
||||||
|
assert_equal [binary format B* $str] [r get mykey]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test "GETBIT against non-existing key" {
|
test "GETBIT against non-existing key" {
|
||||||
r del mykey
|
r del mykey
|
||||||
assert_equal 0 [r getbit mykey 0]
|
assert_equal 0 [r getbit mykey 0]
|
||||||
|
Loading…
Reference in New Issue
Block a user