aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2013-07-04 19:49:48 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2013-07-04 19:49:48 -0700
commit7511b2eb1ef77d69dc5371e62bd1e652ebb4bd2b (patch)
treec3877b3abb6367cc85c6af6a6d4f3657e0c73dfd
parentcbc1fd044bdf7bca1cf19d5f7bc93f2402d71a2e (diff)
parent9aa1efdf46ce333425466e91061793301307ad01 (diff)
downloadlatinime-7511b2eb1ef77d69dc5371e62bd1e652ebb4bd2b.tar.gz
latinime-7511b2eb1ef77d69dc5371e62bd1e652ebb4bd2b.tar.xz
latinime-7511b2eb1ef77d69dc5371e62bd1e652ebb4bd2b.zip
am 9aa1efdf: Merge "Change how the length of the random words are chosen."
* commit '9aa1efdf46ce333425466e91061793301307ad01': Change how the length of the random words are chosen.
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java17
1 files changed, 13 insertions, 4 deletions
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java
index d667db298..55f163255 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java
@@ -151,11 +151,20 @@ public class BinaryDictIOTests extends AndroidTestCase {
* Generates a random word.
*/
private String generateWord(final Random random, final int[] codePointSet) {
- StringBuilder builder = new StringBuilder("a");
- int count = random.nextInt() % 30; // Arbitrarily 30 chars max
- while (count > 0) {
+ StringBuilder builder = new StringBuilder();
+ // 8 * 4 = 32 chars max, but we do it the following way so as to bias the random toward
+ // longer words. This should be closer to natural language, and more importantly, it will
+ // exercise the algorithms in dicttool much more.
+ final int count = 1 + (Math.abs(random.nextInt()) % 5)
+ + (Math.abs(random.nextInt()) % 5)
+ + (Math.abs(random.nextInt()) % 5)
+ + (Math.abs(random.nextInt()) % 5)
+ + (Math.abs(random.nextInt()) % 5)
+ + (Math.abs(random.nextInt()) % 5)
+ + (Math.abs(random.nextInt()) % 5)
+ + (Math.abs(random.nextInt()) % 5);
+ while (builder.length() < count) {
builder.appendCodePoint(codePointSet[Math.abs(random.nextInt()) % codePointSet.length]);
- --count;
}
return builder.toString();
}