GEOADD STORE/STOREDIST tests.

This commit is contained in:
antirez 2016-02-18 14:42:42 +01:00
parent bb75ecddfd
commit f4befcc0ff

View File

@ -128,6 +128,60 @@ start_server {tags {"geo"}} {
assert {$m eq {}}
}
test {GEORADIUS STORE option: syntax error} {
r del points
r geoadd points 13.361389 38.115556 "Palermo" \
15.087269 37.502669 "Catania"
catch {r georadius points 13.361389 38.115556 50 km store} e
set e
} {*ERR*syntax*}
test {GEORANGE STORE option: incompatible options} {
r del points
r geoadd points 13.361389 38.115556 "Palermo" \
15.087269 37.502669 "Catania"
catch {r georadius points 13.361389 38.115556 50 km store points2 withdist} e
assert_match {*ERR*} $e
catch {r georadius points 13.361389 38.115556 50 km store points2 withhash} e
assert_match {*ERR*} $e
catch {r georadius points 13.361389 38.115556 50 km store points2 withcoords} e
assert_match {*ERR*} $e
}
test {GEORANGE STORE option: plain usage} {
r del points
r geoadd points 13.361389 38.115556 "Palermo" \
15.087269 37.502669 "Catania"
r georadius points 13.361389 38.115556 500 km store points2
assert_equal [r zrange points 0 -1] [r zrange points2 0 -1]
}
test {GEORANGE STOREDIST option: plain usage} {
r del points
r geoadd points 13.361389 38.115556 "Palermo" \
15.087269 37.502669 "Catania"
r georadius points 13.361389 38.115556 500 km storedist points2
set res [r zrange points2 0 -1 withscores]
assert {[lindex $res 1] < 1}
assert {[lindex $res 3] > 166}
assert {[lindex $res 3] < 167}
}
test {GEORANGE STOREDIST option: COUNT ASC and DESC} {
r del points
r geoadd points 13.361389 38.115556 "Palermo" \
15.087269 37.502669 "Catania"
r georadius points 13.361389 38.115556 500 km storedist points2 asc count 1
assert {[r zcard points2] == 1}
set res [r zrange points2 0 -1 withscores]
assert {[lindex $res 0] eq "Palermo"}
r georadius points 13.361389 38.115556 500 km storedist points2 desc count 1
assert {[r zcard points2] == 1}
set res [r zrange points2 0 -1 withscores]
assert {[lindex $res 0] eq "Catania"}
}
test {GEOADD + GEORANGE randomized test} {
set attempt 10
while {[incr attempt -1]} {