From a7a26cd51dfa9b3e95e9f59c1e9c46503f3e5536 Mon Sep 17 00:00:00 2001 From: Matitiahu Allouche Date: Tue, 7 Aug 2007 19:22:05 +0000 Subject: [PATCH] ICU-5732 add tests to match those in ICU4J X-SVN-Rev: 22303 --- icu4c/source/test/cintltst/cbiditst.c | 1018 +++++++++++++++++++++---- 1 file changed, 883 insertions(+), 135 deletions(-) diff --git a/icu4c/source/test/cintltst/cbiditst.c b/icu4c/source/test/cintltst/cbiditst.c index 8b707a098a4..03c89af00b3 100644 --- a/icu4c/source/test/cintltst/cbiditst.c +++ b/icu4c/source/test/cintltst/cbiditst.c @@ -9,7 +9,7 @@ * indentation:4 * * created on: 1999sep27 -* created by: Markus W. Scherer +* created by: Markus W. Scherer, updated by Matitiahu Allouche */ #include "cintltst.h" @@ -28,47 +28,41 @@ /* prototypes ---------------------------------------------------------------*/ -static void -testCharFromDirProp(void); +static void testCharFromDirProp(void); -static void -testBidi(void); +static void testBidi(void); -static void -doTests(UBiDi *pBiDi, UBiDi *pLine, UBool countRunsFirst); +static void doTests(UBiDi *pBiDi, UBiDi *pLine, UBool countRunsFirst); -static void -doTest(UBiDi *pBiDi, int testNumber, const BiDiTestData *test, int32_t lineStart, UBool countRunsFirst); +static void doMisc(void); -static void -_testReordering(UBiDi *pBiDi, int testNumber); +static void doTest(UBiDi *pBiDi, int testNumber, const BiDiTestData *test, + int32_t lineStart, UBool countRunsFirst); -static void -testInverseBidi(void); +static void _testReordering(UBiDi *pBiDi, int testNumber); -static void -_testManyInverseBidi(UBiDi *pBiDi, UBiDiLevel direction); +static void testInverse(void); -static void -_testInverseBidi(UBiDi *pBiDi, const UChar *src, int32_t srcLength, UBiDiLevel direction, UErrorCode *pErrorCode); +static void _testManyInverseBidi(UBiDi *pBiDi, UBiDiLevel direction); -static void -_testWriteReverse(void); +static void _testInverseBidi(UBiDi *pBiDi, const UChar *src, int32_t srcLength, + UBiDiLevel direction, UErrorCode *pErrorCode); -static void -doArabicShapingTest(void); +static void _testWriteReverse(void); -static void -doLamAlefSpecialVLTRArabicShapingTest(void); +static void _testManyAddedPoints(void); -static void -doTashkeelSpecialVLTRArabicShapingTest(void); +static void _testMisc(void); -static void -doLOGICALArabicDeShapingTest(void); +static void doArabicShapingTest(void); -static void -doArabicShapingTestForBug5421(void); +static void doLamAlefSpecialVLTRArabicShapingTest(void); + +static void doTashkeelSpecialVLTRArabicShapingTest(void); + +static void doLOGICALArabicDeShapingTest(void); + +static void doArabicShapingTestForBug5421(void); static void testReorder(void); @@ -81,42 +75,38 @@ static void testReorderingMode(void); static void testReorderRunsOnly(void); static void testStreaming(void); static void testClassOverride(void); -static const char* inverseBasic(UBiDi *pBiDi, const UChar *src, int32_t srcLen, +static const char* inverseBasic(UBiDi *pBiDi, const char *src, int32_t srcLen, uint32_t option, UBiDiLevel level, char *result); static UBool assertRoundTrip(UBiDi *pBiDi, int32_t tc, int32_t outIndex, const char *srcChars, const char *destChars, const UChar *dest, int32_t destLen, int mode, int option, UBiDiLevel level); static UBool checkResultLength(UBiDi *pBiDi, const char *srcChars, - const char *destChars, const UChar *dest, + const char *destChars, int32_t destLen, const char *mode, const char *option, UBiDiLevel level); -static UBool testMaps(UBiDi *pBiDi, int32_t stringIndex, const char *src, - const char *dest, const char *mode, const char* option, - UBiDiLevel level, UBool forward); +static UBool checkMaps(UBiDi *pBiDi, int32_t stringIndex, const char *src, + const char *dest, const char *mode, const char* option, + UBiDiLevel level, UBool forward); /* helpers ------------------------------------------------------------------ */ static const char *levelString="..............................................................."; -static void -initCharFromDirProps(void); +static void initCharFromDirProps(void); static UChar * getStringFromDirProps(const uint8_t *dirProps, int32_t length, UChar *buffer); -static void -printUnicode(const UChar *s, int32_t length, const UBiDiLevel *levels); +static void printUnicode(const UChar *s, int32_t length, const UBiDiLevel *levels); /* regression tests ---------------------------------------------------------*/ -void addComplexTest(TestNode** root); - void addComplexTest(TestNode** root) { addTest(root, testCharFromDirProp, "complex/bidi/TestCharFromDirProp"); addTest(root, testBidi, "complex/bidi/TestBidi"); - addTest(root, testInverseBidi, "complex/bidi/TestInverse"); + addTest(root, testInverse, "complex/bidi/TestInverse"); addTest(root, testReorder,"complex/bidi/TestReorder"); addTest(root, testFailureRecovery,"complex/bidi/TestFailureRecovery"); addTest(root, testMultipleParagraphs,"complex/bidi/TestMultipleParagraphs"); @@ -132,11 +122,12 @@ addComplexTest(TestNode** root) { addTest(root, doArabicShapingTestForBug5421, "complex/arabic-shaping/bug-5421"); } -/* verify that the exemplar characters have the expected bidi classes */ static void testCharFromDirProp(void) { + /* verify that the exemplar characters have the expected bidi classes */ int32_t i; + log_verbose("\nEntering TestCharFromDirProp\n\n"); initCharFromDirProps(); for(i=0; i logicalStart.length/level: ", runCount); + for (i = 0; i < runCount; i++) { + UBiDiDirection dir; + int32_t start, len; + dir = ubidi_getVisualRun(bidi, i, &start, &len); + log_err(" %d.%d/%d", start, len, dir); + } + } + fputs("\n", stderr); +} + +static UBool matchingPair(UBiDi *bidi, int32_t i, char c1, char c2) +{ + /* No test for []{} since they have special meaning for pseudo Bidi */ + static char mates1Chars[] = "<>()"; + static char mates2Chars[] = "><)("; + UBiDiLevel level; + int k, len; + + if (c1 == c2) { + return TRUE; + } + /* For UBIDI_REORDER_RUNS_ONLY, it would not be correct to check levels[i], + so we use the appropriate run's level, which is good for all cases. + */ + ubidi_getLogicalRun(bidi, i, NULL, &level); + if ((level & 1) == 0) { + return FALSE; + } + len = strlen(mates1Chars); + for (k = 0; k < len; k++) { + if ((c1 == mates1Chars[k]) && (c2 == mates2Chars[k])) { + return TRUE; + } + } + return FALSE; +} + +static UBool checkWhatYouCan(UBiDi *bidi, const char *srcChars, const char *dstChars) +/* srcChars and dstChars are char arrays encoded as pseudo Bidi */ +{ + int32_t i, idx, logLimit, visLimit; + UBool testOK, errMap, errDst; + UErrorCode errorCode=U_ZERO_ERROR; + int32_t visMap[MAXLEN]; + int32_t logMap[MAXLEN]; + char accumSrc[MAXLEN]; + char accumDst[MAXLEN]; + ubidi_getVisualMap(bidi, visMap, &errorCode); + ubidi_getLogicalMap(bidi, logMap, &errorCode); + if (U_FAILURE(errorCode)) { + log_err("Error #1 invoking ICU within checkWhatYouCan\n"); + return FALSE; + } + + testOK = TRUE; + errMap = errDst = FALSE; + logLimit = ubidi_getProcessedLength(bidi); + visLimit = ubidi_getResultLength(bidi); + memset(accumSrc, '?', logLimit); + memset(accumDst, '?', visLimit); + + for (i = 0; i < logLimit; i++) { + idx = ubidi_getVisualIndex(bidi, i, &errorCode); + if (idx != logMap[i]) { + errMap = TRUE; + } + if (idx == UBIDI_MAP_NOWHERE) { + continue; + } + if (idx >= visLimit) { + continue; + } + accumDst[idx] = srcChars[i]; + if (!matchingPair(bidi, i, srcChars[i], dstChars[idx])) { + errDst = TRUE; + } + } + accumDst[visLimit] = 0; + if (U_FAILURE(errorCode)) { + log_err("Error #2 invoking ICU within checkWhatYouCan\n"); + return FALSE; + } + if (errMap) { + if (testOK) { + printCaseInfo(bidi, srcChars, dstChars); + testOK = FALSE; + } + log_err("Mismatch between getLogicalMap() and getVisualIndex()\n"); + log_err("Map :"); + for (i = 0; i < logLimit; i++) { + log_err(" %d", logMap[i]); + } + fputs("\n", stderr); + log_err("Indexes:"); + for (i = 0; i < logLimit; i++) { + log_err(" %d", ubidi_getVisualIndex(bidi, i, &errorCode)); + } + fputs("\n", stderr); + } + if (errDst) { + if (testOK) { + printCaseInfo(bidi, srcChars, dstChars); + testOK = FALSE; + } + log_err("Source does not map to Result\n"); + log_err("We got: %s", accumDst); fputs("\n", stderr); + } + + errMap = errDst = FALSE; + for (i = 0; i < visLimit; i++) { + idx = ubidi_getLogicalIndex(bidi, i, &errorCode); + if (idx != visMap[i]) { + errMap = TRUE; + } + if (idx == UBIDI_MAP_NOWHERE) { + continue; + } + if (idx >= logLimit) { + continue; + } + accumSrc[idx] = dstChars[i]; + if (!matchingPair(bidi, idx, srcChars[idx], dstChars[i])) { + errDst = TRUE; + } + } + accumSrc[logLimit] = 0; + if (U_FAILURE(errorCode)) { + log_err("Error #3 invoking ICU within checkWhatYouCan\n"); + return FALSE; + } + if (errMap) { + if (testOK) { + printCaseInfo(bidi, srcChars, dstChars); + testOK = FALSE; + } + log_err("Mismatch between getVisualMap() and getLogicalIndex()\n"); + log_err("Map :"); + for (i = 0; i < visLimit; i++) { + log_err(" %d", visMap[i]); + } + fputs("\n", stderr); + log_err("Indexes:"); + for (i = 0; i < visLimit; i++) { + log_err(" %d", ubidi_getLogicalIndex(bidi, i, &errorCode)); + } + fputs("\n", stderr); + } + if (errDst) { + if (testOK) { + printCaseInfo(bidi, srcChars, dstChars); + testOK = FALSE; + } + log_err("Result does not map to Source\n"); + log_err("We got: %s", accumSrc); + fputs("\n", stderr); + } + return testOK; +} + +static void +testReorder(void) { static const char* const logicalOrder[] ={ "del(KC)add(K.C.&)", "del(QDVT) add(BVDL)", @@ -480,12 +703,16 @@ static void testReorder(){ UErrorCode ec = U_ZERO_ERROR; UBiDi* bidi = ubidi_open(); int i; + + log_verbose("\nEntering TestReorder\n\n"); + for(i=0;i -1 && !testMaps(pBiDi, outIndex, srcChars, destChars, - desc, "UBIDI_OPTION_REMOVE_CONTROLS", - level, FALSE)) { + if (outIndex > -1 && !checkMaps(pBiDi, outIndex, srcChars, destChars, + desc, "UBIDI_OPTION_REMOVE_CONTROLS", + level, FALSE)) { return FALSE; } return TRUE; @@ -2491,7 +3204,7 @@ assertRoundTrip(UBiDi *pBiDi, int32_t tc, int32_t outIndex, const char *srcChars static UBool checkResultLength(UBiDi *pBiDi, const char *srcChars, const char *destChars, - const UChar *dest, int32_t destLen, const char* mode, + int32_t destLen, const char* mode, const char* option, UBiDiLevel level) { int32_t actualLen; if (strcmp(mode, "UBIDI_REORDER_INVERSE_NUMBERS_AS_L") == 0) @@ -2517,48 +3230,53 @@ testReorderRunsOnly(void) { const char* textOut[2][2]; const char noroundtrip[2]; } testCases[] = { - {"ab 234 896 de", {{"de 896 ab 234", "de 896 ab 234"}, + {"ab 234 896 de", {{"de 896 ab 234", "de 896 ab 234"}, /*0*/ {"ab 234 @896@ de", "de 896 ab 234"}}, {0, 0}}, - {"abcGHI", {{"GHIabc", "GHIabc"}, {"GHIabc", "GHIabc"}}, {0, 0}}, - {"a.>67->", {{"<-67<.a", "<-67<.a"}, {"<-67<.a", "<-67<.a"}}, {0, 0}}, - {"-=%$123/ *", {{"* /%$123=-", "* /%$123=-"}, + {"abcGHI", {{"GHIabc", "GHIabc"}, {"GHIabc", "GHIabc"}}, {0, 0}}, /*1*/ + {"a.>67->", {{"<-67<.a", "<-67<.a"}, {"<-67<.a", "<-67<.a"}}, {0, 0}}, /*2*/ + {"-=%$123/ *", {{"* /%$123=-", "* /%$123=-"}, /*3*/ {"* /%$123=-", "* /%$123=-"}}, {0, 0}}, - {"abc->12..>JKL", {{"JKL<..12<-abc", "JKL<..abc->12"}, + {"abc->12..>JKL", {{"JKL<..12<-abc", "JKL<..abc->12"}, /*4*/ {"JKL<..12<-abc", "JKL<..abc->12"}}, {0, 0}}, - {"JKL->12..>abc", {{"abc<..JKL->12", "abc<..12<-JKL"}, + {"JKL->12..>abc", {{"abc<..JKL->12", "abc<..12<-JKL"}, /*5*/ {"abc<..JKL->12", "abc<..12<-JKL"}}, {0, 0}}, - {"123->abc", {{"abc<-123", "abc<-123"}, + {"123->abc", {{"abc<-123", "abc<-123"}, /*6*/ {"abc&<-123", "abc<-123"}}, {1, 0}}, - {"123->JKL", {{"JKL<-123", "123->JKL"}, + {"123->JKL", {{"JKL<-123", "123->JKL"}, /*7*/ {"JKL<-123", "JKL<-@123"}}, {0, 1}}, - {"*>12.>34->JKL", {{"JKL<-34<.12<*", "12.>34->JKL<*"}, + {"*>12.>34->JKL", {{"JKL<-34<.12<*", "12.>34->JKL<*"}, /*8*/ {"JKL<-34<.12<*", "JKL<-@34<.12<*"}}, {0, 1}}, - {"*>67.>89->JKL", {{"67.>89->JKL<*", "67.>89->JKL<*"}, + {"*>67.>89->JKL", {{"67.>89->JKL<*", "67.>89->JKL<*"}, /*9*/ {"67.>89->JKL<*", "67.>89->JKL<*"}}, {0, 0}}, - {"* /abc-=$%123", {{"$%123=-abc/ *", "abc-=$%123/ *"}, + {"* /abc-=$%123", {{"$%123=-abc/ *", "abc-=$%123/ *"}, /*10*/ {"$%123=-abc/ *", "abc-=$%123/ *"}}, {0, 0}}, - {"* /$%def-=123", {{"123=-def%$/ *", "def-=123%$/ *"}, + {"* /$%def-=123", {{"123=-def%$/ *", "def-=123%$/ *"}, /*11*/ {"123=-def%$/ *", "def-=123%$/ *"}}, {0, 0}}, - {"-=GHI* /123%$", {{"GHI* /123%$=-", "123%$/ *GHI=-"}, + {"-=GHI* /123%$", {{"GHI* /123%$=-", "123%$/ *GHI=-"}, /*12*/ {"GHI* /123%$=-", "123%$/ *GHI=-"}}, {0, 0}}, - {"-=%$JKL* /123", {{"JKL* /%$123=-", "123/ *JKL$%=-"}, + {"-=%$JKL* /123", {{"JKL* /%$123=-", "123/ *JKL$%=-"}, /*13*/ {"JKL* /%$123=-", "123/ *JKL$%=-"}}, {0, 0}}, - {"ab =#CD *?450", {{"CD *?450#= ab", "450?* CD#= ab"}, + {"ab =#CD *?450", {{"CD *?450#= ab", "450?* CD#= ab"}, /*14*/ {"CD *?450#= ab", "450?* CD#= ab"}}, {0, 0}}, - {"ab 234 896 de", {{"de 896 ab 234", "de 896 ab 234"}, + {"ab 234 896 de", {{"de 896 ab 234", "de 896 ab 234"}, /*15*/ {"ab 234 @896@ de", "de 896 ab 234"}}, {0, 0}}, - {"abc-=%$LMN* /123", {{"LMN* /%$123=-abc", "123/ *LMN$%=-abc"}, + {"abc-=%$LMN* /123", {{"LMN* /%$123=-abc", "123/ *LMN$%=-abc"}, /*16*/ {"LMN* /%$123=-abc", "123/ *LMN$%=-abc"}}, {0, 0}}, - {"123->JKL&MN&P", {{"JKLMNP<-123", "123->JKLMNP"}, - {"JKLMNP<-123", "JKLMNP<-@123"}}, {0, 1}} + {"123->JKL&MN&P", {{"JKLMNP<-123", "123->JKLMNP"}, /*17*/ + {"JKLMNP<-123", "JKLMNP<-@123"}}, {0, 1}}, + {"123", {{"123", "123"}, /* just one run */ /*18*/ + {"123", "123"}}, {0, 0}} }; UBiDi *pBiDi = getBiDiObject(); UBiDi *pL2VBiDi = getBiDiObject(); UChar src[MAXLEN], dest[MAXLEN], visual1[MAXLEN], visual2[MAXLEN]; char destChars[MAXLEN], vis1Chars[MAXLEN], vis2Chars[MAXLEN]; - int32_t srcLen, destLen, vis1Len, vis2Len, option, i, j, nCases; + int32_t srcLen, destLen, vis1Len, vis2Len, option, i, j, nCases, paras; UErrorCode rc = U_ZERO_ERROR; UBiDiLevel level; + + log_verbose("\nEntering TestReorderRunsOnly\n\n"); + if(!pL2VBiDi) { ubidi_close(pBiDi); /* in case this one was allocated */ return; @@ -2573,6 +3291,8 @@ testReorderRunsOnly(void) { srcLen = strlen(testCases[i].textIn); pseudoToU16(srcLen, testCases[i].textIn, src); for(j = 0; j < 2; j++) { + log_verbose("Now doing test for option %d, case %d, level %d\n", + i, option, j); level = paraLevels[j]; ubidi_setPara(pBiDi, src, srcLen, level, NULL, &rc); assertSuccessful("ubidi_setPara", &rc); @@ -2580,6 +3300,7 @@ testReorderRunsOnly(void) { destLen = ubidi_writeReordered(pBiDi, dest, MAXLEN, UBIDI_DO_MIRRORING, &rc); assertSuccessful("ubidi_writeReordered", &rc); u16ToPseudo(destLen, dest, destChars); + checkWhatYouCan(pBiDi, testCases[i].textIn, destChars); assertStringsEqual(testCases[i].textOut[option][level], destChars, testCases[i].textIn, "UBIDI_REORDER_RUNS_ONLY", option==0 ? "0" : "UBIDI_OPTION_INSERT_MARKS", @@ -2594,12 +3315,14 @@ testReorderRunsOnly(void) { vis1Len = ubidi_writeReordered(pL2VBiDi, visual1, MAXLEN, UBIDI_DO_MIRRORING, &rc); assertSuccessful("ubidi_writeReordered1", &rc); u16ToPseudo(vis1Len, visual1, vis1Chars); + checkWhatYouCan(pL2VBiDi, testCases[i].textIn, vis1Chars); ubidi_setPara(pL2VBiDi, dest, destLen, level^1, NULL, &rc); assertSuccessful("ubidi_setPara2", &rc); *visual2 = 0; vis2Len = ubidi_writeReordered(pL2VBiDi, visual2, MAXLEN, UBIDI_DO_MIRRORING, &rc); assertSuccessful("ubidi_writeReordered2", &rc); u16ToPseudo(vis2Len, visual2, vis2Chars); + checkWhatYouCan(pL2VBiDi, destChars, vis2Chars); assertStringsEqual(vis1Chars, vis2Chars, testCases[i].textIn, "UBIDI_REORDER_RUNS_ONLY (2)", option==0 ? "0" : "UBIDI_OPTION_INSERT_MARKS", @@ -2607,12 +3330,23 @@ testReorderRunsOnly(void) { } } } + + /* test with null or empty text */ + ubidi_setPara(pBiDi, src, 0, UBIDI_LTR, NULL, &rc); + assertSuccessful("ubidi_setPara3", &rc); + paras = ubidi_countParagraphs(pBiDi); + if (paras != 0) { + log_err("\nInvalid number of paras (should be 0): %d\n", paras); + } + ubidi_close(pBiDi); ubidi_close(pL2VBiDi); + + log_verbose("\nExiting TestReorderRunsOnly\n\n"); } static void -testReorderingMode() { +testReorderingMode(void) { UChar src[MAXLEN], dest[MAXLEN]; char destChars[MAXLEN]; @@ -2625,7 +3359,7 @@ testReorderingMode() { const char *expectedChars; UBool testOK = TRUE; - log_verbose("\n*** Bidi reordering mode test ***\n"); + log_verbose("\nEntering TestReorderingMode\n\n"); pBiDi = getBiDiObject(); pBiDi2 = getBiDiObject(); @@ -2639,7 +3373,7 @@ testReorderingMode() { ubidi_setInverse(pBiDi2, TRUE); for (tc = 0; tc < TC_COUNT; tc++) { - const char* srcChars = textIn[tc]; + const char *srcChars = textIn[tc]; srcLen = strlen(srcChars); pseudoToU16(srcLen, srcChars, src); @@ -2673,10 +3407,14 @@ testReorderingMode() { UBIDI_DO_MIRRORING, &rc); assertSuccessful("ubidi_writeReordered", &rc); u16ToPseudo(destLen, dest, destChars); + if (!((modes[mode].value == UBIDI_REORDER_INVERSE_NUMBERS_AS_L) && + (options[option].value == UBIDI_OPTION_INSERT_MARKS))) { + checkWhatYouCan(pBiDi, srcChars, destChars); + } if (modes[mode].value == UBIDI_REORDER_INVERSE_NUMBERS_AS_L) { index = -1; - expectedChars = inverseBasic(pBiDi2, src, srcLen, + expectedChars = inverseBasic(pBiDi2, srcChars, srcLen, options[option].value, paraLevels[level], destChars); } else { @@ -2689,19 +3427,19 @@ testReorderingMode() { pBiDi)) { testOK = FALSE; } - else if (options[option].value == UBIDI_OPTION_INSERT_MARKS && + if (options[option].value == UBIDI_OPTION_INSERT_MARKS && !assertRoundTrip(pBiDi3, tc, index, srcChars, destChars, dest, destLen, mode, option, paraLevels[level])) { testOK = FALSE; } else if (!checkResultLength(pBiDi, srcChars, destChars, - dest, destLen, modes[mode].description, + destLen, modes[mode].description, options[option].description, paraLevels[level])) { testOK = FALSE; } - else if (index > -1 && !testMaps(pBiDi, index, srcChars, + else if (index > -1 && !checkMaps(pBiDi, index, srcChars, destChars, modes[mode].description, options[option].description, paraLevels[level], TRUE)) { @@ -2717,18 +3455,21 @@ testReorderingMode() { ubidi_close(pBiDi3); ubidi_close(pBiDi2); ubidi_close(pBiDi); + + log_verbose("\nExiting TestReorderingMode\n\n"); } -static const char* inverseBasic(UBiDi *pBiDi, const UChar *src, int32_t srcLen, +static const char* inverseBasic(UBiDi *pBiDi, const char *srcChars, int32_t srcLen, uint32_t option, UBiDiLevel level, char *result) { UErrorCode rc = U_ZERO_ERROR; int32_t destLen; - UChar dest2 [MAXLEN]; + UChar src[MAXLEN], dest2[MAXLEN]; if (pBiDi == NULL || src == NULL) { return NULL; } ubidi_setReorderingOptions(pBiDi, option); + pseudoToU16(srcLen, srcChars, src); ubidi_setPara(pBiDi, src, srcLen, level, NULL, &rc); assertSuccessful("ubidi_setPara", &rc); @@ -2737,13 +3478,16 @@ static const char* inverseBasic(UBiDi *pBiDi, const UChar *src, int32_t srcLen, UBIDI_DO_MIRRORING, &rc); assertSuccessful("ubidi_writeReordered", &rc); u16ToPseudo(destLen, dest2, result); + if (!(option == UBIDI_OPTION_INSERT_MARKS)) { + checkWhatYouCan(pBiDi, srcChars, result); + } return result; } #define NULL_CHAR '\0' static void -testStreaming() { +testStreaming(void) { #define MAXPORTIONS 10 static const struct { @@ -2786,7 +3530,7 @@ testStreaming() { UBool mismatch, testOK = TRUE; char processedLenStr[MAXPORTIONS * 5]; - log_verbose("\n*** Bidi streaming test ***\n"); + log_verbose("\nEntering TestStreaming\n\n"); pBiDi = getBiDiObject(); @@ -2799,6 +3543,7 @@ testStreaming() { nPortions = testData[i].nPortions[levelIndex]; level = paraLevels[levelIndex]; *processedLenStr = NULL_CHAR; + log_verbose("Testing level %d, case %d\n", level, i); mismatch = FALSE; @@ -2840,6 +3585,7 @@ testStreaming() { if (testOK == TRUE) { log_verbose("\nBiDi streaming test OK\n"); } + log_verbose("\nExiting TestStreaming\n\n"); } U_CDECL_BEGIN @@ -2891,7 +3637,8 @@ static void verifyCallbackParams(UBiDiClassCallback* fn, const void* context, } } -static void testClassOverride(void) { +static void +testClassOverride(void) { static const char* const textSrc = "JIH.>12->a \\u05D0\\u05D1 6 ABC78"; static const char* const textResult = "12<.HIJ->a 78CBA 6 \\u05D1\\u05D0"; @@ -2904,7 +3651,7 @@ static void testClassOverride(void) { int32_t srcLen, destLen, textSrcSize = (int32_t)uprv_strlen(textSrc); char* destChars = NULL; - log_verbose("\n*** Bidi class override test ***\n"); + log_verbose("\nEntering TestClassOverride\n\n"); pBiDi = getBiDiObject(); if(!pBiDi) { @@ -2950,6 +3697,7 @@ static void testClassOverride(void) { log_verbose("\nClass override test OK\n"); } ubidi_close(pBiDi); + log_verbose("\nExiting TestClassOverride\n\n"); } static char * formatMap(const int32_t * map, int len, char * buffer) @@ -2971,8 +3719,8 @@ static char * formatMap(const int32_t * map, int len, char * buffer) } static UBool -testMaps(UBiDi *pBiDi, int32_t stringIndex, const char *src, const char *dest, - const char *mode, const char* option, UBiDiLevel level, UBool forward) +checkMaps(UBiDi *pBiDi, int32_t stringIndex, const char *src, const char *dest, + const char *mode, const char* option, UBiDiLevel level, UBool forward) { int32_t actualLogicalMap[MAX_MAP_LENGTH]; int32_t actualVisualMap[MAX_MAP_LENGTH];