From a923d945b4f6b0874a2ab0a1e5ef538725aa3373 Mon Sep 17 00:00:00 2001 From: Mike McCandless Date: Fri, 10 Jun 2016 10:17:34 -0400 Subject: [PATCH] LUCENE-7327: fix rare test bug --- .../src/java/org/apache/lucene/spatial3d/Geo3DUtil.java | 4 ++-- .../test/org/apache/lucene/spatial3d/TestGeo3DPoint.java | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DUtil.java b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DUtil.java index b5ce2507d61..6d7321025f8 100644 --- a/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DUtil.java +++ b/lucene/spatial3d/src/java/org/apache/lucene/spatial3d/Geo3DUtil.java @@ -45,8 +45,8 @@ class Geo3DUtil { private static final int BITS = 32; private static final double MUL = (0x1L< MAX_VALUE) { diff --git a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java index 85ec54856e6..fed5ada275c 100644 --- a/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java +++ b/lucene/spatial3d/src/test/org/apache/lucene/spatial3d/TestGeo3DPoint.java @@ -1207,13 +1207,19 @@ public class TestGeo3DPoint extends LuceneTestCase { /** * step through some integers, ensuring they decode to their expected double values. - * double values start at -90 and increase by LATITUDE_DECODE for each integer. + * double values start at -planetMax and increase by Geo3DUtil.DECODE for each integer. * check edge cases within the double range and random doubles within the range too. */ public void testQuantization() throws Exception { Random random = random(); for (int i = 0; i < 10000; i++) { int encoded = random.nextInt(); + if (encoded < Geo3DUtil.MIN_ENCODED_VALUE) { + continue; + } + if (encoded > Geo3DUtil.MAX_ENCODED_VALUE) { + continue; + } double min = encoded * Geo3DUtil.DECODE; double decoded = Geo3DUtil.decodeValueFloor(encoded); // should exactly equal expected value