You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by rm...@apache.org on 2016/04/07 06:09:31 UTC
lucene-solr:branch_6x: LUCENE-7185: fix edge case bug in test logic
(min=max=180), don't leak Directory for edge cases!
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x e75db9476 -> cebac848a
LUCENE-7185: fix edge case bug in test logic (min=max=180), don't leak Directory for edge cases!
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/cebac848
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/cebac848
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/cebac848
Branch: refs/heads/branch_6x
Commit: cebac848a999db0b341d717c8edd39ecc9184671
Parents: e75db94
Author: Robert Muir <rm...@apache.org>
Authored: Thu Apr 7 00:08:03 2016 -0400
Committer: Robert Muir <rm...@apache.org>
Committed: Thu Apr 7 00:09:19 2016 -0400
----------------------------------------------------------------------
.../java/org/apache/lucene/geo/Rectangle.java | 2 +-
.../spatial/util/BaseGeoPointTestCase.java | 37 +++++++++++---------
2 files changed, 21 insertions(+), 18 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cebac848/lucene/core/src/java/org/apache/lucene/geo/Rectangle.java
----------------------------------------------------------------------
diff --git a/lucene/core/src/java/org/apache/lucene/geo/Rectangle.java b/lucene/core/src/java/org/apache/lucene/geo/Rectangle.java
index 527395e..592e202 100644
--- a/lucene/core/src/java/org/apache/lucene/geo/Rectangle.java
+++ b/lucene/core/src/java/org/apache/lucene/geo/Rectangle.java
@@ -66,7 +66,7 @@ public class Rectangle {
@Override
public String toString() {
StringBuilder b = new StringBuilder();
- b.append("GeoRect(lat=");
+ b.append("Rectangle(lat=");
b.append(minLat);
b.append(" TO ");
b.append(maxLat);
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/cebac848/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
----------------------------------------------------------------------
diff --git a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java b/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
index 6ae4d20..adca466 100644
--- a/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
+++ b/lucene/spatial/src/test/org/apache/lucene/spatial/util/BaseGeoPointTestCase.java
@@ -738,7 +738,7 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
static final boolean rectContainsPoint(Rectangle rect, double pointLat, double pointLon) {
assert Double.isNaN(pointLat) == false;
- if (rect.minLon < rect.maxLon) {
+ if (rect.minLon <= rect.maxLon) {
return GeoRelationUtils.pointInRectPrecise(pointLat, pointLon, rect.minLat, rect.maxLat, rect.minLon, rect.maxLon);
} else {
// Rect crosses dateline:
@@ -1223,26 +1223,29 @@ public abstract class BaseGeoPointTestCase extends LuceneTestCase {
// exact edge cases
assertEquals(8, s.count(newRectQuery(FIELD_NAME, rect.minLat, rect.maxLat, rect.minLon, rect.maxLon)));
- // expand 1 ulp in each direction
- assumeFalse("can't expand box, its too big already", rect.minLat == -90);
- assumeFalse("can't expand box, its too big already", rect.maxLat == 90);
- assumeFalse("can't expand box, its too big already", rect.minLon == -180);
- assumeFalse("can't expand box, its too big already", rect.maxLon == 180);
- assertEquals(8, s.count(newRectQuery(FIELD_NAME, Math.nextDown(rect.minLat), rect.maxLat, rect.minLon, rect.maxLon)));
- assertEquals(8, s.count(newRectQuery(FIELD_NAME, rect.minLat, Math.nextUp(rect.maxLat), rect.minLon, rect.maxLon)));
- assertEquals(8, s.count(newRectQuery(FIELD_NAME, rect.minLat, rect.maxLat, Math.nextDown(rect.minLon), rect.maxLon)));
- assertEquals(8, s.count(newRectQuery(FIELD_NAME, rect.minLat, rect.maxLat, rect.minLon, Math.nextUp(rect.maxLon))));
+ // expand 1 ulp in each direction if possible and test a slightly larger box!
+ if (rect.minLat != -90) {
+ assertEquals(8, s.count(newRectQuery(FIELD_NAME, Math.nextDown(rect.minLat), rect.maxLat, rect.minLon, rect.maxLon)));
+ }
+ if (rect.maxLat != 90) {
+ assertEquals(8, s.count(newRectQuery(FIELD_NAME, rect.minLat, Math.nextUp(rect.maxLat), rect.minLon, rect.maxLon)));
+ }
+ if (rect.minLon != -180) {
+ assertEquals(8, s.count(newRectQuery(FIELD_NAME, rect.minLat, rect.maxLat, Math.nextDown(rect.minLon), rect.maxLon)));
+ }
+ if (rect.maxLon != 180) {
+ assertEquals(8, s.count(newRectQuery(FIELD_NAME, rect.minLat, rect.maxLat, rect.minLon, Math.nextUp(rect.maxLon))));
+ }
- // now shrink 1 ulp in each direction: it should not include bogus stuff
- assumeFalse("can't shrink box, its too small already", rect.minLat == 90);
- assumeFalse("can't shrink box, its too small already", rect.maxLat == -90);
- assumeFalse("can't shrink box, its too small already", rect.minLon == 180);
- assumeFalse("can't shrink box, its too small already", rect.maxLon == -180);
- // note we put points on "sides" not just "corners" so we just shrink all 4 at once for now: it should exclude all points!
- assertEquals(0, s.count(newRectQuery(FIELD_NAME, Math.nextUp(rect.minLat),
+ // now shrink 1 ulp in each direction if possible: it should not include bogus stuff
+ if (rect.minLat != 90 && rect.maxLat != -90 && rect.minLon != 80 && rect.maxLon != -180) {
+ // note we put points on "sides" not just "corners" so we just shrink all 4 at once for now: it should exclude all points!
+ assertEquals(0, s.count(newRectQuery(FIELD_NAME, Math.nextUp(rect.minLat),
Math.nextDown(rect.maxLat),
Math.nextUp(rect.minLon),
Math.nextDown(rect.maxLon))));
+ }
+
r.close();
w.close();
dir.close();