You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2015/04/22 17:37:41 UTC
svn commit: r1675385 -
/lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java
Author: dsmiley
Date: Wed Apr 22 15:37:41 2015
New Revision: 1675385
URL: http://svn.apache.org/r1675385
Log:
LUCENE-6196: RectIntersectionTestHelper: fix to work with testing rectangles, and more clearly test when the shape.getBoundingBox may be faulty
Modified:
lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java
Modified: lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java?rev=1675385&r1=1675384&r2=1675385&view=diff
==============================================================================
--- lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java (original)
+++ lucene/dev/branches/lucene6196/lucene/spatial/src/test/org/apache/lucene/spatial/spatial4j/RectIntersectionTestHelper.java Wed Apr 22 15:37:41 2015
@@ -34,15 +34,24 @@ public abstract class RectIntersectionTe
super(ctx);
}
+ /** Override to return true if generateRandomShape is essentially a Rectangle. */
+ protected boolean isRandomShapeRectangular() {
+ return false;
+ }
+
protected abstract S generateRandomShape(Point nearP);
+ /** shape has no area; return a point in it */
protected abstract Point randomPointInEmptyShape(S shape);
@SuppressWarnings("unchecked")
@Override
protected Point randomPointIn(Shape shape) {
- if (!shape.hasArea())
- return randomPointInEmptyShape((S) shape);
+ if (!shape.hasArea()) {
+ final Point pt = randomPointInEmptyShape((S) shape);
+ assert shape.relate(pt).intersects() : "faulty randomPointInEmptyShape";
+ return pt;
+ }
return super.randomPointIn(shape);
}
@@ -52,7 +61,7 @@ public abstract class RectIntersectionTe
int laps = 0;
final int MINLAPSPERCASE = scaledRandomIntBetween(20, 200);
while(i_C < MINLAPSPERCASE || i_I < MINLAPSPERCASE || i_W < MINLAPSPERCASE
- || i_D < MINLAPSPERCASE || i_bboxD < MINLAPSPERCASE) {
+ || (!isRandomShapeRectangular() && i_D < MINLAPSPERCASE) || i_bboxD < MINLAPSPERCASE) {
laps++;
TestLog.clear();
@@ -67,6 +76,11 @@ public abstract class RectIntersectionTe
TestLog.log("S-R Rel: {}, Shape {}, Rectangle {}", ic, s, r);
+ if (ic != DISJOINT) {
+ assertTrue("if not disjoint then the shape's bbox shouldn't be disjoint",
+ s.getBoundingBox().relate(r).intersects());
+ }
+
try {
int MAX_TRIES = scaledRandomIntBetween(10, 100);
switch (ic) {