aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/latin/StringUtilsTests.java67
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java14
2 files changed, 48 insertions, 33 deletions
diff --git a/tests/src/com/android/inputmethod/latin/StringUtilsTests.java b/tests/src/com/android/inputmethod/latin/StringUtilsTests.java
index 00cca9d3b..be3494dc7 100644
--- a/tests/src/com/android/inputmethod/latin/StringUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/StringUtilsTests.java
@@ -93,22 +93,24 @@ public class StringUtilsTests extends AndroidTestCase {
}
private void onePathForCaps(final CharSequence cs, final int expectedResult, final int mask,
- final Locale l) {
+ final Locale l, final boolean hasSpaceBefore) {
int oneTimeResult = expectedResult & mask;
- assertEquals("After >" + cs + "<", oneTimeResult, StringUtils.getCapsMode(cs, mask, l));
+ assertEquals("After >" + cs + "<", oneTimeResult,
+ StringUtils.getCapsMode(cs, mask, l, hasSpaceBefore));
}
- private void allPathsForCaps(final CharSequence cs, final int expectedResult, final Locale l) {
+ private void allPathsForCaps(final CharSequence cs, final int expectedResult, final Locale l,
+ final boolean hasSpaceBefore) {
final int c = TextUtils.CAP_MODE_CHARACTERS;
final int w = TextUtils.CAP_MODE_WORDS;
final int s = TextUtils.CAP_MODE_SENTENCES;
- onePathForCaps(cs, expectedResult, c | w | s, l);
- onePathForCaps(cs, expectedResult, w | s, l);
- onePathForCaps(cs, expectedResult, c | s, l);
- onePathForCaps(cs, expectedResult, c | w, l);
- onePathForCaps(cs, expectedResult, c, l);
- onePathForCaps(cs, expectedResult, w, l);
- onePathForCaps(cs, expectedResult, s, l);
+ onePathForCaps(cs, expectedResult, c | w | s, l, hasSpaceBefore);
+ onePathForCaps(cs, expectedResult, w | s, l, hasSpaceBefore);
+ onePathForCaps(cs, expectedResult, c | s, l, hasSpaceBefore);
+ onePathForCaps(cs, expectedResult, c | w, l, hasSpaceBefore);
+ onePathForCaps(cs, expectedResult, c, l, hasSpaceBefore);
+ onePathForCaps(cs, expectedResult, w, l, hasSpaceBefore);
+ onePathForCaps(cs, expectedResult, s, l, hasSpaceBefore);
}
public void testGetCapsMode() {
@@ -116,26 +118,31 @@ public class StringUtilsTests extends AndroidTestCase {
final int w = TextUtils.CAP_MODE_WORDS;
final int s = TextUtils.CAP_MODE_SENTENCES;
Locale l = Locale.ENGLISH;
- allPathsForCaps("", c | w | s, l);
- allPathsForCaps("Word", c, l);
- allPathsForCaps("Word.", c, l);
- allPathsForCaps("Word ", c | w, l);
- allPathsForCaps("Word. ", c | w | s, l);
- allPathsForCaps("Word..", c, l);
- allPathsForCaps("Word.. ", c | w | s, l);
- allPathsForCaps("Word... ", c | w | s, l);
- allPathsForCaps("Word ... ", c | w | s, l);
- allPathsForCaps("Word . ", c | w, l);
- allPathsForCaps("In the U.S ", c | w, l);
- allPathsForCaps("In the U.S. ", c | w, l);
- allPathsForCaps("Some stuff (e.g. ", c | w, l);
- allPathsForCaps("In the U.S.. ", c | w | s, l);
- allPathsForCaps("\"Word.\" ", c | w | s, l);
- allPathsForCaps("\"Word\". ", c | w | s, l);
- allPathsForCaps("\"Word\" ", c | w, l);
+ allPathsForCaps("", c | w | s, l, false);
+ allPathsForCaps("Word", c, l, false);
+ allPathsForCaps("Word.", c, l, false);
+ allPathsForCaps("Word ", c | w, l, false);
+ allPathsForCaps("Word. ", c | w | s, l, false);
+ allPathsForCaps("Word..", c, l, false);
+ allPathsForCaps("Word.. ", c | w | s, l, false);
+ allPathsForCaps("Word... ", c | w | s, l, false);
+ allPathsForCaps("Word ... ", c | w | s, l, false);
+ allPathsForCaps("Word . ", c | w, l, false);
+ allPathsForCaps("In the U.S ", c | w, l, false);
+ allPathsForCaps("In the U.S. ", c | w, l, false);
+ allPathsForCaps("Some stuff (e.g. ", c | w, l, false);
+ allPathsForCaps("In the U.S.. ", c | w | s, l, false);
+ allPathsForCaps("\"Word.\" ", c | w | s, l, false);
+ allPathsForCaps("\"Word\". ", c | w | s, l, false);
+ allPathsForCaps("\"Word\" ", c | w, l, false);
+
+ // Test for phantom space
+ allPathsForCaps("Word", c | w, l, true);
+ allPathsForCaps("Word.", c | w | s, l, true);
+
l = Locale.FRENCH;
- allPathsForCaps("\"Word.\" ", c | w, l);
- allPathsForCaps("\"Word\". ", c | w | s, l);
- allPathsForCaps("\"Word\" ", c | w, l);
+ allPathsForCaps("\"Word.\" ", c | w, l, false);
+ allPathsForCaps("\"Word\". ", c | w | s, l, false);
+ allPathsForCaps("\"Word\" ", c | w, l, false);
}
}
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java
index 328784b1a..a87146ee2 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOTests.java
@@ -65,9 +65,12 @@ public class BinaryDictIOTests extends AndroidTestCase {
private static final FormatSpec.FormatOptions VERSION2 = new FormatSpec.FormatOptions(2);
private static final FormatSpec.FormatOptions VERSION3_WITHOUT_PARENTADDRESS =
- new FormatSpec.FormatOptions(3, false);
+ new FormatSpec.FormatOptions(3, false /* hasParentAddress */);
private static final FormatSpec.FormatOptions VERSION3_WITH_PARENTADDRESS =
- new FormatSpec.FormatOptions(3, true);
+ new FormatSpec.FormatOptions(3, true /* hasParentAddress */);
+ private static final FormatSpec.FormatOptions VERSION3_WITH_LINKEDLIST_NODE =
+ new FormatSpec.FormatOptions(3, true /* hasParentAddress */,
+ true /* hasLinkedListNode */);
private static final String[] CHARACTERS = {
"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m",
@@ -236,7 +239,8 @@ public class BinaryDictIOTests extends AndroidTestCase {
String result = " : buffer type = "
+ ((bufferType == USE_BYTE_BUFFER) ? "byte buffer" : "byte array");
result += " : version = " + formatOptions.mVersion;
- return result + ", hasParentAddress = " + formatOptions.mHasParentAddress;
+ return result + ", hasParentAddress = " + formatOptions.mHasParentAddress
+ + ", hasLinkedListNode = " + formatOptions.mHasLinkedListNode;
}
// Tests for readDictionaryBinary and writeDictionaryBinary
@@ -305,6 +309,7 @@ public class BinaryDictIOTests extends AndroidTestCase {
runReadAndWriteTests(results, USE_BYTE_BUFFER, VERSION2);
runReadAndWriteTests(results, USE_BYTE_BUFFER, VERSION3_WITHOUT_PARENTADDRESS);
runReadAndWriteTests(results, USE_BYTE_BUFFER, VERSION3_WITH_PARENTADDRESS);
+ runReadAndWriteTests(results, USE_BYTE_BUFFER, VERSION3_WITH_LINKEDLIST_NODE);
for (final String result : results) {
Log.d(TAG, result);
@@ -317,6 +322,7 @@ public class BinaryDictIOTests extends AndroidTestCase {
runReadAndWriteTests(results, USE_BYTE_ARRAY, VERSION2);
runReadAndWriteTests(results, USE_BYTE_ARRAY, VERSION3_WITHOUT_PARENTADDRESS);
runReadAndWriteTests(results, USE_BYTE_ARRAY, VERSION3_WITH_PARENTADDRESS);
+ runReadAndWriteTests(results, USE_BYTE_ARRAY, VERSION3_WITH_LINKEDLIST_NODE);
for (final String result : results) {
Log.d(TAG, result);
@@ -450,6 +456,7 @@ public class BinaryDictIOTests extends AndroidTestCase {
runReadUnigramsAndBigramsTests(results, USE_BYTE_BUFFER, VERSION2);
runReadUnigramsAndBigramsTests(results, USE_BYTE_BUFFER, VERSION3_WITHOUT_PARENTADDRESS);
runReadUnigramsAndBigramsTests(results, USE_BYTE_BUFFER, VERSION3_WITH_PARENTADDRESS);
+ runReadUnigramsAndBigramsTests(results, USE_BYTE_BUFFER, VERSION3_WITH_LINKEDLIST_NODE);
for (final String result : results) {
Log.d(TAG, result);
@@ -462,6 +469,7 @@ public class BinaryDictIOTests extends AndroidTestCase {
runReadUnigramsAndBigramsTests(results, USE_BYTE_ARRAY, VERSION2);
runReadUnigramsAndBigramsTests(results, USE_BYTE_ARRAY, VERSION3_WITHOUT_PARENTADDRESS);
runReadUnigramsAndBigramsTests(results, USE_BYTE_ARRAY, VERSION3_WITH_PARENTADDRESS);
+ runReadUnigramsAndBigramsTests(results, USE_BYTE_ARRAY, VERSION3_WITH_LINKEDLIST_NODE);
for (final String result : results) {
Log.d(TAG, result);