From 604fb28b586cdb7248fff29f8a181dd1c7b54483 Mon Sep 17 00:00:00 2001 From: Mike McCandless Date: Mon, 11 Apr 2016 05:24:34 -0400 Subject: [PATCH] fix rare test bug --- .../lucene/facet/range/TestRangeFacetCounts.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java b/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java index 626d772d6a9..18645e75fbb 100644 --- a/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java +++ b/lucene/facet/src/test/org/apache/lucene/facet/range/TestRangeFacetCounts.java @@ -22,14 +22,14 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.atomic.AtomicBoolean; -import org.apache.lucene.document.DoublePoint; -import org.apache.lucene.document.LongPoint; import org.apache.lucene.document.Document; import org.apache.lucene.document.DoubleDocValuesField; +import org.apache.lucene.document.DoublePoint; +import org.apache.lucene.document.LongPoint; import org.apache.lucene.document.NumericDocValuesField; import org.apache.lucene.facet.DrillDownQuery; -import org.apache.lucene.facet.DrillSideways; import org.apache.lucene.facet.DrillSideways.DrillSidewaysResult; +import org.apache.lucene.facet.DrillSideways; import org.apache.lucene.facet.FacetField; import org.apache.lucene.facet.FacetResult; import org.apache.lucene.facet.FacetTestCase; @@ -59,6 +59,7 @@ import org.apache.lucene.search.Scorer; import org.apache.lucene.search.Weight; import org.apache.lucene.store.Directory; import org.apache.lucene.util.IOUtils; +import org.apache.lucene.util.NumericUtils; import org.apache.lucene.util.TestUtil; public class TestRangeFacetCounts extends FacetTestCase { @@ -532,7 +533,11 @@ public class TestRangeFacetCounts extends FacetTestCase { boolean minIncl; boolean maxIncl; - if (min == max) { + + long minAsLong = NumericUtils.doubleToSortableLong(min); + long maxAsLong = NumericUtils.doubleToSortableLong(max); + // NOTE: maxAsLong - minAsLong >= 0 is here to handle the common overflow case! + if (maxAsLong - minAsLong >= 0 && maxAsLong - minAsLong < 2) { minIncl = true; maxIncl = true; } else {