mirror of
https://github.com/fluencelabs/redis
synced 2025-03-17 16:10:50 +00:00
BITCOUNT fuzzy test with random start/end added.
It was verified in practice that this test is able to stress much more the implementation by introducing errors that were only trivially to detect with different offsets but impossible to detect starting always at zero and counting bits the full length of the string.
This commit is contained in:
parent
746ce35f5f
commit
2a7847a3b5
@ -52,7 +52,7 @@ start_server {tags {"bitops"}} {
|
||||
}
|
||||
}
|
||||
|
||||
test {BITCOUNT fuzzing} {
|
||||
test {BITCOUNT fuzzing without start/end} {
|
||||
for {set j 0} {$j < 100} {incr j} {
|
||||
set str [randstring 0 3000]
|
||||
r set str $str
|
||||
@ -60,6 +60,20 @@ start_server {tags {"bitops"}} {
|
||||
}
|
||||
}
|
||||
|
||||
test {BITCOUNT fuzzing with start/end} {
|
||||
for {set j 0} {$j < 100} {incr j} {
|
||||
set str [randstring 0 3000]
|
||||
r set str $str
|
||||
set l [string length $str]
|
||||
set start [randomInt $l]
|
||||
set end [randomInt $l]
|
||||
if {$start > $end} {
|
||||
lassign [list $end $start] start end
|
||||
}
|
||||
assert {[r bitcount str $start $end] == [count_bits [string range $str $start $end]]}
|
||||
}
|
||||
}
|
||||
|
||||
test {BITCOUNT with start, end} {
|
||||
r set s "foobar"
|
||||
assert_equal [r bitcount s 0 -1] [count_bits "foobar"]
|
||||
|
Loading…
x
Reference in New Issue
Block a user