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
fc879abe
Commit
fc879abe
authored
Jun 07, 2011
by
antirez
Browse files
Merge branch 'unstable'
parents
e4f6b8c3
cf1eefa4
Changes
163
Hide whitespace changes
Inline
Side-by-side
tests/test_helper.tcl
View file @
fc879abe
...
...
@@ -110,6 +110,13 @@ proc cleanup {} {
}
proc execute_everything
{}
{
if 0
{
# Use this when hacking on new tests.
set ::verbose 1
execute_tests
"unit/first"
return
}
execute_tests
"unit/printver"
execute_tests
"unit/auth"
execute_tests
"unit/protocol"
...
...
tests/unit/type/set.tcl
View file @
fc879abe
...
...
@@ -105,6 +105,12 @@ start_server {
lsort
[
r smembers myset
]
}
{
a c
}
test
{
SREM variadic version with more args needed to destroy the key
}
{
r del myset
r sadd myset 1 2 3
r srem myset 1 2 3 4 5 6 7 8
}
{
3
}
foreach
{
type
}
{
hashtable intset
}
{
for
{
set i 1
}
{
$i
<= 5
}
{
incr i
}
{
r del
[
format
"set%d"
$i
]
...
...
tests/unit/type/zset.tcl
View file @
fc879abe
...
...
@@ -48,6 +48,34 @@ start_server {tags {"zset"}} {
assert_error
"*NaN*"
{
r zincrby myzset -inf abc
}
}
test
{
ZADD - Variadic version base case
}
{
r del myzset
list
[
r zadd myzset 10 a 20 b 30 c
]
[
r zrange myzset 0 -1 withscores
]
}
{
3
{
a 10 b 20 c 30
}}
test
{
ZADD - Return value is the number of actually added items
}
{
list
[
r zadd myzset 5 x 20 b 30 c
]
[
r zrange myzset 0 -1 withscores
]
}
{
1
{
x 5 a 10 b 20 c 30
}}
test
{
ZADD - Variadic version does not add nothing on single parsing err
}
{
r del myzset
catch
{
r zadd myzset 10 a 20 b 30.badscore c
}
e
assert_match
{
*ERR*not*double*
}
$e
r exists myzset
}
{
0
}
test
{
ZADD - Variadic version will raise error on missing arg
}
{
r del myzset
catch
{
r zadd myzset 10 a 20 b 30 c 40
}
e
assert_match
{
*ERR*syntax*
}
$e
}
test
{
ZINCRBY does not work variadic even if shares ZADD implementation
}
{
r del myzset
catch
{
r zincrby myzset 10 a 20 b 30 c
}
e
assert_match
{
*ERR*wrong*number*arg*
}
$e
}
test
"ZCARD basics -
$encoding
"
{
assert_equal 3
[
r zcard ztmp
]
assert_equal 0
[
r zcard zdoesntexist
]
...
...
@@ -65,6 +93,21 @@ start_server {tags {"zset"}} {
assert_equal 0
[
r exists ztmp
]
}
test
"ZREM variadic version"
{
r del ztmp
r zadd ztmp 10 a 20 b 30 c
assert_equal 2
[
r zrem ztmp x y a b k
]
assert_equal 0
[
r zrem ztmp foo bar
]
assert_equal 1
[
r zrem ztmp c
]
r exists ztmp
}
{
0
}
test
"ZREM variadic version -- remove elements after key deletion"
{
r del ztmp
r zadd ztmp 10 a 20 b 30 c
r zrem ztmp a b c d e f g
}
{
3
}
test
"ZRANGE basics -
$encoding
"
{
r del ztmp
r zadd ztmp 1 a
...
...
Prev
1
…
5
6
7
8
9
Next
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