You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2011/08/01 15:56:14 UTC
svn commit: r1152775 - in /lucene/dev/branches/branch_3x/lucene/src:
test-framework/org/apache/lucene/util/_TestUtil.java
test/org/apache/lucene/index/TestPayloads.java
Author: mikemccand
Date: Mon Aug 1 13:56:13 2011
New Revision: 1152775
URL: http://svn.apache.org/viewvc?rev=1152775&view=rev
Log:
don't use U+FFFF for 3.x tests; fix silly minor unrelated bug in _TestUtil.randomFixedLengthUnicodeString
Modified:
lucene/dev/branches/branch_3x/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java
lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestPayloads.java
Modified: lucene/dev/branches/branch_3x/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java?rev=1152775&r1=1152774&r2=1152775&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test-framework/org/apache/lucene/util/_TestUtil.java Mon Aug 1 13:56:13 2011
@@ -240,7 +240,7 @@ public class _TestUtil {
} else if (t <= 1) {
chars[i++] = (char) random.nextInt(0x80);
} else if (2 == t) {
- chars[i++] = (char) nextInt(random, 0x80, 0x800);
+ chars[i++] = (char) nextInt(random, 0x80, 0x7ff);
} else if (3 == t) {
chars[i++] = (char) nextInt(random, 0x800, 0xd7ff);
} else if (4 == t) {
@@ -348,7 +348,7 @@ public class _TestUtil {
buffer[i] = (char) nextInt(r, 0x800, 0xd7ff);
bytes -= 3;
} else if (3 == t) {
- buffer[i] = (char) nextInt(r, 0xe000, 0xffff);
+ buffer[i] = (char) nextInt(r, 0xe000, 0xfffe);
bytes -= 3;
} else if (4 == t) {
// Make a surrogate pair
Modified: lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestPayloads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestPayloads.java?rev=1152775&r1=1152774&r2=1152775&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestPayloads.java (original)
+++ lucene/dev/branches/branch_3x/lucene/src/test/org/apache/lucene/index/TestPayloads.java Mon Aug 1 13:56:13 2011
@@ -21,7 +21,6 @@ import java.io.File;
import java.io.IOException;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -40,7 +39,6 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.UnicodeUtil;
import org.apache.lucene.util._TestUtil;
@@ -342,10 +340,16 @@ public class TestPayloads extends Lucene
}
private void generateRandomData(byte[] data) {
- // this test needs the random data to be valid unicode: historically it hasn't done a great job
- for (int i = 0; i < data.length; i++) {
- data[i] = (byte) _TestUtil.nextInt(random, 'a', 'z');
+ // this test needs the random data to be valid unicode
+ String s = _TestUtil.randomFixedByteLengthUnicodeString(random, data.length);
+ byte b[];
+ try {
+ b = s.getBytes("UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
}
+ assert b.length == data.length;
+ System.arraycopy(b, 0, data, 0, b.length);
}
private byte[] generateRandomData(int n) {