Bit operations tests improved.
Fuzzing tests of BITCOUNT / BITOP are iterated multiple times. The new BITCOUNT fuzzing test uses random strings in a wider interval of lengths including zero-len strings.
This commit is contained in:
parent
5ca752bccb
commit
7021d1b75c
@ -44,11 +44,7 @@ start_server {tags {"bitops"}} {
|
|||||||
} 0
|
} 0
|
||||||
|
|
||||||
catch {unset num}
|
catch {unset num}
|
||||||
foreach vec [list \
|
foreach vec [list "" "\xaa" "\x00\x00\xff" "foobar"] {
|
||||||
"" "\xaa" "\x00\x00\xff" "foobar" \
|
|
||||||
[randstring 2000 3000] [randstring 2000 3000] \
|
|
||||||
[randstring 2000 3000] \
|
|
||||||
] {
|
|
||||||
incr num
|
incr num
|
||||||
test "BITCOUNT against test vector #$num" {
|
test "BITCOUNT against test vector #$num" {
|
||||||
r set str $vec
|
r set str $vec
|
||||||
@ -56,6 +52,14 @@ start_server {tags {"bitops"}} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test {BITCOUNT fuzzing} {
|
||||||
|
for {set j 0} {$j < 100} {incr j} {
|
||||||
|
set str [randstring 0 3000]
|
||||||
|
r set str $str
|
||||||
|
assert {[r bitcount str] == [count_bits $str]}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
test {BITCOUNT with start, end} {
|
test {BITCOUNT with start, end} {
|
||||||
r set s "foobar"
|
r set s "foobar"
|
||||||
assert_equal [r bitcount s 0 -1] [count_bits "foobar"]
|
assert_equal [r bitcount s 0 -1] [count_bits "foobar"]
|
||||||
@ -114,6 +118,7 @@ start_server {tags {"bitops"}} {
|
|||||||
|
|
||||||
foreach op {and or xor} {
|
foreach op {and or xor} {
|
||||||
test "BITOP $op fuzzing" {
|
test "BITOP $op fuzzing" {
|
||||||
|
for {set i 0} {$i < 10} {incr i} {
|
||||||
set vec {}
|
set vec {}
|
||||||
set veckeys {}
|
set veckeys {}
|
||||||
set numvec [expr {[randomInt 10]+1}]
|
set numvec [expr {[randomInt 10]+1}]
|
||||||
@ -128,3 +133,4 @@ start_server {tags {"bitops"}} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user