mirror of https://github.com/apache/lucene.git
LUCENE-7327: fix rare test bug
This commit is contained in:
parent
e418bd0eb3
commit
a923d945b4
|
@ -45,8 +45,8 @@ class Geo3DUtil {
|
|||
private static final int BITS = 32;
|
||||
private static final double MUL = (0x1L<<BITS)/(2*MAX_VALUE);
|
||||
static final double DECODE = getNextSafeDouble(1/MUL);
|
||||
private static final int MIN_ENCODED_VALUE = encodeValue(-MAX_VALUE);
|
||||
private static final int MAX_ENCODED_VALUE = encodeValue(MAX_VALUE);
|
||||
static final int MIN_ENCODED_VALUE = encodeValue(-MAX_VALUE);
|
||||
static final int MAX_ENCODED_VALUE = encodeValue(MAX_VALUE);
|
||||
|
||||
public static int encodeValue(double x) {
|
||||
if (x > MAX_VALUE) {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue