You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jp...@apache.org on 2012/11/01 12:22:34 UTC

svn commit: r1404544 - /lucene/dev/branches/branch_4x/lucene/codecs/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java

Author: jpountz
Date: Thu Nov  1 11:22:34 2012
New Revision: 1404544

URL: http://svn.apache.org/viewvc?rev=1404544&view=rev
Log:
LZ4: improve test coverage (merged from r1404541).

Modified:
    lucene/dev/branches/branch_4x/lucene/codecs/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java

Modified: lucene/dev/branches/branch_4x/lucene/codecs/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/lucene/codecs/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java?rev=1404544&r1=1404543&r2=1404544&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/lucene/codecs/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java (original)
+++ lucene/dev/branches/branch_4x/lucene/codecs/src/test/org/apache/lucene/codecs/compressing/AbstractTestCompressionMode.java Thu Nov  1 11:22:34 2012
@@ -38,6 +38,10 @@ public abstract class AbstractTestCompre
     final int length = random().nextBoolean()
         ? random().nextInt(20)
         : random().nextInt(192 * 1024);
+    return randomArray(length, max);
+  }
+
+  static byte[] randomArray(int length, int max) {
     final byte[] arr = new byte[length];
     for (int i = 0; i < arr.length; ++i) {
       arr[i] = (byte) RandomInts.randomIntBetween(random(), 0, max);
@@ -147,8 +151,8 @@ public abstract class AbstractTestCompre
     test(decompressed);
   }
 
-  public void testLongLiteralsAndMatchs() throws IOException {
-    // literals and matchs length > 16
+  public void testLongMatchs() throws IOException {
+    // match length > 16
     final byte[] decompressed = new byte[RandomInts.randomIntBetween(random(), 300, 1024)];
     for (int i = 0; i < decompressed.length; ++i) {
       decompressed[i] = (byte) i;
@@ -156,4 +160,14 @@ public abstract class AbstractTestCompre
     test(decompressed);
   }
 
+  public void testLongLiterals() throws IOException {
+    // long literals (length > 16) which are not the last literals
+    final byte[] decompressed = randomArray(RandomInts.randomIntBetween(random(), 400, 1024), 256);
+    final int matchRef = random().nextInt(30);
+    final int matchOff = RandomInts.randomIntBetween(random(), decompressed.length - 40, decompressed.length - 20);
+    final int matchLength = RandomInts.randomIntBetween(random(), 4, 10);
+    System.arraycopy(decompressed, matchRef, decompressed, matchOff, matchLength);
+    test(decompressed);
+  }
+
 }
\ No newline at end of file