aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorYuichiro Hanada <yhanada@google.com>2013-08-23 23:23:03 +0900
committerYuichiro Hanada <yhanada@google.com>2013-08-26 16:14:59 +0900
commitbb5b84a82630bc2309c9ae866d43c7934768bb2e (patch)
tree6e1d699df1cfef116951745816b0353bcd02faab /tests/src
parent800225e0b19c8a368fe74f6b73b40a01340a0c0f (diff)
downloadlatinime-bb5b84a82630bc2309c9ae866d43c7934768bb2e.tar.gz
latinime-bb5b84a82630bc2309c9ae866d43c7934768bb2e.tar.xz
latinime-bb5b84a82630bc2309c9ae866d43c7934768bb2e.zip
[Refactor] Add DictDecoder.getTerminalPosition.
Change-Id: I9d04f64a58f5481cbb64cf1c09b5c485dd4176b4
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java19
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java5
2 files changed, 10 insertions, 14 deletions
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java
index 98f06a6c2..bb5b96a48 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java
@@ -555,7 +555,7 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
int position = -1;
try {
final long now = System.nanoTime();
- position = BinaryDictIOUtils.getTerminalPosition(dictDecoder, word);
+ position = dictDecoder.getTerminalPosition(word);
diff = System.nanoTime() - now;
} catch (IOException e) {
Log.e(TAG, "IOException while getTerminalPosition", e);
@@ -596,16 +596,13 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
try {
// too long word
final String longWord = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
- assertEquals(FormatSpec.NOT_VALID_WORD,
- BinaryDictIOUtils.getTerminalPosition(dictDecoder, longWord));
+ assertEquals(FormatSpec.NOT_VALID_WORD, dictDecoder.getTerminalPosition(longWord));
// null
- assertEquals(FormatSpec.NOT_VALID_WORD,
- BinaryDictIOUtils.getTerminalPosition(dictDecoder, null));
+ assertEquals(FormatSpec.NOT_VALID_WORD, dictDecoder.getTerminalPosition(null));
// empty string
- assertEquals(FormatSpec.NOT_VALID_WORD,
- BinaryDictIOUtils.getTerminalPosition(dictDecoder, ""));
+ assertEquals(FormatSpec.NOT_VALID_WORD, dictDecoder.getTerminalPosition(""));
} catch (IOException e) {
} catch (UnsupportedFormatException e) {
}
@@ -655,16 +652,16 @@ public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
try {
MoreAsserts.assertNotEqual(FormatSpec.NOT_VALID_WORD,
- BinaryDictIOUtils.getTerminalPosition(dictDecoder, sWords.get(0)));
+ dictDecoder.getTerminalPosition(sWords.get(0)));
DynamicBinaryDictIOUtils.deleteWord(dictDecoder, sWords.get(0));
assertEquals(FormatSpec.NOT_VALID_WORD,
- BinaryDictIOUtils.getTerminalPosition(dictDecoder, sWords.get(0)));
+ dictDecoder.getTerminalPosition(sWords.get(0)));
MoreAsserts.assertNotEqual(FormatSpec.NOT_VALID_WORD,
- BinaryDictIOUtils.getTerminalPosition(dictDecoder, sWords.get(5)));
+ dictDecoder.getTerminalPosition(sWords.get(5)));
DynamicBinaryDictIOUtils.deleteWord(dictDecoder, sWords.get(5));
assertEquals(FormatSpec.NOT_VALID_WORD,
- BinaryDictIOUtils.getTerminalPosition(dictDecoder, sWords.get(5)));
+ dictDecoder.getTerminalPosition(sWords.get(5)));
} catch (IOException e) {
} catch (UnsupportedFormatException e) {
}
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java
index be9323b81..7a6708bb3 100644
--- a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtilsTests.java
@@ -142,8 +142,7 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
try {
final Ver3DictDecoder dictDecoder = new Ver3DictDecoder(file);
- dictDecoder.openDictBuffer();
- position = BinaryDictIOUtils.getTerminalPosition(dictDecoder, word);
+ position = dictDecoder.getTerminalPosition(word);
} catch (IOException e) {
} catch (UnsupportedFormatException e) {
}
@@ -161,7 +160,7 @@ public class BinaryDictIOUtilsTests extends AndroidTestCase {
*/
private static PtNodeInfo findWordByBinaryDictReader(final Ver3DictDecoder dictDecoder,
final String word) throws IOException, UnsupportedFormatException {
- int position = BinaryDictIOUtils.getTerminalPosition(dictDecoder, word);
+ int position = dictDecoder.getTerminalPosition(word);
final DictBuffer dictBuffer = dictDecoder.getDictBuffer();
if (position != FormatSpec.NOT_VALID_WORD) {
dictBuffer.position(0);