diff options
author | Yang Bodong <bodong.ybd@alibaba-inc.com> | 2021-02-05 01:39:07 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-04 19:39:07 +0200 |
commit | b7b23a0ff50b6d921528289173d6edb6cc1f643a (patch) | |
tree | 7f4263892f05b8f0f946cb95495165ab2fe574dc /tests | |
parent | ded1655d49950afd02bb3c5199bd33caac995e7c (diff) | |
download | redis-b7b23a0ff50b6d921528289173d6edb6cc1f643a.tar.gz |
Fix GEOSEARCH tcl test error (#8451)
Issue with new test due to longitude wraparound.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/unit/geo.tcl | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/tests/unit/geo.tcl b/tests/unit/geo.tcl index 47100dfa8..a51d1dc5c 100644 --- a/tests/unit/geo.tcl +++ b/tests/unit/geo.tcl @@ -566,6 +566,13 @@ start_server {tags {"geo"}} { foreach name [array names points] { set x [lindex $points($name) 0] set y [lindex $points($name) 1] + # If longitude crosses -180° or 180°, we need to convert it. + # latitude doesn't have this problem, because it's scope is -70~70, see geo_random_point + if {$x > 180} { + set x [expr {$x-360}] + } elseif {$x < -180} { + set x [expr {$x+360}] + } r geoadd mypoints $x $y place:$name lappend tcl_result "place:$name" lappend debuginfo "geoadd mypoints $x $y place:$name" @@ -579,7 +586,7 @@ start_server {tags {"geo"}} { set res [lsort [r geosearch mypoints fromlonlat $search_lon $search_lat bybox $width_new $height_new m]] if {$res != $res2} { set diff [compare_lists $res $res2] - lappend debuginfo "diff: $diff" + lappend debuginfo "res: $res, res2: $res2, diff: $diff" fail "place should be found, debuginfo: $debuginfo, height_new: $height_new width_new: $width_new" } @@ -588,8 +595,7 @@ start_server {tags {"geo"}} { set height_new [expr {$height_m+4}] set res [lsort [r geosearch mypoints fromlonlat $search_lon $search_lat bybox $width_new $height_new m]] if {$res != {place:north place:south}} { - set diff [compare_lists $res $res2] - lappend debuginfo "diff: $diff" + lappend debuginfo "res: $res" fail "place should not be found, debuginfo: $debuginfo, height_new: $height_new width_new: $width_new" } @@ -598,8 +604,7 @@ start_server {tags {"geo"}} { set height_new [expr {$height_m-4}] set res [lsort [r geosearch mypoints fromlonlat $search_lon $search_lat bybox $width_new $height_new m]] if {$res != {place:east place:west}} { - set diff [compare_lists $res $res2] - lappend debuginfo "diff: $diff" + lappend debuginfo "res: $res" fail "place should not be found, debuginfo: $debuginfo, height_new: $height_new width_new: $width_new" } |