lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1201375 - in /lucene/dev/trunk/lucene/src/test/org/apache/lucene/search: TestNumericRangeQuery32.java TestNumericRangeQuery64.java
Date Sun, 13 Nov 2011 00:28:49 GMT
Author: uschindler
Date: Sun Nov 13 00:28:49 2011
New Revision: 1201375

URL: http://svn.apache.org/viewvc?rev=1201375&view=rev
Log:
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)

Modified:
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
    lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=1201375&r1=1201374&r2=1201375&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
(original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
Sun Nov 13 00:28:49 2011
@@ -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 ext
   @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 ext
     }
   }
   
+  @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)

Modified: lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java?rev=1201375&r1=1201374&r2=1201375&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
(original)
+++ lucene/dev/trunk/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
Sun Nov 13 00:28:49 2011
@@ -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 ext
   @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 ext
     }
   }
   
+  @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)



Mime
View raw message