lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r941780 - /lucene/dev/trunk/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
Date Thu, 06 May 2010 15:39:36 GMT
Author: rmuir
Date: Thu May  6 15:39:35 2010
New Revision: 941780

URL: http://svn.apache.org/viewvc?rev=941780&view=rev
Log:
use the new _TestUtil.randomUnicodeString here

Modified:
    lucene/dev/trunk/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java

Modified: lucene/dev/trunk/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java?rev=941780&r1=941779&r2=941780&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
(original)
+++ lucene/dev/trunk/lucene/contrib/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
Thu May  6 15:39:35 2010
@@ -38,6 +38,7 @@ import org.apache.lucene.queryParser.Que
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.RAMDirectory;
+import org.apache.lucene.util._TestUtil;
 
 /**
  * Verifies that Lucene MemoryIndex and RAMDirectory have the same behaviour,
@@ -166,44 +167,7 @@ public class MemoryIndexTest extends Bas
       return TEST_TERMS[random.nextInt(TEST_TERMS.length)];
     } else {
       // return a random unicode term
-      return randomString();
+      return _TestUtil.randomUnicodeString(random);
     }
   }
-  
-  /**
-   * Return a random unicode term, like TestStressIndexing.
-   */
-  private String randomString() {
-    final int end = random.nextInt(20);
-    if (buffer.length < 1 + end) {
-      char[] newBuffer = new char[(int) ((1 + end) * 1.25)];
-      System.arraycopy(buffer, 0, newBuffer, 0, buffer.length);
-      buffer = newBuffer;
-    }
-    for (int i = 0; i < end - 1; i++) {
-      int t = random.nextInt(6);
-      if (0 == t && i < end - 1) {
-        // Make a surrogate pair
-        // High surrogate
-        buffer[i++] = (char) nextInt(0xd800, 0xdc00);
-        // Low surrogate
-        buffer[i] = (char) nextInt(0xdc00, 0xe000);
-      } else if (t <= 1) buffer[i] = (char) random.nextInt(0x80);
-      else if (2 == t) buffer[i] = (char) nextInt(0x80, 0x800);
-      else if (3 == t) buffer[i] = (char) nextInt(0x800, 0xd800);
-      else if (4 == t) buffer[i] = (char) nextInt(0xe000, 0xffff);
-      else if (5 == t) {
-        // Illegal unpaired surrogate
-        if (random.nextBoolean()) buffer[i] = (char) nextInt(0xd800, 0xdc00);
-        else buffer[i] = (char) nextInt(0xdc00, 0xe000);
-      }
-    }
-    return new String(buffer, 0, end);
-  }
-  
-  private char buffer[] = new char[20];
-  // start is inclusive and end is exclusive
-  private int nextInt(int start, int end) {
-    return start + random.nextInt(end - start);
-  }
 }



Mime
View raw message