SCAN: tests moved to unit/scan.tcl.

This commit is contained in:
antirez 2013-10-30 11:34:01 +01:00
parent 3c7a0677b0
commit a881827b6e
3 changed files with 56 additions and 54 deletions

View File

@ -17,6 +17,7 @@ set ::all_tests {
unit/auth
unit/protocol
unit/basic
unit/scan
unit/type/list
unit/type/list-2
unit/type/list-3

View File

@ -761,58 +761,4 @@ start_server {tags {"basic"}} {
r keys *
r keys *
} {dlskeriewrioeuwqoirueioqwrueoqwrueqw}
test "SCAN basic" {
r flushdb
r debug populate 1000
set cur 0
set keys {}
while 1 {
set res [r scan $cur]
set cur [lindex $res 0]
set k [lindex $res 1]
lappend keys $k
if {$cur == 0} break
}
set keys [lsort -unique [concat {*}$keys]]
assert_equal 1000 [llength $keys]
}
test "SCAN COUNT" {
r flushdb
r debug populate 1000
set cur 0
set keys {}
while 1 {
set res [r scan $cur count 5]
set cur [lindex $res 0]
set k [lindex $res 1]
lappend keys $k
if {$cur == 0} break
}
set keys [lsort -unique [concat {*}$keys]]
assert_equal 1000 [llength $keys]
}
test "SCAN MATCH" {
r flushdb
r debug populate 1000
set cur 0
set keys {}
while 1 {
set res [r scan $cur match "key:1??"]
set cur [lindex $res 0]
set k [lindex $res 1]
lappend keys $k
if {$cur == 0} break
}
set keys [lsort -unique [concat {*}$keys]]
assert_equal 100 [llength $keys]
}
}

55
tests/unit/scan.tcl Normal file
View File

@ -0,0 +1,55 @@
start_server {tags {"scan"}} {
test "SCAN basic" {
r flushdb
r debug populate 1000
set cur 0
set keys {}
while 1 {
set res [r scan $cur]
set cur [lindex $res 0]
set k [lindex $res 1]
lappend keys $k
if {$cur == 0} break
}
set keys [lsort -unique [concat {*}$keys]]
assert_equal 1000 [llength $keys]
}
test "SCAN COUNT" {
r flushdb
r debug populate 1000
set cur 0
set keys {}
while 1 {
set res [r scan $cur count 5]
set cur [lindex $res 0]
set k [lindex $res 1]
lappend keys $k
if {$cur == 0} break
}
set keys [lsort -unique [concat {*}$keys]]
assert_equal 1000 [llength $keys]
}
test "SCAN MATCH" {
r flushdb
r debug populate 1000
set cur 0
set keys {}
while 1 {
set res [r scan $cur match "key:1??"]
set cur [lindex $res 0]
set k [lindex $res 1]
lappend keys $k
if {$cur == 0} break
}
set keys [lsort -unique [concat {*}$keys]]
assert_equal 100 [llength $keys]
}
}