+
+static void TestBug11665(void) {
+ // The problem was with the incorrect breaking of Japanese text beginning
+ // with Katakana characters when no prior Japanese or Chinese text had been
+ // encountered.
+ //
+ // Tested here in cintltst, rather than in intltest, because only cintltst
+ // tests have the ability to reset ICU, which is needed to get the bug
+ // to manifest itself.
+
+ static UChar japaneseText[] = {0x30A2, 0x30EC, 0x30EB, 0x30AE, 0x30FC, 0x6027, 0x7D50, 0x819C, 0x708E};
+ int32_t boundaries[10] = {0};
+ UBreakIterator *bi = NULL;
+ int32_t brk;
+ int32_t brkIdx = 0;
+ int32_t totalBreaks = 0;
+ UErrorCode status = U_ZERO_ERROR;
+
+ ctest_resetICU();
+ bi = ubrk_open(UBRK_WORD, "en_US", japaneseText, UPRV_LENGTHOF(japaneseText), &status);
+ TEST_ASSERT_SUCCESS(status);
+ if (!bi) {
+ return;
+ }
+ for (brk=ubrk_first(bi); brk != UBRK_DONE; brk=ubrk_next(bi)) {
+ boundaries[brkIdx] = brk;
+ if (++brkIdx >= UPRV_LENGTHOF(boundaries) - 1) {
+ break;
+ }
+ }
+ if (brkIdx <= 2 || brkIdx >= UPRV_LENGTHOF(boundaries)) {
+ log_err("%s:%d too few or many breaks found.\n", __FILE__, __LINE__);
+ } else {
+ totalBreaks = brkIdx;
+ brkIdx = 0;
+ for (brk=ubrk_first(bi); brk != UBRK_DONE; brk=ubrk_next(bi)) {
+ if (brk != boundaries[brkIdx]) {
+ log_err("%s:%d Break #%d differs between first and second iteration.\n", __FILE__, __LINE__, brkIdx);
+ break;
+ }
+ if (++brkIdx >= UPRV_LENGTHOF(boundaries) - 1) {
+ log_err("%s:%d Too many breaks.\n", __FILE__, __LINE__);
+ break;
+ }
+ }
+ if (totalBreaks != brkIdx) {
+ log_err("%s:%d Number of breaks differ between first and second iteration.\n", __FILE__, __LINE__);
+ }
+ }
+ ubrk_close(bi);
+}
+
+/*
+ * expOffset is the set of expected offsets, ending with '-1'.
+ * "Expected expOffset -1" means "expected the end of the offsets"
+ */
+
+static const char testSentenceSuppressionsEn[] = "Mr. Jones comes home. Dr. Smith Ph.D. is out. In the U.S.A. it is hot.";
+static const int32_t testSentSuppFwdOffsetsEn[] = { 22, 46, 70, -1 }; /* With suppressions */
+static const int32_t testSentFwdOffsetsEn[] = { 4, 22, 26, 46, 70, -1 }; /* Without suppressions */
+static const int32_t testSentSuppRevOffsetsEn[] = { 46, 22, 0, -1 }; /* With suppressions */
+static const int32_t testSentRevOffsetsEn[] = { 46, 26, 22, 4, 0, -1 }; /* Without suppressions */
+
+static const char testSentenceSuppressionsDe[] = "Wenn ich schon h\\u00F6re zu Guttenberg kommt evtl. zur\\u00FCck.";
+// "Wenn ich schon höre zu Guttenberg kommt evtl. zurück."
+static const int32_t testSentSuppFwdOffsetsDe[] = { 53, -1 }; /* With suppressions */
+static const int32_t testSentFwdOffsetsDe[] = { 53, -1 }; /* Without suppressions; no break in evtl. zur due to casing */
+static const int32_t testSentSuppRevOffsetsDe[] = { 0, -1 }; /* With suppressions */
+static const int32_t testSentRevOffsetsDe[] = { 0, -1 }; /* Without suppressions */
+
+static const char testSentenceSuppressionsEs[] = "Te esperamos todos los miercoles en Bravo 416, Col. El Pueblo a las 7 PM.";
+static const int32_t testSentSuppFwdOffsetsEs[] = { 73, -1 }; /* With suppressions */
+static const int32_t testSentFwdOffsetsEs[] = { 52, 73, -1 }; /* Without suppressions */
+static const int32_t testSentSuppRevOffsetsEs[] = { 0, -1 }; /* With suppressions */
+static const int32_t testSentRevOffsetsEs[] = { 52, 0, -1 }; /* Without suppressions */
+
+static const char testSentenceSuppressionsE1[] = "Add or detract. The world will little note.";
+static const char testSentenceSuppressionsE1u[] = "ADD OR DETRACT. THE WORLD WILL LITTLE NOTE.";
+static const int32_t testSentFwdOffsetsE1[] = { 16, 43, -1 }; /* Suppressions and case should make no difference */
+static const int32_t testSentRevOffsetsE1[] = { 16, 0, -1 }; /* Suppressions and case should make no difference */
+
+static const char testSentenceSuppressionsE2[] = "Coming up, the sprints at NCAA. Are you watching?";
+static const char testSentenceSuppressionsE2u[] = "COMING UP, THE SPRINTS AT NCAA. ARE YOU WATCHING?";
+static const int32_t testSentFwdOffsetsE2[] = { 32, 49, -1 }; /* Suppressions and case should make no difference */
+static const int32_t testSentRevOffsetsE2[] = { 32, 0, -1 }; /* Suppressions and case should make no difference */
+
+static const char testSentenceSuppressionsFr[] = "Tr\\u00E8s bonne prise de parole de M. Junod, municipal \\u00E0 la culture de Lausanne.";
+// "Très bonne prise de parole de M. Junod, municipal à la culture de Lausanne."
+static const int32_t testSentFwdOffsetsFr[] = { 33, 75, -1 }; /* Without suppressions */
+static const int32_t testSentSuppFwdOffsetsFr[] = { 75, -1 }; /* With suppressions */
+static const int32_t testSentRevOffsetsFr[] = { 33, 0, -1 }; /* Without suppressions */
+static const int32_t testSentSuppRevOffsetsFr[] = { 0, -1 }; /* With suppressions */
+
+static const char testSentenceSuppressionsE3[] = "G8 countries e.g. U.K., Japan. Sanctions i.e. restrictions. Test E. Xx G. Xx I. Xx.";
+static const char testSentenceSuppressionsE3u[] = "G8 COUNTRIES E.G. U.K., JAPAN. SANCTIONS I.E. RESTRICTIONS. TEST E. XX G. XX I. XX.";
+static const int32_t testSentSuppFwdOffsetsE3[] = { 31, 60, 83, -1 }; /* With suppressions */
+static const int32_t testSentSuppRevOffsetsE3[] = { 60, 31, 0, -1 }; /* With suppressions */
+static const int32_t testSentFwdOffsetsE3[] = { 18, 31, 60, 68, 74, 80, 83, -1 }; /* Without suppressions */
+static const int32_t testSentRevOffsetsE3[] = { 80, 74, 68, 60, 31, 18, 0, -1 }; /* Without suppressions */
+static const int32_t testSentFwdOffsetsE3u[] = { 18, 31, 46, 60, 68, 74, 80, 83, -1 }; /* Without suppressions */
+static const int32_t testSentRevOffsetsE3u[] = { 80, 74, 68, 60, 46, 31, 18, 0, -1 }; /* Without suppressions */
+
+enum { kTextULenMax = 128, kTextBLenMax = 192 };
+
+typedef struct {
+ const char * locale;
+ const char * text;
+ const int32_t * expFwdOffsets;
+ const int32_t * expRevOffsets;
+} TestBISuppressionsItem;
+
+static const TestBISuppressionsItem testBISuppressionsItems[] = {
+ { "en@ss=standard", testSentenceSuppressionsEn, testSentSuppFwdOffsetsEn, testSentSuppRevOffsetsEn },
+ { "en", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn },
+ { "en_CA", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn },
+ { "en_CA@ss=standard", testSentenceSuppressionsEn, testSentSuppFwdOffsetsEn, testSentSuppRevOffsetsEn },
+ { "fr@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn },
+ { "af@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, /* no brkiter data => nosuppressions? */
+ { "af_ZA@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, /* no brkiter data => nosuppressions? */
+ { "zh@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, /* brkiter data, no suppressions data => no suppressions */
+ { "zh_Hant@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, /* brkiter data, no suppressions data => no suppressions */
+ { "fi@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, /* brkiter data, no suppressions data => no suppressions */
+ { "ja@ss=standard", testSentenceSuppressionsEn, testSentFwdOffsetsEn, testSentRevOffsetsEn }, /* brkiter data, no suppressions data => no suppressions */
+ { "de@ss=standard", testSentenceSuppressionsDe, testSentSuppFwdOffsetsDe, testSentSuppRevOffsetsDe },
+ { "de", testSentenceSuppressionsDe, testSentFwdOffsetsDe, testSentRevOffsetsDe },
+ { "es@ss=standard", testSentenceSuppressionsEs, testSentSuppFwdOffsetsEs, testSentSuppRevOffsetsEs },
+ { "es", testSentenceSuppressionsEs, testSentFwdOffsetsEs, testSentRevOffsetsEs },
+ { "en", testSentenceSuppressionsE1, testSentFwdOffsetsE1, testSentRevOffsetsE1 },
+ { "en@ss=standard", testSentenceSuppressionsE1, testSentFwdOffsetsE1, testSentRevOffsetsE1 },
+ { "en", testSentenceSuppressionsE1u, testSentFwdOffsetsE1, testSentRevOffsetsE1 },
+ { "en@ss=standard", testSentenceSuppressionsE1u, testSentFwdOffsetsE1, testSentRevOffsetsE1 },
+ { "en", testSentenceSuppressionsE2, testSentFwdOffsetsE2, testSentRevOffsetsE2 },
+ { "en@ss=standard", testSentenceSuppressionsE2, testSentFwdOffsetsE2, testSentRevOffsetsE2 },
+ { "en", testSentenceSuppressionsE2u, testSentFwdOffsetsE2, testSentRevOffsetsE2 },
+ { "en@ss=standard", testSentenceSuppressionsE2u, testSentFwdOffsetsE2, testSentRevOffsetsE2 },
+ { "fr", testSentenceSuppressionsFr, testSentFwdOffsetsFr, testSentRevOffsetsFr },
+ { "fr@ss=standard", testSentenceSuppressionsFr, testSentSuppFwdOffsetsFr, testSentSuppRevOffsetsFr },
+ { "en@ss=standard", testSentenceSuppressionsE3, testSentSuppFwdOffsetsE3, testSentSuppRevOffsetsE3 },
+ { "en", testSentenceSuppressionsE3, testSentFwdOffsetsE3, testSentRevOffsetsE3 },
+ { "en@ss=standard", testSentenceSuppressionsE3u, testSentSuppFwdOffsetsE3, testSentSuppRevOffsetsE3 },
+ { "en", testSentenceSuppressionsE3u, testSentFwdOffsetsE3u, testSentRevOffsetsE3u },
+ { NULL, NULL, NULL }
+};
+
+static void TestBreakIteratorSuppressions(void) {
+ const TestBISuppressionsItem * itemPtr;
+
+ for (itemPtr = testBISuppressionsItems; itemPtr->locale != NULL; itemPtr++) {
+ UChar textU[kTextULenMax + 1];
+ char textB[kTextBLenMax];
+ int32_t textULen = u_unescape(itemPtr->text, textU, kTextULenMax);
+ textU[kTextULenMax] = 0; // ensure zero termination
+ UErrorCode status = U_ZERO_ERROR;
+ UBreakIterator *bi = ubrk_open(UBRK_SENTENCE, itemPtr->locale, textU, textULen, &status);
+ log_verbose("#%d: %s\n", (itemPtr-testBISuppressionsItems), itemPtr->locale);
+ if (U_SUCCESS(status)) {
+ int32_t offset, start;
+ const int32_t * expOffsetPtr;
+ const int32_t * expOffsetStart;
+ u_austrcpy(textB, textU);
+
+ expOffsetStart = expOffsetPtr = itemPtr->expFwdOffsets;
+ ubrk_first(bi);
+ for (; (offset = ubrk_next(bi)) != UBRK_DONE && *expOffsetPtr >= 0; expOffsetPtr++) {
+ if (offset != *expOffsetPtr) {
+ log_err("FAIL: ubrk_next loc \"%s\", expected %d, got %d, text \"%s\"\n",
+ itemPtr->locale, *expOffsetPtr, offset, textB);
+ }
+ }
+ if (offset != UBRK_DONE || *expOffsetPtr >= 0) {
+ log_err("FAIL: ubrk_next loc \"%s\", expected UBRK_DONE & expOffset -1, got %d and %d, text \"%s\"\n",
+ itemPtr->locale, offset, *expOffsetPtr, textB);
+ }
+
+ expOffsetStart = expOffsetPtr = itemPtr->expFwdOffsets;
+ start = ubrk_first(bi) + 1;
+ for (; (offset = ubrk_following(bi, start)) != UBRK_DONE && *expOffsetPtr >= 0; expOffsetPtr++) {
+ if (offset != *expOffsetPtr) {
+ log_err("FAIL: ubrk_following(%d) loc \"%s\", expected %d, got %d, text \"%s\"\n",
+ start, itemPtr->locale, *expOffsetPtr, offset, textB);
+ }
+ start = *expOffsetPtr + 1;
+ }
+ if (offset != UBRK_DONE || *expOffsetPtr >= 0) {
+ log_err("FAIL: ubrk_following(%d) loc \"%s\", expected UBRK_DONE & expOffset -1, got %d and %d, text \"%s\"\n",
+ start, itemPtr->locale, offset, *expOffsetPtr, textB);
+ }
+
+ expOffsetStart = expOffsetPtr = itemPtr->expRevOffsets;
+ offset = ubrk_last(bi);
+ log_verbose("___ @%d ubrk_last\n", offset);
+ if(offset == 0) {
+ log_err("FAIL: ubrk_last loc \"%s\" unexpected %d\n", itemPtr->locale, offset);
+ }
+ for (; (offset = ubrk_previous(bi)) != UBRK_DONE && *expOffsetPtr >= 0; expOffsetPtr++) {
+ if (offset != *expOffsetPtr) {
+ log_err("FAIL: ubrk_previous loc \"%s\", expected %d, got %d, text \"%s\"\n",
+ itemPtr->locale, *expOffsetPtr, offset, textB);
+ } else {
+ log_verbose("[%d] @%d ubrk_previous()\n", (expOffsetPtr - expOffsetStart), offset);
+ }
+ }
+ if (offset != UBRK_DONE || *expOffsetPtr >= 0) {
+ log_err("FAIL: ubrk_previous loc \"%s\", expected UBRK_DONE & expOffset[%d] -1, got %d and %d, text \"%s\"\n",
+ itemPtr->locale, expOffsetPtr - expOffsetStart, offset, *expOffsetPtr, textB);
+ }
+
+ expOffsetStart = expOffsetPtr = itemPtr->expRevOffsets;
+ start = ubrk_last(bi) - 1;
+ for (; (offset = ubrk_preceding(bi, start)) != UBRK_DONE && *expOffsetPtr >= 0; expOffsetPtr++) {
+ if (offset != *expOffsetPtr) {
+ log_err("FAIL: ubrk_preceding(%d) loc \"%s\", expected %d, got %d, text \"%s\"\n",
+ start, itemPtr->locale, *expOffsetPtr, offset, textB);
+ }
+ start = *expOffsetPtr - 1;
+ }
+ if (start >=0 && (offset != UBRK_DONE || *expOffsetPtr >= 0)) {
+ log_err("FAIL: ubrk_preceding loc(%d) \"%s\", expected UBRK_DONE & expOffset -1, got %d and %d, text \"%s\"\n",
+ start, itemPtr->locale, offset, *expOffsetPtr, textB);
+ }
+
+ ubrk_close(bi);
+ } else {
+ log_data_err("FAIL: ubrk_open(UBRK_SENTENCE, \"%s\", ...) status %s (Are you missing data?)\n",
+ itemPtr->locale, u_errorName(status));
+ }
+ }
+}
+
+#if APPLE_ADDITIONS
+#include <stdio.h>
+#if U_PLATFORM_IS_DARWIN_BASED
+#include <unistd.h>
+#include <mach/mach_time.h>
+#define GET_START() mach_absolute_time()
+#define GET_DURATION(start, info) ((mach_absolute_time() - start) * info.numer)/info.denom
+#elif !U_PLATFORM_HAS_WIN32_API
+#include <unistd.h>
+#include "putilimp.h"
+#define GET_START() (uint64_t)uprv_getUTCtime()
+#define GET_DURATION(start, info) ((uint64_t)uprv_getUTCtime() - start)
+#else
+#include "putilimp.h"
+#define GET_START() (unsigned long long)uprv_getUTCtime()
+#define GET_DURATION(start, info) ((unsigned long long)uprv_getUTCtime() - start)
+#endif
+#include "unicode/urbtok.h"
+#include "cstring.h"
+
+typedef struct {
+ RuleBasedTokenRange token;
+ unsigned long flags;
+} RBTokResult;
+
+static const UChar tokTextLatn[] = {
+/*
+"Short phrase! Another (with parens); done.\n
+At 4:00, tea-time.\n
+He wouldn't've wanted y'all to ... come at 3:30pm for $3 coffee @funman :)\n
+x3:30 -- x1.0"
+*/
+ 0x53,0x68,0x6F,0x72,0x74,0x20,0x70,0x68,0x72,0x61,0x73,0x65,0x21,0x20,
+ 0x41,0x6E,0x6F,0x74,0x68,0x65,0x72,0x20,0x28,0x77,0x69,0x74,0x68,0x20,0x70,0x61,0x72,0x65,0x6E,0x73,0x29,0x3B,0x20,0x64,0x6F,0x6E,0x65,0x2E,0x0A,
+ 0x41,0x74,0x20,0x34,0x3A,0x30,0x30,0x2C,0x20,0x74,0x65,0x61,0x2D,0x74,0x69,0x6D,0x65,0x2E,0x0A,
+ 0x48,0x65,0x20,0x77,0x6F,0x75,0x6C,0x64,0x6E,0x27,0x74,0x27,0x76,0x65,0x20,0x77,0x61,0x6E,0x74,0x65,0x64,0x20,
+ 0x79,0x27,0x61,0x6C,0x6C,0x20,0x74,0x6F,0x20,0x2E,0x2E,0x2E,0x20, 0x63,0x6F,0x6D,0x65,0x20,0x61,0x74,0x20,
+ 0x33,0x3A,0x33,0x30,0x70,0x6D,0x20,0x66,0x6F,0x72,0x20,0x24,0x33,0x20,0x63,0x6F,0x66,0x66,0x65,0x65,0x20,
+ 0x40,0x66,0x75,0x6E,0x6D,0x61,0x6E,0x20,0x3A,0x29,0x0A,
+ 0x78,0x33,0x3A,0x33,0x30,0x20,0x2D,0x2D,0x20,0x78,0x31,0x2E,0x30,0
+};
+
+
+static const RBTokResult expTokLatnCFST[] = { // 26 tokens
+ { { 0, 5 }, 0x002 }, // Short
+ { { 6, 7 }, 0x020 }, // phrase!
+ { { 14, 7 }, 0x002 }, // Another
+ { { 22, 5 }, 0x020 }, // (with
+ { { 28, 8 }, 0x020 }, // parens);
+ { { 37, 5 }, 0x020 }, // done.
+ { { 43, 2 }, 0x002 }, //
+ { { 46, 5 }, 0x030 }, //
+ { { 52, 9 }, 0x020 }, //
+ { { 62, 2 }, 0x002 }, //
+ { { 65, 11 }, 0x020 }, //
+ { { 77, 6 }, 0x000 }, //
+ { { 84, 5 }, 0x020 }, //
+ { { 90, 2 }, 0x000 }, //
+ { { 93, 3 }, 0x020 }, //
+ { { 97, 4 }, 0x000 }, //
+ { { 102, 2 }, 0x000 }, //
+ { { 105, 6 }, 0x030 }, //
+ { { 112, 3 }, 0x000 }, //
+ { { 116, 2 }, 0x030 }, //
+ { { 119, 6 }, 0x000 }, //
+ { { 126, 7 }, 0x020 }, //
+ { { 134, 2 }, 0x020 }, //
+ { { 137, 5 }, 0x030 }, //
+ { { 143, 2 }, 0x020 }, //
+ { { 146, 4 }, 0x030 }, //
+};
+
+// The following was expTokLatnNLLT for ICU 61-based Apple ICU
+static const RBTokResult expTokLatnNLLT_Old[] = { // 66 tokens
+ { { 0, 5 }, 0xC8 }, // Short
+ { { 5, 1 }, 0x00 }, // _sp_
+ { { 6, 6 }, 0xC8 }, // phrase
+ { { 12, 1 }, 0x00 }, // !
+ { { 13, 1 }, 0x00 }, // _sp_
+ { { 14, 7 }, 0xC8 }, // Another
+ { { 21, 1 }, 0x00 }, // _sp_
+ { { 22, 1 }, 0x00 }, // (
+ { { 23, 4 }, 0xC8 }, // with
+ { { 27, 1 }, 0x00 }, // _sp_
+ { { 28, 6 }, 0xC8 }, // parens
+ { { 34, 1 }, 0x00 }, // )
+ { { 35, 1 }, 0x00 }, // ;
+ { { 36, 1 }, 0x00 }, // _sp_
+ { { 37, 4 }, 0xC8 }, // done
+ { { 41, 1 }, 0x14 }, // .
+ { { 42, 1 }, 0x00 }, // _nl_
+
+ { { 43, 2 }, 0xC8 }, // At
+ { { 45, 1 }, 0x00 }, // _sp_
+ { { 46, 4 }, 0x76 }, // 4:00
+ { { 50, 1 }, 0x00 }, // ,
+ { { 51, 1 }, 0x00 }, // _sp_
+ { { 52, 3 }, 0xC8 }, // tea
+ { { 55, 1 }, 0x15 }, // -
+ { { 56, 4 }, 0xC8 }, // time
+ { { 60, 1 }, 0x14 }, // .
+ { { 61, 1 }, 0x00 }, // _nl_
+
+ { { 62, 2 }, 0xC8 }, // He
+ { { 64, 1 }, 0x00 }, // _sp_
+ { { 65, 8 }, 0xCA }, // wouldn't
+ { { 73, 1 }, 0x16 }, // '
+ { { 74, 2 }, 0xC8 }, // ve
+ { { 76, 1 }, 0x00 }, // _sp_
+ { { 77, 6 }, 0xC8 }, // wanted
+ { { 83, 1 }, 0x00 }, // _sp_
+ { { 84, 5 }, 0xCA }, // y'all
+ { { 89, 1 }, 0x00 }, // _sp_
+ { { 90, 2 }, 0xC8 }, // to
+ { { 92, 1 }, 0x00 }, // _sp_
+ { { 93, 3 }, 0x3C }, // ...
+ { { 96, 1 }, 0x00 }, // _sp_
+ { { 97, 4 }, 0xC8 }, // come
+ { { 101, 1 }, 0x00 }, // _sp_
+ { { 102, 2 }, 0xC8 }, // at
+ { { 104, 1 }, 0x00 }, // _sp_
+ { { 105, 4 }, 0xC8 }, // 3:30
+ { { 109, 2 }, 0xC8 }, // pm
+ { { 111, 1 }, 0x00 }, // _sp_
+ { { 112, 3 }, 0xC8 }, // for
+ { { 115, 1 }, 0x00 }, // _sp_
+ { { 116, 1 }, 0x00 }, // $
+ { { 117, 1 }, 0x64 }, // 3
+ { { 118, 1 }, 0x00 }, // _sp_
+ { { 119, 6 }, 0xC8 }, // coffee
+ { { 125, 1 }, 0x00 }, // _sp_
+ { { 126, 7 }, 0xDF }, // @funman
+ { { 133, 1 }, 0x00 }, // _sp_
+ { { 134, 2 }, 0x20 }, // :)
+ { { 136, 1 }, 0x00 }, // _nl_
+ { { 137, 1 }, 0x76 }, // x
+ { { 138, 4 }, 0x76 }, // 3:30
+ { { 142, 1 }, 0x00 }, // _sp_
+ { { 143, 2 }, 0x3D }, // --
+ { { 145, 1 }, 0x00 }, // _sp_
+ { { 146, 1 }, 0x77 }, // x
+ { { 147, 3 }, 0x77 }, // 1.0
+};
+
+// For ICU 62-based Apple ICU, expTokLatnNLLT matches expTokLatnNLLT_File
+#define expTokLatnNLLT expTokLatnNLLT_File
+static const RBTokResult expTokLatnNLLT_File[] = { // 67 tokens
+ { { 0, 5 }, 0xC8 }, // Short
+ { { 5, 1 }, 0x00 }, // _sp_
+ { { 6, 6 }, 0xC8 }, // phrase
+ { { 12, 1 }, 0x00 }, // !
+ { { 13, 1 }, 0x00 }, // _sp_
+ { { 14, 7 }, 0xC8 }, // Another
+ { { 21, 1 }, 0x00 }, // _sp_
+ { { 22, 1 }, 0x00 }, // (
+ { { 23, 4 }, 0xC8 }, // with
+ { { 27, 1 }, 0x00 }, // _sp_
+ { { 28, 6 }, 0xC8 }, // parens
+ { { 34, 1 }, 0x00 }, // )
+ { { 35, 1 }, 0x00 }, // ;
+ { { 36, 1 }, 0x00 }, // _sp_
+ { { 37, 4 }, 0xC8 }, // done
+ { { 41, 1 }, 0x14 }, // .
+ { { 42, 1 }, 0x00 }, // _nl_
+
+ { { 43, 2 }, 0xC8 }, // At
+ { { 45, 1 }, 0x00 }, // _sp_
+ { { 46, 4 }, 0x76 }, // 4:00
+ { { 50, 1 }, 0x00 }, // ,
+ { { 51, 1 }, 0x00 }, // _sp_
+ { { 52, 3 }, 0xC8 }, // tea
+ { { 55, 1 }, 0x15 }, // -
+ { { 56, 4 }, 0xC8 }, // time
+ { { 60, 1 }, 0x14 }, // .
+ { { 61, 1 }, 0x00 }, // _nl_
+
+ { { 62, 2 }, 0xC8 }, // He
+ { { 64, 1 }, 0x00 }, // _sp_
+ { { 65, 8 }, 0xCA }, // wouldn't
+ { { 73, 1 }, 0x16 }, // '
+ { { 74, 2 }, 0xC8 }, // ve
+ { { 76, 1 }, 0x00 }, // _sp_
+ { { 77, 6 }, 0xC8 }, // wanted
+ { { 83, 1 }, 0x00 }, // _sp_
+ { { 84, 5 }, 0xCA }, // y'all
+ { { 89, 1 }, 0x00 }, // _sp_
+ { { 90, 2 }, 0xC8 }, // to
+ { { 92, 1 }, 0x00 }, // _sp_
+ { { 93, 3 }, 0x3C }, // ...
+ { { 96, 1 }, 0x00 }, // _sp_
+ { { 97, 4 }, 0xC8 }, // come
+ { { 101, 1 }, 0x00 }, // _sp_
+ { { 102, 2 }, 0xC8 }, // at
+ { { 104, 1 }, 0x00 }, // _sp_
+ { { 105, 4 }, 0xC8 }, // 3:30
+ { { 109, 2 }, 0xC8 }, // pm
+ { { 111, 1 }, 0x00 }, // _sp_
+ { { 112, 3 }, 0xC8 }, // for
+ { { 115, 1 }, 0x00 }, // _sp_
+ { { 116, 1 }, 0x00 }, // $
+ { { 117, 1 }, 0x64 }, // 3
+ { { 118, 1 }, 0x00 }, // _sp_
+ { { 119, 6 }, 0xC8 }, // coffee
+ { { 125, 1 }, 0x00 }, // _sp_
+ { { 126, 7 }, 0xDF }, // @funman
+ { { 133, 1 }, 0x00 }, // _sp_
+ { { 134, 2 }, 0x20 }, // :)
+ { { 136, 1 }, 0x00 }, // _nl_
+ { { 137, 1 }, 0x76 }, // x
+ { { 138, 4 }, 0x76 }, // 3:30
+ { { 142, 1 }, 0x00 }, // _sp_
+ { { 143, 2 }, 0x3D }, // --
+ { { 145, 1 }, 0x00 }, // _sp_
+ { { 146, 2 }, 0xEC }, // x1
+ { { 148, 1 }, 0x14 }, // .
+ { { 149, 1 }, 0x64 }, // 0
+};
+
+static const RBTokResult expTokLatnNLLT_57[] = { // 67 tokens
+ { { 0, 5 }, 0xC8 }, //
+ { { 5, 1 }, 0x00 }, //
+ { { 6, 6 }, 0xC8 }, //
+ { { 12, 1 }, 0x00 }, //
+ { { 13, 1 }, 0x00 }, //
+ { { 14, 7 }, 0xC8 }, //
+ { { 21, 1 }, 0x00 }, //
+ { { 22, 1 }, 0x00 }, //
+ { { 23, 4 }, 0xC8 }, //
+ { { 27, 1 }, 0x00 }, //
+ { { 28, 6 }, 0xC8 }, //
+ { { 34, 1 }, 0x00 }, //
+ { { 35, 1 }, 0x00 }, //
+ { { 36, 1 }, 0x00 }, //
+ { { 37, 4 }, 0xC8 }, //
+ { { 41, 1 }, 0x14 }, //
+ { { 42, 1 }, 0x00 }, //
+
+ { { 43, 2 }, 0xC8 }, //
+ { { 45, 1 }, 0x00 }, //
+ { { 46, 4 }, 0x76 }, //
+ { { 50, 1 }, 0x00 }, //
+ { { 51, 1 }, 0x00 }, //
+ { { 52, 3 }, 0xC8 }, //
+ { { 55, 1 }, 0x15 }, //
+ { { 56, 4 }, 0xC8 }, //
+ { { 60, 1 }, 0x14 }, //
+ { { 61, 1 }, 0x00 }, //
+
+ { { 62, 2 }, 0xC8 }, //
+ { { 64, 1 }, 0x00 }, //
+ { { 65, 8 }, 0xCA }, //
+ { { 73, 1 }, 0x16 }, //
+ { { 74, 2 }, 0xC8 }, //
+ { { 76, 1 }, 0x00 }, //
+ { { 77, 6 }, 0xC8 }, //
+ { { 83, 1 }, 0x00 }, //
+ { { 84, 5 }, 0xCA }, //
+ { { 89, 1 }, 0x00 }, //
+ { { 90, 2 }, 0xC8 }, //
+ { { 92, 1 }, 0x00 }, //
+ { { 93, 3 }, 0x3C }, //
+ { { 96, 1 }, 0x00 }, //
+ { { 97, 4 }, 0xC8 }, //
+ { { 101, 1 }, 0x00 }, //
+ { { 102, 2 }, 0xC8 }, //
+ { { 104, 1 }, 0x00 }, //
+ { { 105, 6 }, 0xC8 }, //
+ { { 111, 1 }, 0x00 }, //
+ { { 112, 3 }, 0xC8 }, //
+ { { 115, 1 }, 0x00 }, //
+ { { 116, 1 }, 0x00 }, //
+ { { 117, 1 }, 0x64 }, //
+ { { 118, 1 }, 0x00 }, //
+ { { 119, 6 }, 0xC8 }, //
+ { { 125, 1 }, 0x00 }, //
+ { { 126, 7 }, 0xDF }, //
+ { { 133, 1 }, 0x00 }, //
+ { { 134, 2 }, 0x20 }, //
+ { { 136, 1 }, 0x00 }, //
+ { { 137, 2 }, 0xEC }, //
+ { { 139, 1 }, 0x00 }, //
+ { { 140, 2 }, 0x64 }, //
+ { { 142, 1 }, 0x00 }, //
+ { { 143, 2 }, 0x3D }, //
+ { { 145, 1 }, 0x00 }, //
+ { { 146, 2 }, 0xEC }, //
+ { { 148, 1 }, 0x14 }, //
+ { { 149, 1 }, 0x64 }, //
+};
+
+
+static const RBTokResult expTokLatnStdW[] = { // 72 tokens
+ { { 0, 5 }, 0x0C8 }, //
+ { { 5, 1 }, 0x000 }, //
+ { { 6, 6 }, 0x0C8 }, //
+ { { 12, 1 }, 0x000 }, //
+ { { 13, 1 }, 0x000 }, //
+ { { 14, 7 }, 0x0C8 }, //
+ { { 21, 1 }, 0x000 }, //
+ { { 22, 1 }, 0x000 }, //
+ { { 23, 4 }, 0x0C8 }, //
+ { { 27, 1 }, 0x000 }, //
+ { { 28, 6 }, 0x0C8 }, //
+ { { 34, 1 }, 0x000 }, //
+ { { 35, 1 }, 0x000 }, //
+ { { 36, 1 }, 0x000 }, //
+ { { 37, 4 }, 0x0C8 }, //
+ { { 41, 1 }, 0x000 }, //
+ { { 42, 1 }, 0x000 }, //
+ { { 43, 2 }, 0x0C8 }, //
+ { { 45, 1 }, 0x000 }, //
+ { { 46, 1 }, 0x064 }, //
+ { { 47, 1 }, 0x000 }, //
+ { { 48, 2 }, 0x064 }, //
+ { { 50, 1 }, 0x000 }, //
+ { { 51, 1 }, 0x000 }, //
+ { { 52, 3 }, 0x0C8 }, //
+ { { 55, 1 }, 0x000 }, //
+ { { 56, 4 }, 0x0C8 }, //
+ { { 60, 1 }, 0x000 }, //
+ { { 61, 1 }, 0x000 }, //
+ { { 62, 2 }, 0x0C8 }, //
+ { { 64, 1 }, 0x000 }, //
+ { { 65, 11 }, 0x0C8 }, //
+ { { 76, 1 }, 0x000 }, //
+ { { 77, 6 }, 0x0C8 }, //
+ { { 83, 1 }, 0x000 }, //
+ { { 84, 5 }, 0x0C8 }, //
+ { { 89, 1 }, 0x000 }, //
+ { { 90, 2 }, 0x0C8 }, //
+ { { 92, 1 }, 0x000 }, //
+ { { 93, 1 }, 0x000 }, //
+ { { 94, 1 }, 0x000 }, //
+ { { 95, 1 }, 0x000 }, //
+ { { 96, 1 }, 0x000 }, //
+ { { 97, 4 }, 0x0C8 }, //
+ { { 101, 1 }, 0x000 }, //
+ { { 102, 2 }, 0x0C8 }, //
+ { { 104, 1 }, 0x000 }, //
+ { { 105, 1 }, 0x064 }, //
+ { { 106, 1 }, 0x000 }, //
+ { { 107, 4 }, 0x0C8 }, //
+ { { 111, 1 }, 0x000 }, //
+ { { 112, 3 }, 0x0C8 }, //
+ { { 115, 1 }, 0x000 }, //
+ { { 116, 1 }, 0x000 }, //
+ { { 117, 1 }, 0x064 }, //
+ { { 118, 1 }, 0x000 }, //
+ { { 119, 6 }, 0x0C8 }, //
+ { { 125, 1 }, 0x000 }, //
+ { { 126, 1 }, 0x000 }, //
+ { { 127, 6 }, 0x0C8 }, //
+ { { 133, 1 }, 0x000 }, //
+ { { 134, 1 }, 0x000 }, //
+ { { 135, 1 }, 0x000 }, //
+ { { 136, 1 }, 0x000 }, //
+ { { 137, 2 }, 0x0EC }, //
+ { { 139, 1 }, 0x000 }, //
+ { { 140, 2 }, 0x064 }, //
+ { { 142, 1 }, 0x000 }, //
+ { { 143, 1 }, 0x000 }, //
+ { { 144, 1 }, 0x000 }, //
+ { { 145, 1 }, 0x000 }, //
+ { { 146, 4 }, 0x064 }, //
+};
+
+static const UChar tokTextMisc[] = {
+/*
+"4‑inch phone.\n
+3월 30일\n
+从你开始使用 iPhone 6s 的那一刻起,你就会感觉到它是如此不同。\n""
+*/
+ 0x0034,0x2011,0x0069,0x006E,0x0063,0x0068,0x0020,0x0070,0x0068,0x006F,0x006E,0x0065,0x002E,0x000A,
+ 0x0033,0xC6D4,0x0020,0x0033,0x0030,0xC77C,0x000A,
+ 0x4ECE,0x4F60,0x5F00,0x59CB,0x4F7F,0x7528,0x0020,0x0069,0x0050,0x0068,0x006F,0x006E,0x0065,0x0020,
+ 0x0036,0x0073,0x0020,0x7684,0x90A3,0x4E00,0x523B,0x8D77,0xFF0C,
+ 0x4F60,0x5C31,0x4F1A,0x611F,0x89C9,0x5230,0x5B83,0x662F,0x5982,0x6B64,0x4E0D,0x540C,0x3002,0x000A,0
+};
+
+static const RBTokResult expTokMiscCFST[] = { // 8 tokens
+ // ranges flags text
+ { { 0, 6}, 0x131 }, // 4‑inch
+ { { 7, 6}, 0x20 }, // phone.
+ { { 14, 2}, 0x1110 }, // 3월
+ { { 17, 3}, 0x1110 }, // 30일
+ { { 21, 6}, 0x40000000 }, // 从你开始使用
+ { { 28, 6}, 0x04 }, // iPhone
+ { { 35, 2}, 0x10 }, // 6s
+ { { 38, 19}, 0x40000121 }, // 的那一刻起,你就会感觉到它是如此不同。
+};
+
+static const RBTokResult expTokMiscCFST_57Bulk[] = { // 5 tokens
+ // ranges flags text
+ { { 0, 6}, 0x131 }, // 4‑inch
+ { { 7, 6}, 0x20 }, // phone.
+ { { 14, 2}, 0x1110 }, // 3월
+ { { 17, 3}, 0x1110 }, // 30일
+ { { 21, 6}, 0x40000000 }, // 从你开始使用
+ // missing the last 3 entries
+};
+
+
+static const RBTokResult expTokMiscNLLT[] = { // 36 tokens
+ { { 0, 1 }, 0x064 }, //
+ { { 1, 1 }, 0x000 }, //
+ { { 2, 4 }, 0x0C8 }, //
+ { { 6, 1 }, 0x000 }, //
+ { { 7, 5 }, 0x0C8 }, //
+ { { 12, 1 }, 0x014 }, //
+ { { 13, 1 }, 0x000 }, //
+ { { 14, 1 }, 0x064 }, //
+ { { 15, 1 }, 0x0C8 }, //
+ { { 16, 1 }, 0x000 }, //
+ { { 17, 2 }, 0x064 }, //
+ { { 19, 1 }, 0x0C8 }, //
+ { { 20, 1 }, 0x000 }, //
+ { { 21, 1 }, 0x190 }, //
+ { { 22, 1 }, 0x190 }, //
+ { { 23, 2 }, 0x190 }, //
+ { { 25, 2 }, 0x190 }, //
+ { { 27, 1 }, 0x000 }, //
+ { { 28, 6 }, 0x0C8 }, //
+ { { 34, 1 }, 0x000 }, //
+ { { 35, 2 }, 0x0C8 }, //
+ { { 37, 1 }, 0x000 }, //
+ { { 38, 1 }, 0x190 }, //
+ { { 39, 2 }, 0x190 }, //
+ { { 41, 2 }, 0x190 }, //
+ { { 43, 1 }, 0x000 }, //
+ { { 44, 1 }, 0x190 }, //
+ { { 45, 1 }, 0x190 }, //
+ { { 46, 1 }, 0x190 }, //
+ { { 47, 2 }, 0x190 }, //
+ { { 49, 1 }, 0x190 }, //
+ { { 50, 2 }, 0x190 }, //
+ { { 52, 2 }, 0x190 }, //
+ { { 54, 2 }, 0x190 }, //
+ { { 56, 1 }, 0x000 }, //
+ { { 57, 1 }, 0x000 }, //
+};
+
+static const RBTokResult expTokMiscNLLT_57Loop[] = { // 36 tokens
+ { { 0, 1 }, 0x064 }, //
+ { { 1, 1 }, 0x000 }, //
+ { { 2, 4 }, 0x0C8 }, //
+ { { 6, 1 }, 0x000 }, //
+ { { 7, 5 }, 0x0C8 }, //
+ { { 12, 1 }, 0x014 }, //
+ { { 13, 1 }, 0x000 }, //
+ { { 14, 1 }, 0x064 }, //
+ { { 15, 1 }, 0x0C8 }, //
+ { { 16, 1 }, 0x000 }, //
+ { { 17, 2 }, 0x064 }, //
+ { { 19, 1 }, 0x0C8 }, //
+ { { 20, 1 }, 0x000 }, //
+ { { 21, 1 }, 0x190 }, //
+ { { 22, 1 }, 0x000 }, //
+ { { 23, 2 }, 0x000 }, //
+ { { 25, 2 }, 0x000 }, //
+ { { 27, 1 }, 0x000 }, //
+ { { 28, 6 }, 0x0C8 }, //
+ { { 34, 1 }, 0x000 }, //
+ { { 35, 2 }, 0x0C8 }, //
+ { { 37, 1 }, 0x000 }, //
+ { { 38, 1 }, 0x190 }, //
+ { { 39, 2 }, 0x000 }, //
+ { { 41, 2 }, 0x000 }, //
+ { { 43, 1 }, 0x000 }, //
+ { { 44, 1 }, 0x190 }, //
+ { { 45, 1 }, 0x000 }, //
+ { { 46, 1 }, 0x000 }, //
+ { { 47, 2 }, 0x000 }, //
+ { { 49, 1 }, 0x000 }, //
+ { { 50, 2 }, 0x000 }, //
+ { { 52, 2 }, 0x000 }, //
+ { { 54, 2 }, 0x000 }, //
+ { { 56, 1 }, 0x000 }, //
+ { { 57, 1 }, 0x000 }, //
+};
+
+static const RBTokResult expTokMiscStdW[] = { // 36 tokens
+ { { 0, 1 }, 0x064 }, //
+ { { 1, 1 }, 0x000 }, //
+ { { 2, 4 }, 0x0C8 }, //
+ { { 6, 1 }, 0x000 }, //
+ { { 7, 5 }, 0x0C8 }, //
+ { { 12, 1 }, 0x000 }, // 0x014 for NLLT
+ { { 13, 1 }, 0x000 }, //
+ { { 14, 1 }, 0x064 }, //
+ { { 15, 1 }, 0x0C8 }, //
+ { { 16, 1 }, 0x000 }, //
+ { { 17, 2 }, 0x064 }, //
+ { { 19, 1 }, 0x0C8 }, //
+ { { 20, 1 }, 0x000 }, //
+ { { 21, 1 }, 0x190 }, //
+ { { 22, 1 }, 0x190 }, //
+ { { 23, 2 }, 0x190 }, //
+ { { 25, 2 }, 0x190 }, //
+ { { 27, 1 }, 0x000 }, //
+ { { 28, 6 }, 0x0C8 }, //
+ { { 34, 1 }, 0x000 }, //
+ { { 35, 2 }, 0x0C8 }, //
+ { { 37, 1 }, 0x000 }, //
+ { { 38, 1 }, 0x190 }, //
+ { { 39, 2 }, 0x190 }, //
+ { { 41, 2 }, 0x190 }, //
+ { { 43, 1 }, 0x000 }, //
+ { { 44, 1 }, 0x190 }, //
+ { { 45, 1 }, 0x190 }, //
+ { { 46, 1 }, 0x190 }, //
+ { { 47, 2 }, 0x190 }, //
+ { { 49, 1 }, 0x190 }, //
+ { { 50, 2 }, 0x190 }, //
+ { { 52, 2 }, 0x190 }, //
+ { { 54, 2 }, 0x190 }, //
+ { { 56, 1 }, 0x000 }, //
+ { { 57, 1 }, 0x000 }, //
+};
+
+static const UChar tokTextJpan[] = {
+ 0x30B3,0x30F3,0x30D4,0x30E5,0x30FC,0x30BF,0x30FC, // {{ 0, 7 }, 400 }
+ 0x306F, // {{ 7, 1 }, 400 }
+ 0x3001, // {{ 8, 1 }, 0 } 、
+ 0x672C,0x8CEA, // {{ 9, 2 }, 400 }
+ 0x7684, // {{ 11, 1 }, 400 }
+ 0x306B, // {{ 12, 1 }, 400 }
+ 0x306F, // {{ 13, 1 }, 400 }
+ 0x6570,0x5B57, // {{ 14, 2 }, 400 }
+ 0x3057,0x304B, // {{ 16, 2 }, 400 }
+ 0x6271,0x3046, // {{ 18, 2 }, 400 }
+ 0x3053,0x3068, // {{ 20, 2 }, 400 }
+ 0x304C, // {{ 22, 1 }, 400 }
+ 0x3067,0x304D, // {{ 23, 2 }, 400 }
+ 0x307E, // {{ 25, 1 }, 400 }
+ 0x305B,0x3093, // {{ 26, 2 }, 400 }
+ 0x3002, // {{ 28, 1 }, 0 } 。
+ 0x30B3,0x30F3,0x30D4,0x30E5,0x30FC,0x30BF,0x30FC, // {{ 29, 7 }, 400 }
+ 0x306F, // {{ 36, 1 }, 400 }
+ 0x3001, // {{ 37, 1 }, 0 } 、
+ 0x6587,0x5B57, // {{ 38, 2 }, 400 }
+ 0x3084, // {{ 40, 1 }, 400 }
+ 0x8A18,0x53F7, // {{ 41, 2 }, 400 }
+ 0x306A,0x3069, // {{ 43, 2 }, 400 }
+ 0x306E, // {{ 45, 1 }, 400 }
+ 0x305D,0x308C,0x305E,0x308C,0x306B, // {{ 46, 5 }, 400 }
+ 0x756A,0x53F7, // {{ 51, 2 }, 400 }
+ 0x3092, // {{ 53, 1 }, 400 }
+ 0x5272,0x308A,0x632F,0x308B, // {{ 54, 4 }, 400 }
+ 0x3053,0x3068, // {{ 58, 2 }, 400 }
+ 0x306B,0x3088,0x3063,0x3066, // {{ 60, 4 }, 400 }
+ 0x6271,0x3048,0x308B, // {{ 64, 3 }, 400 }
+ 0x3088,0x3046, // {{ 67, 2 }, 400 }
+ 0x306B,0x3057, // {{ 69, 2 }, 400 }
+ 0x307E,0x3059, // {{ 71, 2 }, 400 }
+ 0x3002, // {{ 73, 1 }, 0 } 。
+ 0x30E6,0x30CB, // {{ 74, 2 }, 400 }
+ 0x30B3,0x30FC,0x30C9, // {{ 76, 3 }, 400 }
+ 0x304C, // {{ 79, 1 }, 400 }
+ 0x51FA,0x6765,0x308B, // {{ 80, 3 }, 400 }
+ 0x307E,0x3067, // {{ 83, 2 }, 400 }
+ 0x306F, // {{ 85, 1 }, 400 }
+ 0x3001, // {{ 86, 1 }, 0 } 、
+ 0x3053,0x308C,0x3089,0x306E, // {{ 87, 4 }, 400 }
+ 0x756A,0x53F7, // {{ 91, 2 }, 400 }
+ 0x3092, // {{ 93, 1 }, 400 }
+ 0x5272,0x308A,0x632F,0x308B, // {{ 94, 4 }, 400 }
+ 0x4ED5,0x7D44,0x307F, // {{ 98, 3 }, 400 }
+ 0x304C, // {{ 101, 1 }, 400 }
+ 0x767E, // {{ 102, 1 }, 400 }
+ 0x7A2E,0x985E, // {{ 103, 2 }, 400 }
+ 0x3082, // {{ 105, 1 }, 400 }
+ 0x5B58,0x5728, // {{ 106, 2 }, 400 }
+ 0x3057,0x307E, // {{ 108, 2 }, 400 }
+ 0x3057,0x305F, // {{ 110, 2 }, 400 }
+ 0x3002, // {{ 112, 1 }, 0 } 。
+ 0
+};
+
+static const RBTokResult expTokJpanCFST[] = { // 1 token (??)
+ // ranges flags text
+ {{ 0, 113 }, 0x40000120 },
+};
+
+static const RBTokResult expTokJpan[] = { // 55 tokens
+ // ranges flags text
+ {{ 0, 7 }, 400 },
+ {{ 7, 1 }, 400 },
+ {{ 8, 1 }, 0 }, // 、
+ {{ 9, 2 }, 400 },
+ {{ 11, 1 }, 400 },
+ {{ 12, 1 }, 400 },
+ {{ 13, 1 }, 400 },
+ {{ 14, 2 }, 400 },
+ {{ 16, 2 }, 400 },
+ {{ 18, 2 }, 400 },
+ {{ 20, 2 }, 400 },
+ {{ 22, 1 }, 400 },
+ {{ 23, 2 }, 400 },
+ {{ 25, 1 }, 400 },
+ {{ 26, 2 }, 400 },
+ {{ 28, 1 }, 0 }, // 。
+ {{ 29, 7 }, 400 },
+ {{ 36, 1 }, 400 },
+ {{ 37, 1 }, 0 }, // 、
+ {{ 38, 2 }, 400 },
+ {{ 40, 1 }, 400 },
+ {{ 41, 2 }, 400 },
+ {{ 43, 2 }, 400 },
+ {{ 45, 1 }, 400 },
+ {{ 46, 5 }, 400 },
+ {{ 51, 2 }, 400 },
+ {{ 53, 1 }, 400 },
+ {{ 54, 4 }, 400 },
+ {{ 58, 2 }, 400 },
+ {{ 60, 4 }, 400 },
+ {{ 64, 3 }, 400 },
+ {{ 67, 2 }, 400 },
+ {{ 69, 2 }, 400 },
+ {{ 71, 2 }, 400 },
+ {{ 73, 1 }, 0 }, // 。
+ {{ 74, 2 }, 400 },
+ {{ 76, 3 }, 400 },
+ {{ 79, 1 }, 400 },
+ {{ 80, 3 }, 400 },
+ {{ 83, 2 }, 400 },
+ {{ 85, 1 }, 400 },
+ {{ 86, 1 }, 0 }, // 、
+ {{ 87, 4 }, 400 },
+ {{ 91, 2 }, 400 },
+ {{ 93, 1 }, 400 },
+ {{ 94, 4 }, 400 },
+ {{ 98, 3 }, 400 },
+ {{ 101, 1 }, 400 },
+ {{ 102, 1 }, 400 },
+ {{ 103, 2 }, 400 },
+ {{ 105, 1 }, 400 },
+ {{ 106, 2 }, 400 },
+ {{ 108, 2 }, 400 },
+ {{ 110, 2 }, 400 },
+ {{ 112, 1 }, 0 }, // 。
+};
+
+static const RBTokResult expTokJpanNLLT_57Loop[] = { // 55 tokens
+ {{ 0, 7 }, 0x190 }, //
+ {{ 7, 1 }, 0x000 }, //
+ {{ 8, 1 }, 0x000 }, //
+ {{ 9, 2 }, 0x190 }, //
+ {{ 11, 1 }, 0x000 }, //
+ {{ 12, 1 }, 0x000 }, //
+ {{ 13, 1 }, 0x000 }, //
+ {{ 14, 2 }, 0x000 }, //
+ {{ 16, 2 }, 0x000 }, //
+ {{ 18, 2 }, 0x000 }, //
+ {{ 20, 2 }, 0x000 }, //
+ {{ 22, 1 }, 0x000 }, //
+ {{ 23, 2 }, 0x000 }, //
+ {{ 25, 1 }, 0x000 }, //
+ {{ 26, 2 }, 0x000 }, //
+ {{ 28, 1 }, 0x000 }, //
+ {{ 29, 7 }, 0x190 }, //
+ {{ 36, 1 }, 0x000 }, //
+ {{ 37, 1 }, 0x000 }, //
+ {{ 38, 2 }, 0x190 }, //
+ {{ 40, 1 }, 0x000 }, //
+ {{ 41, 2 }, 0x000 }, //
+ {{ 43, 2 }, 0x000 }, //
+ {{ 45, 1 }, 0x000 }, //
+ {{ 46, 5 }, 0x000 }, //
+ {{ 51, 2 }, 0x000 }, //
+ {{ 53, 1 }, 0x000 }, //
+ {{ 54, 4 }, 0x000 }, //
+ {{ 58, 2 }, 0x000 }, //
+ {{ 60, 4 }, 0x000 }, //
+ {{ 64, 3 }, 0x000 }, //
+ {{ 67, 2 }, 0x000 }, //
+ {{ 69, 2 }, 0x000 }, //
+ {{ 71, 2 }, 0x000 }, //
+ {{ 73, 1 }, 0x000 }, //
+ {{ 74, 2 }, 0x190 }, //
+ {{ 76, 3 }, 0x000 }, //
+ {{ 79, 1 }, 0x000 }, //
+ {{ 80, 3 }, 0x000 }, //
+ {{ 83, 2 }, 0x000 }, //
+ {{ 85, 1 }, 0x000 }, //
+ {{ 86, 1 }, 0x000 }, //
+ {{ 87, 4 }, 0x190 }, //
+ {{ 91, 2 }, 0x000 }, //
+ {{ 93, 1 }, 0x000 }, //
+ {{ 94, 4 }, 0x000 }, //
+ {{ 98, 3 }, 0x000 }, //
+ {{ 101, 1 }, 0x000 }, //
+ {{ 102, 1 }, 0x000 }, //
+ {{ 103, 2 }, 0x000 }, //
+ {{ 105, 1 }, 0x000 }, //
+ {{ 106, 2 }, 0x000 }, //
+ {{ 108, 2 }, 0x000 }, //
+ {{ 110, 2 }, 0x000 }, //
+ {{ 112, 1 }, 0x000 }, //
+};
+
+
+static const UChar tokTextThai[] = {
+ 0x55,0x6E,0x69,0x63,0x6F,0x64,0x65, // {{ 0, 7 }, 200 },
+ 0x20, // {{ 7, 1 }, 1 },
+ 0x0E04,0x0E37,0x0E2D, // {{ 8, 3 }, 200 },
+ 0x0E2D,0x0E30,0x0E44,0x0E23, // {{ 11, 4 }, 200 },
+ 0x3F, // {{ 15, 1 }, 0 },
+ 0x0A, // {{ 16, 1 }, 0 },
+ 0x55,0x6E,0x69,0x63,0x6F,0x64,0x65, // {{ 17, 7 }, 200 },
+ 0x20, // {{ 24, 1 }, 1 },
+ 0x0E01,0x0E33,0x0E2B,0x0E19,0x0E14, // {{ 25, 5 }, 200 },
+ 0x0E2B,0x0E21,0x0E32,0x0E22,0x0E40,0x0E25,0x0E02, // {{ 30, 7 }, 200 },
+ 0x0E40,0x0E09,0x0E1E,0x0E32,0x0E30, // {{ 37, 5 }, 200 },
+ 0x0E2A,0x0E33,0x0E2B,0x0E23,0x0E31,0x0E1A, // {{ 42, 6 }, 200 },
+ 0x0E17,0x0E38,0x0E01, // {{ 48, 3 }, 200 },
+ 0x0E2D,0x0E31,0x0E01,0x0E02,0x0E23,0x0E30, // {{ 51, 6 }, 200 },
+ 0x0A, // {{ 57, 1 }, 0 },
+ 0x0E42,0x0E14,0x0E22, // {{ 58, 3 }, 200 },
+ 0x0E44,0x0E21,0x0E48, // {{ 61, 3 }, 200 },
+ 0x0E2A,0x0E19,0x0E43,0x0E08, // {{ 64, 4 }, 200 },
+ 0x0E27,0x0E48,0x0E32, // {{ 68, 3 }, 200 },
+ 0x0E40,0x0E1B,0x0E47,0x0E19, // {{ 71, 4 }, 200 },
+ 0x0E41,0x0E1E, // {{ 75, 2 }, 200 },
+ 0x0E25,0x0E47,0x0E15, // {{ 77, 3 }, 200 },
+ 0x0E1F,0x0E2D,0x0E23,0x0E4C,0x0E21, // {{ 80, 5 }, 200 },
+ 0x0E43,0x0E14, // {{ 85, 2 }, 200 },
+ 0x0A, // {{ 87, 1 }, 0 },
+ 0x0E44,0x0E21,0x0E48, // {{ 88, 3 }, 200 },
+ 0x0E02,0x0E36,0x0E49,0x0E19, // {{ 91, 4 }, 200 },
+ 0x0E01,0x0E31,0x0E1A, // {{ 95, 3 }, 200 },
+ 0x0E27,0x0E48,0x0E32, // {{ 98, 3 }, 200 },
+ 0x0E08,0x0E30, // {{ 101, 2 }, 200 },
+ 0x0E40,0x0E1B,0x0E47,0x0E19, // {{ 103, 4 }, 200 },
+ 0x0E42,0x0E1B,0x0E23,0x0E41,0x0E01,0x0E23,0x0E21, // {{ 107, 7 }, 200 },
+ 0x0E43,0x0E14, // {{ 114, 2 }, 200 },
+ 0x0A, // {{ 116, 1 }, 0 },
+ 0x0E41,0x0E25,0x0E30, // {{ 117, 3 }, 200 },
+ 0x0E44,0x0E21,0x0E48, // {{ 120, 3 }, 200 },
+ 0x0E27,0x0E48,0x0E32, // {{ 123, 3 }, 200 },
+ 0x0E08,0x0E30, // {{ 126, 2 }, 200 },
+ 0x0E40,0x0E1B,0x0E47,0x0E19, // {{ 128, 4 }, 200 },
+ 0x0E20,0x0E32,0x0E29,0x0E32, // {{ 132, 4 }, 200 },
+ 0x0E43,0x0E14, // {{ 136, 2 }, 200 },
+ 0x0A, // {{ 138, 1 }, 0 },
+ 0
+};
+
+ static const RBTokResult expTokThaiCFST[] = { // 34 tokens
+ {{ 0, 7 }, 0x002 }, //
+ {{ 8, 3 }, 0x020 }, //
+ {{ 11, 5 }, 0x020 }, //
+ {{ 17, 7 }, 0x002 }, //
+ {{ 25, 5 }, 0x109 }, //
+ {{ 30, 7 }, 0x109 }, //
+ {{ 37, 5 }, 0x109 }, //
+ {{ 42, 6 }, 0x109 }, //
+ {{ 48, 3 }, 0x109 }, //
+ {{ 51, 6 }, 0x109 }, //
+ {{ 58, 3 }, 0x009 }, //
+ {{ 61, 3 }, 0x009 }, //
+ {{ 64, 4 }, 0x009 }, //
+ {{ 68, 3 }, 0x009 }, //
+ {{ 71, 4 }, 0x009 }, //
+ {{ 75, 2 }, 0x009 }, //
+ {{ 77, 3 }, 0x009 }, //
+ {{ 80, 5 }, 0x009 }, //
+ {{ 85, 2 }, 0x009 }, //
+ {{ 88, 3 }, 0x009 }, //
+ {{ 91, 4 }, 0x009 }, //
+ {{ 95, 3 }, 0x009 }, //
+ {{ 98, 3 }, 0x009 }, //
+ {{ 101, 2 }, 0x009 }, //
+ {{ 103, 4 }, 0x009 }, //
+ {{ 107, 7 }, 0x009 }, //
+ {{ 114, 2 }, 0x009 }, //
+ {{ 117, 3 }, 0x009 }, //
+ {{ 120, 3 }, 0x009 }, //
+ {{ 123, 3 }, 0x009 }, //
+ {{ 126, 2 }, 0x009 }, //
+ {{ 128, 4 }, 0x009 }, //
+ {{ 132, 4 }, 0x009 }, //
+ {{ 136, 2 }, 0x009 }, //
+};
+
+ static const RBTokResult expTokThaiCFST_57Loop[] = { // 34 tokens
+ {{ 0, 7 }, 0x002 }, //
+ {{ 8, 3 }, 0x020 }, //
+ {{ 11, 5 }, 0x000 }, //
+ {{ 17, 7 }, 0x002 }, //
+ {{ 25, 5 }, 0x109 }, //
+ {{ 30, 7 }, 0x000 }, //
+ {{ 37, 5 }, 0x000 }, //
+ {{ 42, 6 }, 0x000 }, //
+ {{ 48, 3 }, 0x000 }, //
+ {{ 51, 6 }, 0x000 }, //
+ {{ 58, 3 }, 0x009 }, //
+ {{ 61, 3 }, 0x000 }, //
+ {{ 64, 4 }, 0x000 }, //
+ {{ 68, 3 }, 0x000 }, //
+ {{ 71, 4 }, 0x000 }, //
+ {{ 75, 2 }, 0x000 }, //
+ {{ 77, 3 }, 0x000 }, //
+ {{ 80, 5 }, 0x000 }, //
+ {{ 85, 2 }, 0x000 }, //
+ {{ 88, 3 }, 0x009 }, //
+ {{ 91, 4 }, 0x000 }, //
+ {{ 95, 3 }, 0x000 }, //
+ {{ 98, 3 }, 0x000 }, //
+ {{ 101, 2 }, 0x000 }, //
+ {{ 103, 4 }, 0x000 }, //
+ {{ 107, 7 }, 0x000 }, //
+ {{ 114, 2 }, 0x000 }, //
+ {{ 117, 3 }, 0x009 }, //
+ {{ 120, 3 }, 0x000 }, //
+ {{ 123, 3 }, 0x000 }, //
+ {{ 126, 2 }, 0x000 }, //
+ {{ 128, 4 }, 0x000 }, //
+ {{ 132, 4 }, 0x000 }, //
+ {{ 136, 2 }, 0x000 }, //
+};
+
+static const RBTokResult expTokThai[] = { // 42 tokens
+ // ranges flags text
+ {{ 0, 7 }, 0xC8 }, // 0xC8 = 200
+ {{ 7, 1 }, 0x00 }, //
+ {{ 8, 3 }, 0xC8 },
+ {{ 11, 4 }, 0xC8 },
+ {{ 15, 1 }, 0x00 }, //
+ {{ 16, 1 }, 0x00 }, //
+ {{ 17, 7 }, 0xC8 },
+ {{ 24, 1 }, 0x00 }, //
+ {{ 25, 5 }, 0xC8 },
+ {{ 30, 7 }, 0xC8 },
+ {{ 37, 5 }, 0xC8 },
+ {{ 42, 6 }, 0xC8 },
+ {{ 48, 3 }, 0xC8 },
+ {{ 51, 6 }, 0xC8 },
+ {{ 57, 1 }, 0x00 }, //
+ {{ 58, 3 }, 0xC8 },
+ {{ 61, 3 }, 0xC8 },
+ {{ 64, 4 }, 0xC8 },
+ {{ 68, 3 }, 0xC8 },
+ {{ 71, 4 }, 0xC8 },
+ {{ 75, 2 }, 0xC8 },
+ {{ 77, 3 }, 0xC8 },
+ {{ 80, 5 }, 0xC8 },
+ {{ 85, 2 }, 0xC8 },
+ {{ 87, 1 }, 0x00 }, //
+ {{ 88, 3 }, 0xC8 },
+ {{ 91, 4 }, 0xC8 },
+ {{ 95, 3 }, 0xC8 },
+ {{ 98, 3 }, 0xC8 },
+ {{ 101, 2 }, 0xC8 },
+ {{ 103, 4 }, 0xC8 },
+ {{ 107, 7 }, 0xC8 },
+ {{ 114, 2 }, 0xC8 },
+ {{ 116, 1 }, 0x00 }, //
+ {{ 117, 3 }, 0xC8 },
+ {{ 120, 3 }, 0xC8 },
+ {{ 123, 3 }, 0xC8 },
+ {{ 126, 2 }, 0xC8 },
+ {{ 128, 4 }, 0xC8 },
+ {{ 132, 4 }, 0xC8 },
+ {{ 136, 2 }, 0xC8 },
+ {{ 138, 1 }, 0x00 }, //
+};
+
+static const RBTokResult expTokThaiNLLT_57Loop[] = { // 42 tokens
+ {{ 0, 7 }, 0xC8 }, // 0xC8 = 200
+ {{ 7, 1 }, 0x00 }, //
+ {{ 8, 3 }, 0xC8 }, //
+ {{ 11, 4 }, 0x00 }, //
+ {{ 15, 1 }, 0x00 }, //
+ {{ 16, 1 }, 0x00 }, //
+ {{ 17, 7 }, 0xC8 }, //
+ {{ 24, 1 }, 0x00 }, //
+ {{ 25, 5 }, 0xC8 }, //
+ {{ 30, 7 }, 0x00 }, //
+ {{ 37, 5 }, 0x00 }, //
+ {{ 42, 6 }, 0x00 }, //
+ {{ 48, 3 }, 0x00 }, //
+ {{ 51, 6 }, 0x00 }, //
+ {{ 57, 1 }, 0x00 }, //
+ {{ 58, 3 }, 0xC8 }, //
+ {{ 61, 3 }, 0x00 }, //
+ {{ 64, 4 }, 0x00 }, //
+ {{ 68, 3 }, 0x00 }, //
+ {{ 71, 4 }, 0x00 }, //
+ {{ 75, 2 }, 0x00 }, //
+ {{ 77, 3 }, 0x00 }, //
+ {{ 80, 5 }, 0x00 }, //
+ {{ 85, 2 }, 0x00 }, //
+ {{ 87, 1 }, 0x00 }, //
+ {{ 88, 3 }, 0xC8 }, //
+ {{ 91, 4 }, 0x00 }, //
+ {{ 95, 3 }, 0x00 }, //
+ {{ 98, 3 }, 0x00 }, //
+ {{ 101, 2 }, 0x00 }, //
+ {{ 103, 4 }, 0x00 }, //
+ {{ 107, 7 }, 0x00 }, //
+ {{ 114, 2 }, 0x00 }, //
+ {{ 116, 1 }, 0x00 }, //
+ {{ 117, 3 }, 0xC8 }, //
+ {{ 120, 3 }, 0x00 }, //
+ {{ 123, 3 }, 0x00 }, //
+ {{ 126, 2 }, 0x00 }, //
+ {{ 128, 4 }, 0x00 }, //
+ {{ 132, 4 }, 0x00 }, //
+ {{ 136, 2 }, 0x00 }, //
+ {{ 138, 1 }, 0x00 }, //
+};
+
+
+typedef struct {
+ const char* descrip;
+ const UChar* tokText; // zero-terminated text
+ const RBTokResult* expTok;
+ int32_t expTokLen;
+ const RBTokResult* expTokFile;
+ int32_t expTokFileLen;
+ const RBTokResult* expTok57Loop; // Actual urbtok results in ICU 59 for this test
+ int32_t expTok57LoopLen; // Actual urbtok results in ICU 59 for this test
+ const RBTokResult* expTok57Bulk; // Actual urbtok results in ICU 59 for this test
+ int32_t expTok57BulkLen; // Actual urbtok results in ICU 59 for this test
+} TokTextAndResults;
+
+static const TokTextAndResults tokTextAndResCFST[] = {
+ { "CFST/Latn", tokTextLatn, expTokLatnCFST, UPRV_LENGTHOF(expTokLatnCFST), expTokLatnCFST, UPRV_LENGTHOF(expTokLatnCFST), expTokLatnCFST, UPRV_LENGTHOF(expTokLatnCFST), expTokLatnCFST, UPRV_LENGTHOF(expTokLatnCFST) },
+ { "CFST/Misc", tokTextMisc, expTokMiscCFST, UPRV_LENGTHOF(expTokMiscCFST), expTokMiscCFST, UPRV_LENGTHOF(expTokMiscCFST), expTokMiscCFST, UPRV_LENGTHOF(expTokMiscCFST), expTokMiscCFST_57Bulk, UPRV_LENGTHOF(expTokMiscCFST_57Bulk) },
+ { "CFST/Jpan", tokTextJpan, expTokJpanCFST, UPRV_LENGTHOF(expTokJpanCFST), expTokJpanCFST, UPRV_LENGTHOF(expTokJpanCFST), expTokJpanCFST, UPRV_LENGTHOF(expTokJpanCFST), expTokJpanCFST, UPRV_LENGTHOF(expTokJpanCFST) },
+ { "CFST/Thai", tokTextThai, expTokThaiCFST, UPRV_LENGTHOF(expTokThaiCFST), expTokThaiCFST, UPRV_LENGTHOF(expTokThaiCFST), expTokThaiCFST_57Loop, UPRV_LENGTHOF(expTokThaiCFST_57Loop), expTokThaiCFST, UPRV_LENGTHOF(expTokThaiCFST) },
+ { NULL, NULL, NULL, 0, NULL, 0, NULL, 0 }
+};
+
+static const TokTextAndResults tokTextAndResNLLT[] = {
+ { "NLLT/Latn", tokTextLatn, expTokLatnNLLT, UPRV_LENGTHOF(expTokLatnNLLT), expTokLatnNLLT_File, UPRV_LENGTHOF(expTokLatnNLLT_File), expTokLatnNLLT_57, UPRV_LENGTHOF(expTokLatnNLLT_57), expTokLatnNLLT_57, UPRV_LENGTHOF(expTokLatnNLLT_57)},
+ { "NLLT/Misc", tokTextMisc, expTokMiscNLLT, UPRV_LENGTHOF(expTokMiscNLLT), expTokMiscNLLT, UPRV_LENGTHOF(expTokMiscNLLT), expTokMiscNLLT_57Loop, UPRV_LENGTHOF(expTokMiscNLLT_57Loop), expTokMiscNLLT, UPRV_LENGTHOF(expTokMiscNLLT)},
+ { "NLLT/Jpan", tokTextJpan, expTokJpan, UPRV_LENGTHOF(expTokJpan), expTokJpan, UPRV_LENGTHOF(expTokJpan), expTokJpanNLLT_57Loop, UPRV_LENGTHOF(expTokJpanNLLT_57Loop), expTokJpan, UPRV_LENGTHOF(expTokJpan) },
+ { "NLLT/Thai", tokTextThai, expTokThai, UPRV_LENGTHOF(expTokThai), expTokThai, UPRV_LENGTHOF(expTokThai), expTokThaiNLLT_57Loop, UPRV_LENGTHOF(expTokThaiNLLT_57Loop), expTokThai, UPRV_LENGTHOF(expTokThai) },
+ { NULL, NULL, NULL, 0, NULL, 0, NULL, 0 }
+};
+
+static const TokTextAndResults tokTextAndResStdW[] = {
+ { "StdW/Latn", tokTextLatn, expTokLatnStdW, UPRV_LENGTHOF(expTokLatnStdW), expTokLatnStdW, UPRV_LENGTHOF(expTokLatnStdW), expTokLatnStdW, UPRV_LENGTHOF(expTokLatnStdW), expTokLatnStdW, UPRV_LENGTHOF(expTokLatnStdW) },
+ { "StdW/Misc", tokTextMisc, expTokMiscStdW, UPRV_LENGTHOF(expTokMiscStdW), expTokMiscStdW, UPRV_LENGTHOF(expTokMiscStdW), expTokMiscStdW, UPRV_LENGTHOF(expTokMiscStdW), expTokMiscStdW, UPRV_LENGTHOF(expTokMiscStdW) },
+ { "StdW/Jpan", tokTextJpan, expTokJpan, UPRV_LENGTHOF(expTokJpan), expTokJpan, UPRV_LENGTHOF(expTokJpan), expTokJpan, UPRV_LENGTHOF(expTokJpan), expTokJpan, UPRV_LENGTHOF(expTokJpan) },
+ { "StdW/Thai", tokTextThai, expTokThai, UPRV_LENGTHOF(expTokThai), expTokThai, UPRV_LENGTHOF(expTokThai), expTokThai, UPRV_LENGTHOF(expTokThai), expTokThai, UPRV_LENGTHOF(expTokThai) },
+ { NULL, NULL, NULL, 0, NULL, 0, NULL, 0 }
+};
+
+typedef struct {
+ const char* descrip;
+ const char* rulesSource; // relative to cintltst directory; UTF8 rule source; NULL for std word rules
+ const char* rulesBin; // relative to cintltst directory; current binary version
+ const char* rulesBin57; // relative to cintltst directory; ICU 57 binary version
+ const TokTextAndResults* textAndResults;
+} TokRulesAndTests;
+
+static const TokRulesAndTests tokRulesTests[] = { // icu60 binary files invalid in ICU 62
+ { "CFST", "../testdata/tokCFSTrules.txt", NULL,/*tokCFSTrulesLE_icu60.data invalid*/ "../testdata/tokCFSTrulesLE_icu57.data", tokTextAndResCFST },
+ { "NLLT", "../testdata/wordNLLTu8.txt", NULL,/*wordNLLT_icu60.dat invalid */ "../testdata/wordNLLT_icu57.dat", tokTextAndResNLLT },
+ { "StdW", "../../data/brkitr/rules/word.txt", NULL, NULL, tokTextAndResStdW },
+ { "WORD", NULL, NULL, NULL, tokTextAndResStdW },
+ { NULL, NULL, NULL, NULL, NULL }
+};
+
+enum {
+ kMaxTokens = 96
+};
+
+// read data from file into a malloc'ed buf, which must be freed by caller.
+// returns NULL if error.
+static void* dataBufFromFile(const char* path, long* dataBufSizeP) {
+ FILE * dataFile;
+ void * dataBuf;
+ long dataBufSize, dataFileRead = 0;
+
+ if (dataBufSizeP) {
+ *dataBufSizeP = 0;
+ }
+ dataFile = fopen(path, "r");
+ if (dataFile == NULL) {
+ log_data_err("FAIL: for %s, fopen fails\n", path);
+ return NULL;
+ }
+ fseek(dataFile, 0, SEEK_END);
+ dataBufSize = ftell(dataFile);
+ rewind(dataFile);
+
+ dataBuf = uprv_malloc(dataBufSize);
+ if (dataBuf != NULL) {
+ dataFileRead = fread(dataBuf, 1, dataBufSize, dataFile);
+ }
+ fclose(dataFile);
+ if (dataBuf == NULL) {
+ log_data_err("FAIL: for %s, uprv_malloc fails for dataBuf[%ld]\n", path, dataBufSize);
+ return NULL;
+ }
+ if (dataFileRead < dataBufSize) {
+ log_data_err("FAIL: for %s, fread fails, read %ld of %ld\n", path, dataFileRead, dataBufSize);
+ uprv_free(dataBuf);
+ return NULL;
+ }
+ if (dataBufSizeP) {
+ *dataBufSizeP = dataBufSize;
+ }
+ return dataBuf;
+}
+
+static void handleTokResults(const char* testItem, const char* tokClass, const char* ruleSource, const char* algType,
+ uint64_t duration, int32_t expTokLen, const RBTokResult* expTokRes,
+ int32_t getTokLen, RuleBasedTokenRange* getTokens, unsigned long *getFlags) {
+ int32_t iToken;
+ UBool fail = (getTokLen != expTokLen);
+ for (iToken = 0; !fail && iToken < getTokLen; iToken++) {
+ if ( getTokens[iToken].location != expTokRes[iToken].token.location || getTokens[iToken].length != expTokRes[iToken].token.length ||
+ getFlags[iToken] != expTokRes[iToken].flags ) {
+ fail = TRUE;
+ }
+ }
+ if (fail) {
+ log_err("FAIL: %s %s %s %s expected %d tokens, got %d\n", testItem, tokClass, ruleSource, algType, expTokLen, getTokLen);
+ printf("# expect get\n");
+ printf("# loc len flags loc len flags\n");
+ int32_t maxTokens = (getTokLen >= expTokLen)? getTokLen: expTokLen;
+ for (iToken = 0; iToken < maxTokens; iToken++) {
+ if (iToken < expTokLen) {
+ printf(" %3ld %3ld 0x%-8lX", expTokRes[iToken].token.location,
+ expTokRes[iToken].token.length, expTokRes[iToken].flags);
+ } else {
+ printf(" ");
+ }
+ if (iToken < getTokLen) {
+ printf(" %3ld %3ld 0x%-8lX\n", getTokens[iToken].location, getTokens[iToken].length, getFlags[iToken] );
+ } else {
+ printf("\n");
+ }
+ }
+ } else {
+ log_info("%s %s %s %s get %d tokens, nsec %llu\n", testItem, tokClass, ruleSource, algType, getTokLen, duration);
+ }
+}
+
+static void TestRuleBasedTokenizer(void) {
+ const TokRulesAndTests* ruleTypePtr;
+#if !U_PLATFORM_HAS_WIN32_API
+ uint64_t start, duration;
+#else
+ unsigned long long start, duration;
+#endif
+#if U_PLATFORM_IS_DARWIN_BASED
+ mach_timebase_info_data_t info;
+
+ mach_timebase_info(&info);
+#endif
+ for (ruleTypePtr = tokRulesTests; ruleTypePtr->descrip != NULL; ruleTypePtr++) {
+ UBreakIterator* ubrkFromSource = NULL;
+ UBreakIterator* ubrkBinFromSource = NULL;
+ UBreakIterator* utokFromSource = NULL;
+ UBreakIterator* utokBinFromSource = NULL;
+ UBreakIterator* utokBinFromFile = NULL;
+ UBreakIterator* utok57FromSource = NULL;
+ UBreakIterator* utok57BinFromSource = NULL;
+ UBreakIterator* utok57BinFromFile = NULL;
+ uint8_t* ubrkBinRules = NULL; // these must be retained while ubrkBinFromSource is open
+ UErrorCode status = U_ZERO_ERROR;
+
+ log_info("- starting tests for rule type %s\n", ruleTypePtr->descrip);
+
+ // Get UBreakIterators
+ if (ruleTypePtr->rulesSource == NULL) {
+ // use standard WORD rules for root
+ start = GET_START();
+ ubrkFromSource = ubrk_open(UBRK_WORD, "root", NULL, 0, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: ubrk_open WORD for root, status: %s\n", u_errorName(status));
+ } else {
+ log_info(" ubrk_open nsec %llu\n", duration);
+ int32_t rulesBinFromStdSize = ubrk_getBinaryRules(ubrkFromSource, NULL, 0, &status);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: ubrk_getBinaryRules preflight status: %s, rulesBinFromStdSize %d\n", u_errorName(status), rulesBinFromStdSize);
+ } else {
+ ubrkBinRules = (uint8_t *)uprv_malloc(rulesBinFromStdSize);
+ if (ubrkBinRules == NULL) {
+ log_data_err("FAIL: uprv_malloc fails for ubrkBinRules[%d]\n", rulesBinFromStdSize);
+ } else {
+ start = GET_START();
+ rulesBinFromStdSize = ubrk_getBinaryRules(ubrkFromSource, ubrkBinRules, rulesBinFromStdSize, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: ubrk_getBinaryRules status: %s, rulesBinFromStdSize %d\n", u_errorName(status), rulesBinFromStdSize);
+ } else {
+ log_info(" ubrk_getBinaryRules size %d, nsec %llu\n", rulesBinFromStdSize, duration);
+
+ status = U_ZERO_ERROR;
+ start = GET_START();
+ // ubrk_openBinaryRules does not copy the binary rules, they must be kept around while ubrkBinFromSource is open
+ ubrkBinFromSource = ubrk_openBinaryRules(ubrkBinRules, rulesBinFromStdSize, NULL, 0, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: ubrk_openBinaryRules status: %s\n", u_errorName(status));
+ } else {
+ log_info(" ubrk_openBinaryRules nsec %llu\n", duration);
+ }
+
+ status = U_ZERO_ERROR;
+ start = GET_START();
+ utokBinFromSource = urbtok_openBinaryRules(ubrkBinRules, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok_openBinaryRules status: %s\n", u_errorName(status));
+ } else {
+ log_info(" urbtok_openBinaryRules nsec %llu\n", duration);
+ }
+
+ status = U_ZERO_ERROR;
+ utok57BinFromSource = urbtok57_openBinaryRules(ubrkBinRules, &status);
+ if (U_SUCCESS(status)) {
+ log_err("FAIL: urbtok57_openBinaryRules with new rules succeeded but should have failed\n");
+ ubrk_close(utok57BinFromSource);
+ utok57BinFromSource = NULL;
+ }
+ }
+ // ubrkBinRules is freed at the end of the main loop
+ }
+ }
+ }
+ status = U_ZERO_ERROR;
+ start = GET_START();
+ utokFromSource = urbtok_open(UBRK_WORD, "root", &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok_open WORD for root, status: %s\n", u_errorName(status));
+ } else {
+ log_info(" urbtok_open nsec %llu\n", duration);
+ }
+ } else {
+ // use source rules, including custom rules from CoreNLP
+ int32_t rulesUTF16Size;
+ UChar* rulesUTF16Buf = NULL;
+ long rulesUTF8Size;
+ char * rulesUTF8Buf = (char *)dataBufFromFile(ruleTypePtr->rulesSource, &rulesUTF8Size);
+ // dataBufFromFile already logged any errors leading to NULL return
+ if (rulesUTF8Buf) {
+ long rulesUTF8Offset = 0;
+ /* Handle UTF8 BOM: */
+ if (uprv_strncmp(rulesUTF8Buf, "\xEF\xBB\xBF", 3) == 0) {
+ rulesUTF8Offset = 3;
+ rulesUTF8Size -= rulesUTF8Offset;
+ }
+ u_strFromUTF8(NULL, 0, &rulesUTF16Size, rulesUTF8Buf+rulesUTF8Offset, rulesUTF8Size, &status); /* preflight */
+ if (status == U_BUFFER_OVERFLOW_ERROR) { /* expected for preflight */
+ status = U_ZERO_ERROR;
+ }
+ if (U_FAILURE(status)) {
+ log_data_err("FAIL: for %s, u_strFromUTF8 preflight fails: %s\n", ruleTypePtr->rulesSource, u_errorName(status));
+ } else {
+ rulesUTF16Buf = (UChar *)uprv_malloc(rulesUTF16Size*sizeof(UChar));
+ if (rulesUTF16Buf == NULL) {
+ log_data_err("FAIL: for %s, uprv_malloc fails for rulesUTF16Buf[%ld]\n", ruleTypePtr->rulesSource, rulesUTF16Size*sizeof(UChar));
+ } else {
+ u_strFromUTF8(rulesUTF16Buf, rulesUTF16Size, &rulesUTF16Size, rulesUTF8Buf+rulesUTF8Offset, rulesUTF8Size, &status);
+ if (U_FAILURE(status)) {
+ log_data_err("FAIL: for %s, u_strFromUTF8 fails: %s\n", ruleTypePtr->rulesSource, u_errorName(status));
+ uprv_free(rulesUTF16Buf);
+ rulesUTF16Buf = NULL;
+ }
+ }
+ }
+ uprv_free(rulesUTF8Buf);
+ }
+ if (rulesUTF16Buf) {
+ UParseError parseErr;
+
+ status = U_ZERO_ERROR;
+ start = GET_START();
+ ubrkFromSource = ubrk_openRules(rulesUTF16Buf, rulesUTF16Size, NULL, 0, &parseErr, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: ubrk_openRules %s status: %s, line %d, col %d\n", ruleTypePtr->rulesSource, u_errorName(status), parseErr.line, parseErr.offset);
+ } else {
+ log_info(" ubrk_openRules nsec %llu\n", duration);
+ }
+
+ status = U_ZERO_ERROR;
+ start = GET_START();
+ utokFromSource = urbtok_openRules(rulesUTF16Buf, rulesUTF16Size, &parseErr, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok_openRules %s status: %s, line %d, col %d\n", ruleTypePtr->rulesSource, u_errorName(status), parseErr.line, parseErr.offset);
+ } else {
+ log_info(" urbtok_openRules nsec %llu\n", duration);
+ }
+
+ status = U_ZERO_ERROR;
+ start = GET_START();
+ utok57FromSource = urbtok57_openRules(rulesUTF16Buf, rulesUTF16Size, &parseErr, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ if (ruleTypePtr->rulesBin57) {
+ // Have binary, source should word
+ log_err("FAIL: urbtok57_openRules %s status: %s, line %d, col %d\n", ruleTypePtr->rulesSource, u_errorName(status), parseErr.line, parseErr.offset);
+ } else {
+ // Source may use new syntax not compatible with urbtok57
+ log_info(" urbtok57_openRules cannot handle %s, status: %s, line %d, col %d\n", ruleTypePtr->rulesSource, u_errorName(status), parseErr.line, parseErr.offset);
+ }
+ } else {
+ log_info(" urbtok57_openRules nsec %llu\n", duration);
+ }
+
+ uprv_free(rulesUTF16Buf);
+ }
+ if (ubrkFromSource) {
+ status = U_ZERO_ERROR;
+ int32_t rulesBinFromSourceSize = ubrk_getBinaryRules(ubrkFromSource, NULL, 0, &status);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: ubrk_getBinaryRules preflight status: %s, rulesBinFromSourceSize %d\n", u_errorName(status), rulesBinFromSourceSize);
+ } else {
+ ubrkBinRules = (uint8_t *)uprv_malloc(rulesBinFromSourceSize);
+ if (ubrkBinRules == NULL) {
+ log_data_err("FAIL: uprv_malloc fails for ubrk ubrkBinRules[%d]\n", rulesBinFromSourceSize);
+ } else {
+ start = GET_START();
+ rulesBinFromSourceSize = ubrk_getBinaryRules(ubrkFromSource, ubrkBinRules, rulesBinFromSourceSize, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: ubrk_getBinaryRules status: %s, rulesBinFromSourceSize %d\n", u_errorName(status), rulesBinFromSourceSize);
+ } else {
+ log_info(" ubrk_getBinaryRules size %d, nsec %llu\n", rulesBinFromSourceSize, duration);
+
+ start = GET_START();
+ // ubrk_openBinaryRules does not copy the binary rules, they must be kept around while ubrkBinFromSource is open
+ ubrkBinFromSource = ubrk_openBinaryRules(ubrkBinRules, rulesBinFromSourceSize, NULL, 0, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: ubrk_openBinaryRules status: %s\n", u_errorName(status));
+ } else {
+ log_info(" ubrk_openBinaryRules nsec %llu\n", duration);
+ }
+ }
+ // ubrkBinRules is freed at the end of the main loop
+ }
+ }
+ }
+
+ if (utokFromSource) {
+ status = U_ZERO_ERROR;
+ int32_t rulesBinFromSourceSize = urbtok_getBinaryRules(utokFromSource, NULL, 0, &status);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok_getBinaryRules preflight status: %s, rulesBinFromSourceSize %d\n", u_errorName(status), rulesBinFromSourceSize);
+ } else {
+ uint8_t* rulesBinFromSource = (uint8_t *)uprv_malloc(rulesBinFromSourceSize);
+ if (rulesBinFromSource == NULL) {
+ log_data_err("FAIL: uprv_malloc fails for urbtok rulesBinFromSource[%d]\n", rulesBinFromSourceSize);
+ } else {
+ start = GET_START();
+ rulesBinFromSourceSize = urbtok_getBinaryRules(utokFromSource, rulesBinFromSource, rulesBinFromSourceSize, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok_getBinaryRules status: %s, rulesBinFromSourceSize %d\n", u_errorName(status), rulesBinFromSourceSize);
+ } else {
+ log_info(" urbtok_getBinaryRules size %d, nsec %llu\n", rulesBinFromSourceSize, duration);
+
+ status = U_ZERO_ERROR;
+ start = GET_START();
+ // ubrk_openBinaryRules does copy the binary rules, they can be freed at the end of this block
+ utokBinFromSource = urbtok_openBinaryRules(rulesBinFromSource, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok_openBinaryRules from source status: %s\n", u_errorName(status));
+ } else {
+ log_info(" urbtok_openBinaryRules from source nsec %llu\n", duration);
+ }
+
+ status = U_ZERO_ERROR;
+ utok57BinFromSource = urbtok57_openBinaryRules(rulesBinFromSource, &status);
+ if (U_SUCCESS(status)) {
+ log_err("FAIL: urbtok57_openBinaryRules with new rules succeeded but should have failed\n");
+ ubrk_close(utok57BinFromSource);
+ utok57BinFromSource = NULL;
+ }
+
+ if (ruleTypePtr->rulesBin) {
+ long rulesBinSize;
+ uint8_t* rulesBinBuf = (uint8_t*)dataBufFromFile(ruleTypePtr->rulesBin, &rulesBinSize);
+ // dataBufFromFile already logged any errors leading to NULL return
+ if (rulesBinBuf) {
+ log_info(" get urbtok binary rules from file, rulesBinSize %d\n", rulesBinSize);
+ status = U_ZERO_ERROR;
+ start = GET_START();
+ utokBinFromFile = urbtok_openBinaryRules(rulesBinBuf, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok_openBinaryRules from file status: %s\n", u_errorName(status));
+ } else {
+ log_info(" urbtok_openBinaryRules from file nsec %llu\n", duration);
+ }
+ uprv_free(rulesBinBuf);
+ }
+ }
+ }
+ uprv_free(rulesBinFromSource);
+ }
+ }
+ }
+
+ if (utok57FromSource) {
+ status = U_ZERO_ERROR;
+ int32_t rulesBinFromSourceSize = urbtok57_getBinaryRules(utok57FromSource, NULL, 0, &status);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok57_getBinaryRules preflight status: %s, rulesBinFromSourceSize %d\n", u_errorName(status), rulesBinFromSourceSize);
+ } else {
+ uint8_t* rulesBinFromSource = (uint8_t *)uprv_malloc(rulesBinFromSourceSize);
+ if (rulesBinFromSource == NULL) {
+ log_data_err("FAIL: uprv_malloc fails for urbtok57 rulesBinFromSource[%d]\n", rulesBinFromSourceSize);
+ } else {
+ start = GET_START();
+ rulesBinFromSourceSize = urbtok57_getBinaryRules(utok57FromSource, rulesBinFromSource, rulesBinFromSourceSize, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok57_getBinaryRules status: %s, rulesBinFromSourceSize %d\n", u_errorName(status), rulesBinFromSourceSize);
+ } else {
+ log_info(" urbtok57_getBinaryRules size %d, nsec %llu\n", rulesBinFromSourceSize, duration);
+
+ status = U_ZERO_ERROR;
+ start = GET_START();
+ // ubrk_openBinaryRules does copy the binary rules, they can be freed at the end of this block
+ utok57BinFromSource = urbtok57_openBinaryRules(rulesBinFromSource, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok57_openBinaryRules from source status: %s\n", u_errorName(status));
+ } else {
+ log_info(" urbtok57_openBinaryRules from source nsec %llu\n", duration);
+ }
+
+ if (ruleTypePtr->rulesBin57) {
+ long rulesBinSize;
+ uint8_t* rulesBinBuf = (uint8_t*)dataBufFromFile(ruleTypePtr->rulesBin57, &rulesBinSize);
+ // dataBufFromFile already logged any errors leading to NULL return
+ if (rulesBinBuf) {
+ log_info(" get urbtok57 binary rules from file, rulesBinSize %d\n", rulesBinSize);
+ status = U_ZERO_ERROR;
+ start = GET_START();
+ utok57BinFromFile = urbtok57_openBinaryRules(rulesBinBuf, &status);
+ duration = GET_DURATION(start, info);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: urbtok57_openBinaryRules from file status: %s\n", u_errorName(status));
+ } else {
+ log_info(" urbtok57_openBinaryRules file nsec %llu\n", duration);
+ }
+ uprv_free(rulesBinBuf);
+ }
+ }
+ }
+ uprv_free(rulesBinFromSource);
+ }
+ }
+ }
+ }
+
+ if (ubrkFromSource) {
+ // Test tokenization
+ const TokTextAndResults* textResultsPtr;
+ for (textResultsPtr = ruleTypePtr->textAndResults; textResultsPtr->descrip != NULL; textResultsPtr++) {
+ RuleBasedTokenRange tokens[kMaxTokens];
+ unsigned long flags[kMaxTokens];
+ RuleBasedTokenRange *tokenLimit = tokens + kMaxTokens;
+ RuleBasedTokenRange *tokenP;
+ unsigned long *flagsP;
+ int32_t iTest, numTokens;
+ const char* testType[] = { "source", "binFromSource", "binFromFile" };
+ int32_t textLen = u_strlen(textResultsPtr->tokText);
+ log_info("-- starting tests for rule/text combo %s, text UTF16 units: %d\n", textResultsPtr->descrip, textLen);
+
+ if (ubrkFromSource || ubrkBinFromSource) {
+ for (iTest = 0; iTest < 2; iTest++) {
+ UBreakIterator* ubrk = (iTest==0)? ubrkFromSource: ubrkBinFromSource;
+ if (ubrk) {
+ int32_t offset, lastOffset;
+ // Do ubrk loop tests
+ status = U_ZERO_ERROR;
+ ubrk_setText(ubrk, textResultsPtr->tokText, textLen, &status);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: %s ubrk_setText ubrk %s status: %s\n", textResultsPtr->descrip, testType[iTest], u_errorName(status));
+ } else {
+ start = GET_START();
+ lastOffset = ubrk_current(ubrk);
+ for (tokenP = tokens, flagsP = flags; tokenP < tokenLimit && (offset = ubrk_next(ubrk)) != UBRK_DONE;) {
+ int32_t flagSet = ubrk_getRuleStatus(ubrk);
+ if (flagSet != -1) {
+ int32_t flagVec[8];
+ int32_t flagCount;
+ UErrorCode locStatus = U_ZERO_ERROR;
+
+ tokenP->location = lastOffset;
+ tokenP++->length = offset - lastOffset;
+ flagCount = ubrk_getRuleStatusVec(ubrk, flagVec, 8, &locStatus);
+ if (U_SUCCESS(locStatus) && flagCount-- > 1) {
+ // skip last flagVec entry since we have from ubrk_getRuleStatus above
+ int32_t flagIdx;
+ for (flagIdx = 0; flagIdx < flagCount; flagIdx++) {
+ flagSet |= flagVec[flagIdx];
+ }
+ }
+ *flagsP++ = (unsigned long)flagSet;
+ }
+ lastOffset = offset;
+ }
+ numTokens = tokenP - tokens;
+ duration = GET_DURATION(start, info);
+
+ handleTokResults(textResultsPtr->descrip, "ubrk", testType[iTest], "(loop)", duration,
+ textResultsPtr->expTokLen, textResultsPtr->expTok, numTokens, tokens, flags);
+ }
+ }
+ }
+ }
+
+ if (utokFromSource || utokBinFromSource) {
+ for (iTest = 0; iTest < 3; iTest++) {
+ UBreakIterator* utok = (iTest==0)? utokFromSource: ((iTest==1)? utokBinFromSource: utokBinFromFile);
+ if (utok) {
+ // Do utok loop & bulk tests
+ status = U_ZERO_ERROR;
+ ubrk_setText(utok, textResultsPtr->tokText, textLen, &status);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: %s ubrk_setText utok %s (loop) status: %s\n", textResultsPtr->descrip, testType[iTest], u_errorName(status));
+ } else {
+ start = GET_START();
+ for (tokenP = tokens, flagsP = flags; tokenP < tokenLimit && urbtok_tokenize(utok, 1, tokenP, flagsP) == 1; tokenP++, flagsP++) {
+ ;
+ }
+ numTokens = tokenP - tokens;
+ duration = GET_DURATION(start, info);
+
+ if (iTest < 2) {
+ handleTokResults(textResultsPtr->descrip, "utok", testType[iTest], "(loop)", duration,
+ textResultsPtr->expTokLen, textResultsPtr->expTok, numTokens, tokens, flags);
+ } else {
+ handleTokResults(textResultsPtr->descrip, "utok", testType[iTest], "(loop)", duration,
+ textResultsPtr->expTokFileLen, textResultsPtr->expTokFile, numTokens, tokens, flags);
+ }
+ }
+
+ status = U_ZERO_ERROR;
+ ubrk_setText(utok, textResultsPtr->tokText, textLen, &status);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: %s ubrk_setText utok %s (bulk) status: %s\n", textResultsPtr->descrip, testType[iTest], u_errorName(status));
+ } else {
+ start = GET_START();
+ numTokens = urbtok_tokenize(utok, kMaxTokens, tokens, flags);
+ duration = GET_DURATION(start, info);
+
+ if (iTest < 2) {
+ handleTokResults(textResultsPtr->descrip, "utok", testType[iTest], "(bulk)", duration,
+ textResultsPtr->expTokLen, textResultsPtr->expTok, numTokens, tokens, flags);
+ } else {
+ handleTokResults(textResultsPtr->descrip, "utok", testType[iTest], "(bulk)", duration,
+ textResultsPtr->expTokFileLen, textResultsPtr->expTokFile, numTokens, tokens, flags);
+ }
+ }
+ }
+ }
+ }
+
+ if (utok57FromSource || utok57BinFromSource) {
+ for (iTest = 0; iTest < 3; iTest++) {
+ UBreakIterator* utok57 = (iTest==0)? utok57FromSource: ((iTest==1)? utok57BinFromSource: utok57BinFromFile);;
+ if (utok57) {
+ // Do utok57 loop & bulk tests
+ status = U_ZERO_ERROR;
+ ubrk_setText(utok57, textResultsPtr->tokText, textLen, &status);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: %s ubrk_setText utok57 %s (loop) status: %s\n", textResultsPtr->descrip, testType[iTest], u_errorName(status));
+ } else {
+ start = GET_START();
+ for (tokenP = tokens, flagsP = flags; tokenP < tokenLimit && urbtok57_tokenize(utok57, 1, tokenP, flagsP) == 1; tokenP++, flagsP++) {
+ ;
+ }
+ numTokens = tokenP - tokens;
+ duration = GET_DURATION(start, info);
+
+ handleTokResults(textResultsPtr->descrip, "utok57", testType[iTest], "(loop)", duration,
+ textResultsPtr->expTok57LoopLen, textResultsPtr->expTok57Loop, numTokens, tokens, flags);
+ }
+
+ status = U_ZERO_ERROR;
+ ubrk_setText(utok57, textResultsPtr->tokText, textLen, &status);
+ if (U_FAILURE(status)) {
+ log_err("FAIL: %s ubrk_setText utok57 %s (bulk) status: %s\n", textResultsPtr->descrip, testType[iTest], u_errorName(status));
+ } else {
+ start = GET_START();
+ numTokens = urbtok57_tokenize(utok57, kMaxTokens, tokens, flags);
+ duration = GET_DURATION(start, info);
+
+ handleTokResults(textResultsPtr->descrip, "utok57", testType[iTest], "(bulk)", duration,
+ textResultsPtr->expTok57BulkLen, textResultsPtr->expTok57Bulk, numTokens, tokens, flags);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ // Close UBreakIterators and rule memory, don't need to check for NULL
+ ubrk_close(ubrkFromSource);
+ ubrk_close(ubrkBinFromSource);
+ ubrk_close(utokFromSource);
+ ubrk_close(utokBinFromSource);
+ ubrk_close(utokBinFromFile);
+ ubrk_close(utok57FromSource);
+ ubrk_close(utok57BinFromSource);
+ ubrk_close(utok57BinFromFile);
+ uprv_free(ubrkBinRules);
+ }
+}
+
+
+
+#endif
+
+