X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/3d1f044b704633e2e541231cd17ae9ecf9ad5c7a..refs/heads/master:/icuSources/test/cintltst/cbiapts.c diff --git a/icuSources/test/cintltst/cbiapts.c b/icuSources/test/cintltst/cbiapts.c index 5efde690..f6382190 100644 --- a/icuSources/test/cintltst/cbiapts.c +++ b/icuSources/test/cintltst/cbiapts.c @@ -35,11 +35,17 @@ #include "cbiapts.h" #include "cmemory.h" -#define TEST_ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \ -log_data_err("Failure at file %s, line %d, error = %s (Are you missing data?)\n", __FILE__, __LINE__, u_errorName(status));}} - -#define TEST_ASSERT(expr) {if ((expr)==FALSE) { \ -log_data_err("Test Failure at file %s, line %d (Are you missing data?)\n", __FILE__, __LINE__);}} +#define TEST_ASSERT_SUCCESS(status) UPRV_BLOCK_MACRO_BEGIN { \ + if (U_FAILURE(status)) { \ + log_data_err("Failure at file %s, line %d, error = %s (Are you missing data?)\n", __FILE__, __LINE__, u_errorName(status)); \ + } \ +} UPRV_BLOCK_MACRO_END + +#define TEST_ASSERT(expr) UPRV_BLOCK_MACRO_BEGIN { \ + if ((expr)==FALSE) { \ + log_data_err("Test Failure at file %s, line %d (Are you missing data?)\n", __FILE__, __LINE__); \ + } \ +} UPRV_BLOCK_MACRO_END #define APPLE_ADDITIONS 1 @@ -107,7 +113,7 @@ static UChar* toUChar(const char *src, void **freeHook) { UErrorCode status = U_ZERO_ERROR; if (src == NULL) { return NULL; - }; + } cnv = ucnv_open(NULL, &status); if(U_FAILURE(status) || cnv == NULL) { @@ -540,7 +546,7 @@ static UBreakIterator * testOpenRules(char *rules) { if (U_FAILURE(status)) { log_data_err("FAIL: ubrk_openRules: ICU Error \"%s\" (Are you missing data?)\n", u_errorName(status)); bi = 0; - }; + } freeToUCharStrings(&strCleanUp); return bi; @@ -574,7 +580,7 @@ static void TestBreakIteratorRules() { ubrk_setText(bi, uData, -1, &status); pos = ubrk_first(bi); - for (i=0; i x64) + { { 139, 1 }, 0x000 }, // : + { { 140, 2 }, 0x064 }, // 30 { { 142, 1 }, 0x000 }, // { { 143, 1 }, 0x000 }, // { { 144, 1 }, 0x000 }, // @@ -2151,10 +2160,18 @@ typedef struct { const TokTextAndResults* textAndResults; } TokRulesAndTests; +#ifdef APPLE_XCODE_BUILD +#define TESTDATA_PARENT "." +#define WORD_PARENT "testdata" // the testdata build copies word.txt to testdata in the Xocde build +#else +#define TESTDATA_PARENT ".." +#define WORD_PARENT "../../data/brkitr/rules" +#endif + 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 }, + { "CFST", TESTDATA_PARENT "/testdata/tokCFSTrules.txt", NULL,/*tokCFSTrulesLE_icu60.data invalid*/ TESTDATA_PARENT "/testdata/tokCFSTrulesLE_icu57.data", tokTextAndResCFST }, + { "NLLT", TESTDATA_PARENT "/testdata/wordNLLTu8.txt", NULL,/*wordNLLT_icu60.dat invalid */ TESTDATA_PARENT "/testdata/wordNLLT_icu57.dat", tokTextAndResNLLT }, + { "StdW", WORD_PARENT "/word.txt", NULL, NULL, tokTextAndResStdW }, { "WORD", NULL, NULL, NULL, tokTextAndResStdW }, { NULL, NULL, NULL, NULL, NULL } }; @@ -2205,16 +2222,17 @@ static void* dataBufFromFile(const char* path, long* dataBufSizeP) { 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; + int32_t iToken, mismatchAt = -1; 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; + mismatchAt = iToken; } } if (fail) { - log_err("FAIL: %s %s %s %s expected %d tokens, got %d\n", testItem, tokClass, ruleSource, algType, expTokLen, getTokLen); + log_err("FAIL: %s %s %s %s expected %d tokens, got %d, mismatch at %d\n", testItem, tokClass, ruleSource, algType, expTokLen, getTokLen, mismatchAt); printf("# expect get\n"); printf("# loc len flags loc len flags\n"); int32_t maxTokens = (getTokLen >= expTokLen)? getTokLen: expTokLen;