lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From uschind...@apache.org
Subject svn commit: r1201379 - in /lucene/dev/branches/branch_3x: ./ lucene/ lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
Date Sun, 13 Nov 2011 00:34:46 GMT
Author: uschindler
Date: Sun Nov 13 00:34:46 2011
New Revision: 1201379

URL: http://svn.apache.org/viewvc?rev=1201379&view=rev
Log:
Merged revision(s) 1201375 from lucene/dev/trunk:
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/branches/branch_3x/   (props changed)
    lucene/dev/branches/branch_3x/lucene/   (props changed)
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
    lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=1201379&r1=1201378&r2=1201379&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
Sun Nov 13 00:34:46 2011
@@ -37,7 +37,7 @@ import org.junit.BeforeClass;
 
 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
@@ -50,6 +50,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))
@@ -370,6 +371,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), "field4"));
+    assertEquals(0, countTerms(NumericRangeQuery.newIntRange("field4", 4, upper, lower, true,
true), "field4"));
+    // 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), "field4"));
+  }
+  
   private int countTerms(MultiTermQuery q, String field) throws Exception {
     FilteredTermEnum termEnum = q.getEnum(reader);
     try {

Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java?rev=1201379&r1=1201378&r2=1201379&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
Sun Nov 13 00:34:46 2011
@@ -37,7 +37,7 @@ import org.junit.BeforeClass;
 
 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
@@ -50,6 +50,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))
@@ -390,6 +391,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), "field4"));
+    assertEquals(0, countTerms(NumericRangeQuery.newLongRange("field4", 4, upper, lower,
true, true), "field4"));
+    // 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), "field4"));
+  }
+  
   private int countTerms(MultiTermQuery q, String field) throws Exception {
     FilteredTermEnum termEnum = q.getEnum(reader);
     try {



Mime
View raw message