diff options
-rw-r--r-- | android/PhoneticStringUtils.cpp | 9 | ||||
-rw-r--r-- | android/PhoneticStringUtilsTest.cpp | 11 |
2 files changed, 9 insertions, 11 deletions
diff --git a/android/PhoneticStringUtils.cpp b/android/PhoneticStringUtils.cpp index fa32d38..da5767f 100644 --- a/android/PhoneticStringUtils.cpp +++ b/android/PhoneticStringUtils.cpp @@ -294,14 +294,14 @@ static bool GetExpectedString( char32_t codepoints[MAX_CODEPOINTS]; - size_t src_len = GetUtf8LengthOrZero(src); + size_t src_len = utf8_length(src); if (src_len == 0) { return false; } bool next_is_consumed; size_t j = 0; for (size_t i = 0; i < src_len;) { - int32_t ret = GetUtf32AtFromUtf8(src, src_len, i, &i); + int32_t ret = utf32_at(src, src_len, i, &i); if (ret < 0) { // failed to parse UTF-8 return false; @@ -327,14 +327,13 @@ static bool GetExpectedString( length = 1; } - size_t new_len = GetUtf8LengthFromUtf32(codepoints, length); + size_t new_len = utf8_length_from_utf32(codepoints, length); *dst = static_cast<char *>(malloc(new_len + 1)); if (*dst == NULL) { return false; } - printf("new_len: %u\n", new_len); - if (GetUtf8FromUtf32(codepoints, length, *dst, new_len + 1) != new_len) { + if (utf32_to_utf8(codepoints, length, *dst, new_len + 1) != new_len) { free(*dst); *dst = NULL; return false; diff --git a/android/PhoneticStringUtilsTest.cpp b/android/PhoneticStringUtilsTest.cpp index 06a7ba8..5665fb9 100644 --- a/android/PhoneticStringUtilsTest.cpp +++ b/android/PhoneticStringUtilsTest.cpp @@ -31,7 +31,7 @@ class TestExecutor { private: void DoOneTest(void (TestExecutor::*test)()); - void testGetUtf32At(); + void testUtf32At(); void testGetPhoneticallySortableCodePointAscii(); void testGetPhoneticallySortableCodePointKana(); void testGetPhoneticallySortableCodePointWhitespaceOnly(); @@ -67,7 +67,7 @@ class TestExecutor { bool TestExecutor::DoAllTests() { - DoOneTest(&TestExecutor::testGetUtf32At); + DoOneTest(&TestExecutor::testUtf32At); DoOneTest(&TestExecutor::testGetPhoneticallySortableCodePointAscii); DoOneTest(&TestExecutor::testGetPhoneticallySortableCodePointKana); DoOneTest(&TestExecutor::testGetPhoneticallySortableCodePointWhitespaceOnly); @@ -97,8 +97,7 @@ void TestExecutor::DoOneTest(void (TestExecutor::*test)()) { #define TEST_GET_UTF32AT(src, index, expected_next, expected_value) \ ({ \ size_t next; \ - String8 string8(src); \ - int32_t ret = string8.getUtf32At((index), &next); \ + int32_t ret = utf32_at(src, strlen(src), index, &next); \ if (ret < 0) { \ printf("getUtf32At() returned negative value (src: %s, index: %d)\n", \ (src), (index)); \ @@ -111,8 +110,8 @@ void TestExecutor::DoOneTest(void (TestExecutor::*test)()) { } \ }) -void TestExecutor::testGetUtf32At() { - printf("testGetUtf32At()\n"); +void TestExecutor::testUtf32At() { + printf("testUtf32At()\n"); TEST_GET_UTF32AT("a", 0, 1, 97); // Japanese hiragana "a" |