mirror of https://github.com/apache/lucene.git
LUCENE-3205: Re-add missing extra test for empty enums, also fix distance, as only negative numbers were tested (because of reduced test document count)
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1201375 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
19b9b3c96f
commit
82c51029f8
|
@ -39,7 +39,7 @@ import org.junit.Test;
|
|||
|
||||
public class TestNumericRangeQuery32 extends LuceneTestCase {
|
||||
// distance of entries
|
||||
private static final int distance = 6666;
|
||||
private static int distance;
|
||||
// shift the starting of the values to the left, to also have negative values:
|
||||
private static final int startOffset = - 1 << 15;
|
||||
// number of docs to generate for testing
|
||||
|
@ -52,6 +52,7 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
|
|||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
noDocs = atLeast(4096);
|
||||
distance = (1 << 30) / noDocs;
|
||||
directory = newDirectory();
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random, directory,
|
||||
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random))
|
||||
|
@ -377,6 +378,21 @@ public class TestNumericRangeQuery32 extends LuceneTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyEnums() throws Exception {
|
||||
int count=3000;
|
||||
int lower=(distance*3/2)+startOffset, upper=lower + count*distance + (distance/3);
|
||||
// test empty enum
|
||||
assert lower < upper;
|
||||
assertTrue(0 < countTerms(NumericRangeQuery.newIntRange("field4", 4, lower, upper, true, true)));
|
||||
assertEquals(0, countTerms(NumericRangeQuery.newIntRange("field4", 4, upper, lower, true, true)));
|
||||
// test empty enum outside of bounds
|
||||
lower = distance*noDocs+startOffset;
|
||||
upper = 2 * lower;
|
||||
assert lower < upper;
|
||||
assertEquals(0, countTerms(NumericRangeQuery.newIntRange("field4", 4, lower, upper, true, true)));
|
||||
}
|
||||
|
||||
private int countTerms(MultiTermQuery q) throws Exception {
|
||||
final Terms terms = MultiFields.getTerms(reader, q.getField());
|
||||
if (terms == null)
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.junit.Test;
|
|||
|
||||
public class TestNumericRangeQuery64 extends LuceneTestCase {
|
||||
// distance of entries
|
||||
private static final long distance = 66666L;
|
||||
private static long distance;
|
||||
// shift the starting of the values to the left, to also have negative values:
|
||||
private static final long startOffset = - 1L << 31;
|
||||
// number of docs to generate for testing
|
||||
|
@ -52,6 +52,7 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
|
|||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
noDocs = atLeast(4096);
|
||||
distance = (1L << 60) / noDocs;
|
||||
directory = newDirectory();
|
||||
RandomIndexWriter writer = new RandomIndexWriter(random, directory,
|
||||
newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random))
|
||||
|
@ -397,6 +398,21 @@ public class TestNumericRangeQuery64 extends LuceneTestCase {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEmptyEnums() throws Exception {
|
||||
int count=3000;
|
||||
long lower=(distance*3/2)+startOffset, upper=lower + count*distance + (distance/3);
|
||||
// test empty enum
|
||||
assert lower < upper;
|
||||
assertTrue(0 < countTerms(NumericRangeQuery.newLongRange("field4", 4, lower, upper, true, true)));
|
||||
assertEquals(0, countTerms(NumericRangeQuery.newLongRange("field4", 4, upper, lower, true, true)));
|
||||
// test empty enum outside of bounds
|
||||
lower = distance*noDocs+startOffset;
|
||||
upper = 2L * lower;
|
||||
assert lower < upper;
|
||||
assertEquals(0, countTerms(NumericRangeQuery.newLongRange("field4", 4, lower, upper, true, true)));
|
||||
}
|
||||
|
||||
private int countTerms(MultiTermQuery q) throws Exception {
|
||||
final Terms terms = MultiFields.getTerms(reader, q.getField());
|
||||
if (terms == null)
|
||||
|
|
Loading…
Reference in New Issue