Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e983cf34
Commit
e983cf34
authored
Dec 15, 2010
by
Pieter Noordhuis
Browse files
Add fuzzy test for SETBIT
parent
30407e1f
Changes
1
Show whitespace changes
Inline
Side-by-side
tests/unit/basic.tcl
View file @
e983cf34
...
...
@@ -422,6 +422,24 @@ start_server {tags {"basic"}} {
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"
{
r del mykey
assert_equal 0
[
r getbit mykey 0
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment