diff options
author | antirez <antirez@gmail.com> | 2016-02-18 14:42:42 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2016-02-18 14:42:42 +0100 |
commit | f4befcc0ffd52fcec776b6e1174b6d6984353a2e (patch) | |
tree | 75fd54cb680ef1a3f9def5bdc526a11beec0aa64 /tests | |
parent | bb75ecddfdcab4fb530bb9c78088e53b28687816 (diff) | |
download | redis-f4befcc0ffd52fcec776b6e1174b6d6984353a2e.tar.gz |
GEOADD STORE/STOREDIST tests.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/geo.tcl | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/unit/geo.tcl b/tests/unit/geo.tcl index 181430a87..3aa06c99c 100644 --- a/tests/unit/geo.tcl +++ b/tests/unit/geo.tcl @@ -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]} { |