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
5b1207c6
Commit
5b1207c6
authored
Nov 28, 2009
by
antirez
Browse files
ZRANGEBYSCORE fuzzy test
parent
c74e7c77
Changes
1
Hide whitespace changes
Inline
Side-by-side
test-redis.tcl
View file @
5b1207c6
...
@@ -1024,6 +1024,45 @@ proc main {server port} {
...
@@ -1024,6 +1024,45 @@ proc main {server port} {
$r zrangebyscore zset 2 4
$r zrangebyscore zset 2 4
}
{
b c d
}
}
{
b c d
}
test
{
ZRANGEBYSCORE fuzzy test, 100 ranges in 1000 elements sorted set
}
{
set err
{}
$r del zset
for
{
set i 0
}
{
$i
< 1000
}
{
incr i
}
{
$r zadd zset
[
expr rand
()]
$i
}
for
{
set i 0
}
{
$i
< 100
}
{
incr i
}
{
set min
[
expr rand
()]
set max
[
expr rand
()]
if
{
$min
> $max
}
{
set aux $min
set min $max
set max $aux
}
set low
[
$r
zrangebyscore zset -inf $min
]
set ok
[
$r
zrangebyscore zset $min $max
]
set high
[
$r
zrangebyscore zset $max +inf
]
foreach x $low
{
set score
[
$r
zscore zset $x
]
if
{
$score
> $min
}
{
append err
"Error, score for
$x
is
$score
>
$min
\n
"
}
}
foreach x $ok
{
set score
[
$r
zscore zset $x
]
if
{
$score
< $min || $score > $max
}
{
append err
"Error, score for
$x
is
$score
outside
$min-$max
range
\n
"
}
}
foreach x $high
{
set score
[
$r
zscore zset $x
]
if
{
$score
< $max
}
{
append err
"Error, score for
$x
is
$score
<
$max
\n
"
}
}
}
set _ $err
}
{}
test
{
Sorted sets +inf and -inf handling
}
{
test
{
Sorted sets +inf and -inf handling
}
{
$r del zset
$r del zset
$r zadd zset -100 a
$r zadd zset -100 a
...
...
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