Clean up tests and increase speed

Conservatively reduce the number of unigrams to test from 1000
to 100.

Bug: 8583091
Change-Id: I48621ec44ff5f0590640d7c6b174ab5a6d267aaf
main
Jean Chalard 2013-04-15 14:22:43 +09:00
parent c2653d0b5c
commit 001884a1ee
1 changed files with 6 additions and 5 deletions

View File

@ -51,7 +51,7 @@ import java.util.Set;
@LargeTest @LargeTest
public class BinaryDictIOTests extends AndroidTestCase { public class BinaryDictIOTests extends AndroidTestCase {
private static final String TAG = BinaryDictIOTests.class.getSimpleName(); private static final String TAG = BinaryDictIOTests.class.getSimpleName();
private static final int MAX_UNIGRAMS = 1000; private static final int MAX_UNIGRAMS = 100;
private static final int UNIGRAM_FREQ = 10; private static final int UNIGRAM_FREQ = 10;
private static final int BIGRAM_FREQ = 50; private static final int BIGRAM_FREQ = 50;
private static final int TOLERANCE_OF_BIGRAM_FREQ = 5; private static final int TOLERANCE_OF_BIGRAM_FREQ = 5;
@ -135,11 +135,12 @@ public class BinaryDictIOTests extends AndroidTestCase {
while (count > 0) { while (count > 0) {
final long r = Math.abs(random.nextInt()); final long r = Math.abs(random.nextInt());
if (r < 0) continue; if (r < 0) continue;
// Don't insert 0~20, but insert any other code point. // Don't insert 0~0x20, but insert any other code point.
// Code points are in the range 0~0x10FFFF. // Code points are in the range 0~0x10FFFF.
final int candidateCodePoint = (int)(20 + r % (0x10FFFF - 20)); final int candidateCodePoint = (int)(0x20 + r % (Character.MAX_CODE_POINT - 0x20));
// Code points between 0xD800 and 0xDFFF are not valid. // Code points between MIN_ and MAX_SURROGATE are not valid on their own.
if (candidateCodePoint >= 0xD800 && candidateCodePoint <= 0xDFFF) continue; if (candidateCodePoint >= Character.MIN_SURROGATE
&& candidateCodePoint <= Character.MAX_SURROGATE) continue;
builder.appendCodePoint(candidateCodePoint); builder.appendCodePoint(candidateCodePoint);
--count; --count;
} }