lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1349601 - /lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
Date Wed, 13 Jun 2012 01:02:05 GMT
Author: rmuir
Date: Wed Jun 13 01:02:05 2012
New Revision: 1349601

URL: http://svn.apache.org/viewvc?rev=1349601&view=rev
Log:
test for correct shift operator

Modified:
    lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java

Modified: lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java?rev=1349601&r1=1349600&r2=1349601&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
(original)
+++ lucene/dev/trunk/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
Wed Jun 13 01:02:05 2012
@@ -28,6 +28,7 @@ import org.apache.lucene.analysis.Canned
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.analysis.MockPayloadAnalyzer;
 import org.apache.lucene.analysis.Token;
+import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
@@ -436,6 +437,31 @@ public class TestPostingsOffsets extends
       // expected
     }
   }
+  
+  public void testLegalbutVeryLargeOffsets() throws Exception {
+    Directory dir = newDirectory();
+    IndexWriter iw = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
+    Document doc = new Document();
+    Token t1 = new Token("foo", 0, Integer.MAX_VALUE-500);
+    if (random().nextBoolean()) {
+      t1.setPayload(new BytesRef("test"));
+    }
+    Token t2 = new Token("foo", Integer.MAX_VALUE-500, Integer.MAX_VALUE);
+    TokenStream tokenStream = new CannedTokenStream(
+        new Token[] { t1, t2 }
+    );
+    FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
+    ft.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS);
+    // store some term vectors for the checkindex cross-check
+    ft.setStoreTermVectors(true);
+    ft.setStoreTermVectorPositions(true);
+    ft.setStoreTermVectorOffsets(true);
+    Field field = new Field("foo", tokenStream, ft);
+    doc.add(field);
+    iw.addDocument(doc);
+    iw.close();
+    dir.close();
+  }
   // TODO: more tests with other possibilities
   
   private void checkTokens(Token[] tokens) throws IOException {



Mime
View raw message