Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
b9bb7e2d
Commit
b9bb7e2d
authored
Jul 22, 2014
by
antirez
Browse files
Test: check sorted set elements order after union.
This is not a regression but issue #1786 showed the need for this test.
parent
d74e422b
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/type/zset.tcl
View file @
b9bb7e2d
...
@@ -588,6 +588,28 @@ start_server {tags {"zset"}} {
...
@@ -588,6 +588,28 @@ start_server {tags {"zset"}} {
r zrange to_here 0 -1
r zrange to_here 0 -1
}
{
100
}
}
{
100
}
test
{
ZUNIONSTORE result is sorted
}
{
# Create two sets with common and not common elements, perform
# the UNION, check that elements are still sorted.
r del one two dest
set cmd1
[
list r zadd one
]
set cmd2
[
list r zadd two
]
for
{
set j 0
}
{
$j
< 1000
}
{
incr j
}
{
lappend cmd1
[
expr rand
()]
[
randomInt 1000
]
lappend cmd2
[
expr rand
()]
[
randomInt 1000
]
}
{*}
$cmd1
{*}
$cmd2
assert
{[
r zcard one
]
> 100
}
assert
{[
r zcard two
]
> 100
}
r zunionstore dest 2 one two
set oldscore 0
foreach
{
ele score
}
[
r zrange dest 0 -1 withscores
]
{
assert
{
$score
>= $oldscore
}
set oldscore $score
}
}
proc stressers
{
encoding
}
{
proc stressers
{
encoding
}
{
if
{
$encoding
==
"ziplist"
}
{
if
{
$encoding
==
"ziplist"
}
{
# Little extra to allow proper fuzzing in the sorting stresser
# Little extra to allow proper fuzzing in the sorting stresser
...
...
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