aboutsummaryrefslogtreecommitdiffstats
path: root/native/jni/tests
diff options
context:
space:
mode:
authorAkifumi Yoshimoto <akifumi@google.com>2014-09-19 09:58:40 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-09-19 09:58:40 +0000
commit5c6db929e44df1b47ddf06a8d405f897dc6ba4e1 (patch)
tree1349e0f1a53020270fff83cf53f6b32dcf6d41d8 /native/jni/tests
parentf14043c8c63946f386577fe47d90d037c5706ea6 (diff)
parentfb2bde5a688d93aa946e3dd923aa1e99588777fc (diff)
downloadlatinime-5c6db929e44df1b47ddf06a8d405f897dc6ba4e1.tar.gz
latinime-5c6db929e44df1b47ddf06a8d405f897dc6ba4e1.tar.xz
latinime-5c6db929e44df1b47ddf06a8d405f897dc6ba4e1.zip
Merge "Native side reads character table"
Diffstat (limited to 'native/jni/tests')
-rw-r--r--native/jni/tests/suggest/policyimpl/dictionary/utils/byte_array_utils_test.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/native/jni/tests/suggest/policyimpl/dictionary/utils/byte_array_utils_test.cpp b/native/jni/tests/suggest/policyimpl/dictionary/utils/byte_array_utils_test.cpp
index a1c310d8a..c201e0d00 100644
--- a/native/jni/tests/suggest/policyimpl/dictionary/utils/byte_array_utils_test.cpp
+++ b/native/jni/tests/suggest/policyimpl/dictionary/utils/byte_array_utils_test.cpp
@@ -23,6 +23,19 @@
namespace latinime {
namespace {
+TEST(ByteArrayUtilsTest, TestReadCodePointTable) {
+ const int codePointTable[] = { 0x6f, 0x6b };
+ const uint8_t buffer[] = { 0x20u, 0x21u, 0x00u, 0x01u, 0x00u };
+ int pos = 0;
+ // Expect the first entry of codePointTable
+ EXPECT_EQ(0x6f, ByteArrayUtils::readCodePointAndAdvancePosition(buffer, codePointTable, &pos));
+ // Expect the second entry of codePointTable
+ EXPECT_EQ(0x6b, ByteArrayUtils::readCodePointAndAdvancePosition(buffer, codePointTable, &pos));
+ // Expect the original code point from buffer[2] to buffer[4], 0x100
+ // It isn't picked from the codePointTable, since it exceeds the range of the codePointTable.
+ EXPECT_EQ(0x100, ByteArrayUtils::readCodePointAndAdvancePosition(buffer, codePointTable, &pos));
+}
+
TEST(ByteArrayUtilsTest, TestReadInt) {
const uint8_t buffer[] = { 0x1u, 0x8Au, 0x0u, 0xAAu };
@@ -67,7 +80,7 @@ TEST(ByteArrayUtilsTest, TestReadCodePoint) {
int pos = 0;
int codePointArray[3];
- EXPECT_EQ(3, ByteArrayUtils::readStringAndAdvancePosition(buffer, MAX_WORD_LENGTH,
+ EXPECT_EQ(3, ByteArrayUtils::readStringAndAdvancePosition(buffer, MAX_WORD_LENGTH, nullptr,
codePointArray, &pos));
EXPECT_EQ(0x10FF00, codePointArray[0]);
EXPECT_EQ(0x20, codePointArray[1]);