mirror of https://github.com/apache/lucene.git
fix RangeField tests so they use actual ranges, not just 0 ranges
This commit is contained in:
parent
70fd627ca7
commit
ea31811e42
|
@ -43,11 +43,13 @@ public class TestDoubleRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
double[] min = new double[dimensions];
|
||||
double[] max = new double[dimensions];
|
||||
|
||||
double minV, maxV;
|
||||
for (int d=0; d<dimensions; ++d) {
|
||||
min[d] = nextDoubleInternal();
|
||||
max[d] = nextDoubleInternal();
|
||||
minV = nextDoubleInternal();
|
||||
maxV = nextDoubleInternal();
|
||||
min[d] = Math.min(minV, maxV);
|
||||
max[d] = Math.max(minV, maxV);
|
||||
}
|
||||
|
||||
return new DoubleRange(min, max);
|
||||
}
|
||||
|
||||
|
@ -140,16 +142,8 @@ public class TestDoubleRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
assert min != null && max != null && min.length > 0 && max.length > 0
|
||||
: "test box: min/max cannot be null or empty";
|
||||
assert min.length == max.length : "test box: min/max length do not agree";
|
||||
this.min = new double[min.length];
|
||||
this.max = new double[max.length];
|
||||
for (int d=0; d<min.length; ++d) {
|
||||
if (min[d] > max[d]) {
|
||||
// swap if max < min:
|
||||
double temp = min[d];
|
||||
min[d] = max[d];
|
||||
max[d] = temp;
|
||||
}
|
||||
}
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -164,7 +158,12 @@ public class TestDoubleRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
|
||||
@Override
|
||||
protected void setMin(int dim, Object val) {
|
||||
min[dim] = (Double)val;
|
||||
double v = (Double)val;
|
||||
if (min[dim] < v) {
|
||||
max[dim] = v;
|
||||
} else {
|
||||
min[dim] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -174,7 +173,12 @@ public class TestDoubleRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
|
||||
@Override
|
||||
protected void setMax(int dim, Object val) {
|
||||
max[dim] = (Double)val;
|
||||
double v = (Double)val;
|
||||
if (max[dim] > v) {
|
||||
min[dim] = v;
|
||||
} else {
|
||||
max[dim] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,11 +43,13 @@ public class TestFloatRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
float[] min = new float[dimensions];
|
||||
float[] max = new float[dimensions];
|
||||
|
||||
float minV, maxV;
|
||||
for (int d=0; d<dimensions; ++d) {
|
||||
min[d] = nextFloatInternal();
|
||||
max[d] = nextFloatInternal();
|
||||
minV = nextFloatInternal();
|
||||
maxV = nextFloatInternal();
|
||||
min[d] = Math.min(minV, maxV);
|
||||
max[d] = Math.max(minV, maxV);
|
||||
}
|
||||
|
||||
return new FloatRange(min, max);
|
||||
}
|
||||
|
||||
|
@ -140,16 +142,8 @@ public class TestFloatRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
assert min != null && max != null && min.length > 0 && max.length > 0
|
||||
: "test box: min/max cannot be null or empty";
|
||||
assert min.length == max.length : "test box: min/max length do not agree";
|
||||
this.min = new float[min.length];
|
||||
this.max = new float[max.length];
|
||||
for (int d=0; d<min.length; ++d) {
|
||||
if (min[d] > max[d]) {
|
||||
// swap if max < min:
|
||||
float temp = min[d];
|
||||
min[d] = max[d];
|
||||
max[d] = temp;
|
||||
}
|
||||
}
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -164,7 +158,12 @@ public class TestFloatRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
|
||||
@Override
|
||||
protected void setMin(int dim, Object val) {
|
||||
min[dim] = (Float)val;
|
||||
float v = (Float)val;
|
||||
if (min[dim] < v) {
|
||||
max[dim] = v;
|
||||
} else {
|
||||
min[dim] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -174,7 +173,12 @@ public class TestFloatRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
|
||||
@Override
|
||||
protected void setMax(int dim, Object val) {
|
||||
max[dim] = (Float)val;
|
||||
float v = (Float)val;
|
||||
if (max[dim] > v) {
|
||||
min[dim] = v;
|
||||
} else {
|
||||
max[dim] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,11 +43,13 @@ public class TestIntRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
int[] min = new int[dimensions];
|
||||
int[] max = new int[dimensions];
|
||||
|
||||
int minV, maxV;
|
||||
for (int d=0; d<dimensions; ++d) {
|
||||
min[d] = nextIntInternal();
|
||||
max[d] = nextIntInternal();
|
||||
minV = nextIntInternal();
|
||||
maxV = nextIntInternal();
|
||||
min[d] = Math.min(minV, maxV);
|
||||
max[d] = Math.max(minV, maxV);
|
||||
}
|
||||
|
||||
return new IntRange(min, max);
|
||||
}
|
||||
|
||||
|
@ -140,16 +142,8 @@ public class TestIntRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
assert min != null && max != null && min.length > 0 && max.length > 0
|
||||
: "test box: min/max cannot be null or empty";
|
||||
assert min.length == max.length : "test box: min/max length do not agree";
|
||||
this.min = new int[min.length];
|
||||
this.max = new int[max.length];
|
||||
for (int d=0; d<min.length; ++d) {
|
||||
if (min[d] > max[d]) {
|
||||
// swap if max < min:
|
||||
int temp = min[d];
|
||||
min[d] = max[d];
|
||||
max[d] = temp;
|
||||
}
|
||||
}
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -164,7 +158,12 @@ public class TestIntRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
|
||||
@Override
|
||||
protected void setMin(int dim, Object val) {
|
||||
min[dim] = (Integer)val;
|
||||
int v = (Integer)val;
|
||||
if (min[dim] < v) {
|
||||
max[dim] = v;
|
||||
} else {
|
||||
min[dim] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -174,7 +173,12 @@ public class TestIntRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
|
||||
@Override
|
||||
protected void setMax(int dim, Object val) {
|
||||
max[dim] = (Integer)val;
|
||||
int v = (Integer)val;
|
||||
if (max[dim] > v) {
|
||||
min[dim] = v;
|
||||
} else {
|
||||
max[dim] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,11 +43,13 @@ public class TestLongRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
long[] min = new long[dimensions];
|
||||
long[] max = new long[dimensions];
|
||||
|
||||
long minV, maxV;
|
||||
for (int d=0; d<dimensions; ++d) {
|
||||
min[d] = nextLongInternal();
|
||||
max[d] = nextLongInternal();
|
||||
minV = nextLongInternal();
|
||||
maxV = nextLongInternal();
|
||||
min[d] = Math.min(minV, maxV);
|
||||
max[d] = Math.max(minV, maxV);
|
||||
}
|
||||
|
||||
return new LongRange(min, max);
|
||||
}
|
||||
|
||||
|
@ -140,16 +142,8 @@ public class TestLongRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
assert min != null && max != null && min.length > 0 && max.length > 0
|
||||
: "test box: min/max cannot be null or empty";
|
||||
assert min.length == max.length : "test box: min/max length do not agree";
|
||||
this.min = new long[min.length];
|
||||
this.max = new long[max.length];
|
||||
for (int d=0; d<min.length; ++d) {
|
||||
if (min[d] > max[d]) {
|
||||
// swap if max < min:
|
||||
long temp = min[d];
|
||||
min[d] = max[d];
|
||||
max[d] = temp;
|
||||
}
|
||||
}
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -164,7 +158,12 @@ public class TestLongRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
|
||||
@Override
|
||||
protected void setMin(int dim, Object val) {
|
||||
min[dim] = (Long)val;
|
||||
long v = (Long)val;
|
||||
if (min[dim] < v) {
|
||||
max[dim] = v;
|
||||
} else {
|
||||
min[dim] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -174,7 +173,12 @@ public class TestLongRangeFieldQueries extends BaseRangeFieldQueryTestCase {
|
|||
|
||||
@Override
|
||||
protected void setMax(int dim, Object val) {
|
||||
max[dim] = (Long)val;
|
||||
long v = (Long)val;
|
||||
if (max[dim] > v) {
|
||||
min[dim] = v;
|
||||
} else {
|
||||
max[dim] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue