diff --git a/icu4c/source/test/cintltst/callcoll.c b/icu4c/source/test/cintltst/callcoll.c index 963251f7bb..d306b04c2a 100644 --- a/icu4c/source/test/cintltst/callcoll.c +++ b/icu4c/source/test/cintltst/callcoll.c @@ -30,6 +30,8 @@ */ #ifndef INCLUDE_CALLCOLL_C +#include +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" @@ -37,7 +39,6 @@ #include "ccolltst.h" #include "callcoll.h" #include "unicode/ustring.h" -#include static UCollator *myCollation; diff --git a/icu4c/source/test/cintltst/ccaltst.c b/icu4c/source/test/cintltst/ccaltst.c index a5d4cde2e0..9cab104fb0 100644 --- a/icu4c/source/test/cintltst/ccaltst.c +++ b/icu4c/source/test/cintltst/ccaltst.c @@ -14,6 +14,9 @@ /* C API AND FUNCTIONALITY TEST FOR CALENDAR (ucol.h)*/ +#include +#include +#include #include "unicode/uloc.h" #include "unicode/utypes.h" #include "unicode/ucal.h" @@ -21,8 +24,6 @@ #include "unicode/ustring.h" #include "cintltst.h" #include "ccaltst.h" -#include -#include #include "cformtst.h" @@ -156,7 +157,7 @@ void TestCalendar() } else{ log_verbose("PASS: getting the time zone display name successful : %s, %d needed \n", - u_errorName(status), resultlengthneeded); + u_errorName(status), resultlengthneeded); } diff --git a/icu4c/source/test/cintltst/ccolltst.c b/icu4c/source/test/cintltst/ccolltst.c index 47f0af94df..ee775f42db 100644 --- a/icu4c/source/test/cintltst/ccolltst.c +++ b/icu4c/source/test/cintltst/ccolltst.c @@ -12,12 +12,13 @@ * Madhu Katragadda Creation ********************************************************************************* */ +#include +#include +#include #include "cintltst.h" #include "ccolltst.h" #include "unicode/ucol.h" -#include #include "unicode/ustring.h" -#include void addCollAPITest(TestNode**); void addCurrencyTest(TestNode**); diff --git a/icu4c/source/test/cintltst/ccurrtst.c b/icu4c/source/test/cintltst/ccurrtst.c index 25e04dad49..d5614035db 100644 --- a/icu4c/source/test/cintltst/ccurrtst.c +++ b/icu4c/source/test/cintltst/ccurrtst.c @@ -13,6 +13,8 @@ ********************************************************************************* */ +#include +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" @@ -101,11 +103,11 @@ void currTest() sortklen=ucol_getSortKey(c, source, u_strlen(source), NULL, 0); sortKey1=(uint8_t*)malloc(sizeof(uint8_t) * (sortklen+1)); ucol_getSortKey(c, source, u_strlen(source), sortKey1, sortklen+1); - + sortklen=ucol_getSortKey(c, target, u_strlen(target), NULL, 0); sortKey2=(uint8_t*)malloc(sizeof(uint8_t) * (sortklen+1)); ucol_getSortKey(c, target, u_strlen(target), sortKey2, sortklen+1); - + res = memcmp(sortKey1, sortKey2, sortklen); if (res < 0) keyResult = (UCollationResult)-1; else if (res > 0) keyResult = (UCollationResult)1; diff --git a/icu4c/source/test/cintltst/cdantst.c b/icu4c/source/test/cintltst/cdantst.c index bc50be0352..d1f24680d1 100644 --- a/icu4c/source/test/cintltst/cdantst.c +++ b/icu4c/source/test/cintltst/cdantst.c @@ -18,6 +18,8 @@ * collation rules as its sorting sequence. */ +#include +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" @@ -25,7 +27,6 @@ #include "ccolltst.h" #include "cdantst.h" #include "unicode/ustring.h" -#include static UCollator *myCollation; const static UChar testSourceCases[][MAX_TOKEN_LEN] = { diff --git a/icu4c/source/test/cintltst/cdattst.c b/icu4c/source/test/cintltst/cdattst.c index a3659070ba..310d56e7cd 100644 --- a/icu4c/source/test/cintltst/cdattst.c +++ b/icu4c/source/test/cintltst/cdattst.c @@ -15,6 +15,9 @@ /* C API TEST FOR DATE FORMAT */ +#include +#include +#include #include "unicode/uloc.h" #include "unicode/utypes.h" #include "unicode/udat.h" @@ -23,8 +26,6 @@ #include "unicode/ustring.h" #include "cintltst.h" #include "cdattst.h" -#include -#include #include "cformtst.h" diff --git a/icu4c/source/test/cintltst/cdetst.c b/icu4c/source/test/cintltst/cdetst.c index cc0248699a..0fd4a5bdfb 100644 --- a/icu4c/source/test/cintltst/cdetst.c +++ b/icu4c/source/test/cintltst/cdetst.c @@ -18,6 +18,7 @@ * collation rules as its sorting sequence. */ +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" diff --git a/icu4c/source/test/cintltst/cdtdptst.c b/icu4c/source/test/cintltst/cdtdptst.c index 91c5eb877a..dcc1a92fd1 100644 --- a/icu4c/source/test/cintltst/cdtdptst.c +++ b/icu4c/source/test/cintltst/cdtdptst.c @@ -14,6 +14,9 @@ */ /* INDEPTH TEST FOR DATE FORMAT */ +#include +#include +#include #include "unicode/uloc.h" #include "unicode/utypes.h" #include "unicode/udat.h" @@ -23,8 +26,6 @@ #include "cintltst.h" #include "cdtdptst.h" #include "cformtst.h" -#include -#include void addDtFrDepTest(TestNode** root) { diff --git a/icu4c/source/test/cintltst/cdtrgtst.c b/icu4c/source/test/cintltst/cdtrgtst.c index 0daa192df7..f88359fd6b 100644 --- a/icu4c/source/test/cintltst/cdtrgtst.c +++ b/icu4c/source/test/cintltst/cdtrgtst.c @@ -15,6 +15,9 @@ */ /* REGRESSION TEST FOR DATE FORMAT */ +#include +#include +#include #include "unicode/uloc.h" #include "unicode/utypes.h" #include "unicode/udat.h" @@ -23,8 +26,6 @@ #include "unicode/ustring.h" #include "cintltst.h" #include "cdtrgtst.h" -#include -#include void addDateForRgrTest(TestNode** root) diff --git a/icu4c/source/test/cintltst/cestst.c b/icu4c/source/test/cintltst/cestst.c index 31d5b1f3db..6041cc637d 100644 --- a/icu4c/source/test/cintltst/cestst.c +++ b/icu4c/source/test/cintltst/cestst.c @@ -18,6 +18,7 @@ * collation rules as its sorting sequence. */ +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" diff --git a/icu4c/source/test/cintltst/cfintst.c b/icu4c/source/test/cintltst/cfintst.c index f2f87b07d0..4c9de55ed0 100644 --- a/icu4c/source/test/cintltst/cfintst.c +++ b/icu4c/source/test/cintltst/cfintst.c @@ -18,6 +18,7 @@ * collation rules as its sorting sequence. */ +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" diff --git a/icu4c/source/test/cintltst/cformtst.c b/icu4c/source/test/cintltst/cformtst.c index a1d6728a84..00dd303830 100644 --- a/icu4c/source/test/cintltst/cformtst.c +++ b/icu4c/source/test/cintltst/cformtst.c @@ -15,6 +15,7 @@ /* FormatTest is a medium top level test for everything in the C FORMAT API */ +#include #include "cintltst.h" #include "cformtst.h" @@ -29,17 +30,17 @@ void addDtFrDepTest(TestNode**); void checkHeap() { - int i; - void *n[2048]; + int i; + void *n[2048]; - log_info("checkHeap..."); + log_info("checkHeap..."); - - for(i=0;i<1;i++) + + for(i=0;i<1;i++) { - n[i]= malloc(i+15); + n[i]= malloc(i+15); } - + /* for(i=0;i<2048;i++) { free(n[i]); @@ -67,8 +68,8 @@ void addFormatTest(TestNode** root) addMsgForTest(root); addDateForRgrTest(root); addDtFrDepTest(root); - - + + } /*INternal functions used*/ @@ -78,7 +79,7 @@ UChar* myDateFormat(UDateFormat* dat, UDate d1) int32_t resultlength, resultlengthneeded; UFieldPosition pos; UErrorCode status = U_ZERO_ERROR; - + resultlength=0; resultlengthneeded=udat_format(dat, d1, NULL, resultlength, &pos, &status); diff --git a/icu4c/source/test/cintltst/cfrtst.c b/icu4c/source/test/cintltst/cfrtst.c index 93313bbb2b..7f480e69ea 100644 --- a/icu4c/source/test/cintltst/cfrtst.c +++ b/icu4c/source/test/cintltst/cfrtst.c @@ -18,6 +18,7 @@ * collation rules as its sorting sequence. */ +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" @@ -152,10 +153,10 @@ void doTest(UCollator* myCollation, const UChar source[], const UChar target[], sortKey1=(uint8_t*)malloc(sizeof(uint8_t) * (sortklenmax+1)); ucol_getSortKey(myCollation, source, u_strlen(source), sortKey1, sortklen1+1); - + sortKey2=(uint8_t*)malloc(sizeof(uint8_t) * (sortklenmax+1)); ucol_getSortKey(myCollation, target, u_strlen(target), sortKey2, sortklen2+1); - + temp= memcmp(sortKey1, sortKey2, sortklenmin); if(temp < 0) keyResult=UCOL_LESS; @@ -168,7 +169,7 @@ void doTest(UCollator* myCollation, const UChar source[], const UChar target[], void TestTertiary( ) { - + int32_t i; UErrorCode status = U_ZERO_ERROR; myCollation = ucol_open("fr_FR", &status); diff --git a/icu4c/source/test/cintltst/cg7coll.c b/icu4c/source/test/cintltst/cg7coll.c index 36be392f3d..4f69301dfe 100644 --- a/icu4c/source/test/cintltst/cg7coll.c +++ b/icu4c/source/test/cintltst/cg7coll.c @@ -34,6 +34,9 @@ * co-p * cop */ +#include +#include +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" @@ -41,8 +44,6 @@ #include "cg7coll.h" #include "ccolltst.h" #include "unicode/ustring.h" -#include -#include const char* locales[8] = { @@ -162,9 +163,9 @@ void doTest(UCollator *myCollation, const UChar source[], const UChar target[], int32_t temp; UCollationResult compareResult, keyResult; uint8_t *sortKey1, *sortKey2; - + compareResult = ucol_strcoll(myCollation, source, u_strlen(source), target, u_strlen(target)); - + sortklen1=ucol_getSortKey(myCollation, source, u_strlen(source), NULL, 0); sortklen2=ucol_getSortKey(myCollation, target, u_strlen(target), NULL, 0); @@ -173,10 +174,10 @@ void doTest(UCollator *myCollation, const UChar source[], const UChar target[], sortKey1=(uint8_t*)malloc(sizeof(uint8_t) * (sortklenmax+1)); ucol_getSortKey(myCollation, source, u_strlen(source), sortKey1, sortklen1+1); - + sortKey2=(uint8_t*)malloc(sizeof(uint8_t) * (sortklenmax+1)); ucol_getSortKey(myCollation, target, u_strlen(target), sortKey2, sortklen2+1); - + temp= memcmp(sortKey1, sortKey2, sortklenmin); if(temp < 0) keyResult=UCOL_LESS; diff --git a/icu4c/source/test/cintltst/cintltst.c b/icu4c/source/test/cintltst/cintltst.c index b757b111ae..8338b6162a 100644 --- a/icu4c/source/test/cintltst/cintltst.c +++ b/icu4c/source/test/cintltst/cintltst.c @@ -15,6 +15,9 @@ /*The main root for C API tests*/ +#include +#include +#include #include "unicode/utypes.h" #include "cintltst.h" @@ -22,8 +25,6 @@ U_CDECL_BEGIN #include "cucdtst.h" U_CDECL_END -#include -#include #include "unicode/uchar.h" #include "unicode/ustring.h" #include "unicode/ucnv.h" diff --git a/icu4c/source/test/cintltst/citertst.c b/icu4c/source/test/cintltst/citertst.c index 0f83d0e7a4..12d96844a7 100644 --- a/icu4c/source/test/cintltst/citertst.c +++ b/icu4c/source/test/cintltst/citertst.c @@ -16,6 +16,8 @@ * (Let me reiterate my position...) */ +#include +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" @@ -31,14 +33,14 @@ UCollator *en_us=0; void addCollIterTest(TestNode** root) { - - + + addTest(root, &TestPrevious, "tscoll/citertst/TestPrevious"); addTest(root, &TestOffset, "tscoll/citertst/TestOffset"); addTest(root, &TestSetText, "tscoll/citertst/TestSetText"); addTest(root, &TestMaxExpansion, "tscoll/citertst/TestMaxExpansion"); - - + + } @@ -60,7 +62,7 @@ void TestPrevious() u_uastrcpy(test1, "What subset of all possible test cases?"); u_uastrcpy(test2, "has the highest probability of detecting"); en_us = ucol_open("en_US", &status); - + iter=ucol_openElements(en_us, test1, u_strlen(test1), &status); if(U_FAILURE(status)){ log_err("ERROR: in creation of collation element iterator using ucol_openElements()\n %s\n", @@ -192,7 +194,7 @@ void TestOffset() { assertEqual(iter, pristine); } - + ucol_closeElements(pristine); ucol_closeElements(iter); free(orders); @@ -290,7 +292,7 @@ void backAndForth(UCollationElements *iter) if (index != 0) { - + log_err("Didn't get back to beginning - index is %d\n", index); ucol_reset(iter); @@ -336,17 +338,17 @@ void TestMaxExpansion() 0x65, 2, 0x66, 4 }; - + u_uastrcpy(rule1, "< a & ae = "); u_strcat(rule1, singleUChar); u_uastrcpy(temp, " < b < e"); u_strcat(rule1, temp); verifyExpansion(rule1, test1, ARRAY_LENGTH(test1)); - + /* Now a more complicated one: "a1" --> "ae" "z" --> "aeef" */ - + u_uastrcpy(rule1, ""); u_uastrcpy(rule1, "< a & ae = a1 & aeef = z < b < e < f"); verifyExpansion(rule1, test2, ARRAY_LENGTH(test2)); @@ -387,8 +389,8 @@ void verifyExpansion(UChar* rules, const UChar expansionTests[], int32_t testCou /* First get the collation key that the test string expands to */ UChar test[2] = { 0, 0} ; - test[0] = expansionTests[i+0]; - + test[0] = expansionTests[i+0]; + ucol_setText(iter, test, u_strlen(test), &status); if (U_FAILURE(status)) { log_err("call to ucol_setText(iter, test, length) failed."); @@ -400,15 +402,15 @@ void verifyExpansion(UChar* rules, const UChar expansionTests[], int32_t testCou log_err("call to iter->next() failed."); return; } - + /*if (order == UCOL_NULLORDER || ucol_next(iter, &status) != UCOL_NULLORDER) { ucol_reset(iter); log_err("verifyExpansion: \'%s\' has multiple orders\n", austrdup(test)); }*/ - + expansion = ucol_getMaxExpansion(iter, order); expect = expansionTests[i+1]; - + if (expansion != expect) { log_err("Expansion for \'%s\' is wrong. Expected %d, Got %d\n", austrdup(test), expect, expansion); } @@ -431,8 +433,8 @@ int32_t* getOrders(UCollationElements *iter, int32_t *orderLength) int32_t *orders =(int32_t*)malloc(sizeof(int32_t) * maxSize); status= U_ZERO_ERROR; - - + + while ((order=ucol_next(iter, &status)) != UCOL_NULLORDER) { if (size == maxSize) @@ -445,21 +447,21 @@ int32_t* getOrders(UCollationElements *iter, int32_t *orderLength) orders = temp; } - + orders[size++] = order; - - - + + + } if (maxSize > size) { temp = (int32_t*)malloc(sizeof(int32_t) * size); - + memcpy(temp, orders, size * sizeof(int32_t)); free(orders); orders = temp; - + } /* ucol_previous(iter, &status); */ @@ -478,7 +480,7 @@ void assertEqual(UCollationElements *i1, UCollationElements *i2) { c1 = ucol_next(i1, &status); c2 = ucol_next(i2, &status); - + if (c1 != c2) { log_err("Error in iteration %d assetEqual between\n %d and %d, they are not equal\n", count, c1, c2); diff --git a/icu4c/source/test/cintltst/cjaptst.c b/icu4c/source/test/cintltst/cjaptst.c index 58c07c60af..73a2150585 100644 --- a/icu4c/source/test/cintltst/cjaptst.c +++ b/icu4c/source/test/cintltst/cjaptst.c @@ -18,6 +18,7 @@ * collation rules as its sorting sequence. */ +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" diff --git a/icu4c/source/test/cintltst/cloctst.c b/icu4c/source/test/cintltst/cloctst.c index fc7f2b6cff..c9b5ad4895 100644 --- a/icu4c/source/test/cintltst/cloctst.c +++ b/icu4c/source/test/cintltst/cloctst.c @@ -12,12 +12,13 @@ * Madhu Katragadda Ported for C API ********************************************************************************* */ +#include +#include +#include #include "unicode/utypes.h" #include "unicode/utypes.h" #include "cloctst.h" #include "unicode/uloc.h" -#include -#include #include "unicode/ustring.h" #include "cintltst.h" #include "ccolltst.h" diff --git a/icu4c/source/test/cintltst/cmsgtst.c b/icu4c/source/test/cintltst/cmsgtst.c index 4d2158392b..e162f18551 100644 --- a/icu4c/source/test/cintltst/cmsgtst.c +++ b/icu4c/source/test/cintltst/cmsgtst.c @@ -14,6 +14,9 @@ */ /* C API TEST FOR MESSAGE FORMAT */ +#include +#include +#include #include "unicode/uloc.h" #include "unicode/utypes.h" #include "unicode/umsg.h" @@ -22,8 +25,6 @@ #include "unicode/ustring.h" #include "cintltst.h" #include "cmsgtst.h" -#include -#include #include "cformtst.h" static const char* txt_testCasePatterns[] = { diff --git a/icu4c/source/test/cintltst/cnmdptst.c b/icu4c/source/test/cintltst/cnmdptst.c index 73dbf9589a..a3f033f080 100644 --- a/icu4c/source/test/cintltst/cnmdptst.c +++ b/icu4c/source/test/cintltst/cnmdptst.c @@ -17,14 +17,15 @@ /* C DEPTH TEST FOR NUMBER FORMAT */ +#include +#include +#include #include "unicode/uloc.h" #include "unicode/utypes.h" #include "unicode/unum.h" #include "unicode/ustring.h" #include "cintltst.h" #include "cnmdptst.h" -#include -#include #define CHECK(status,str) if (U_FAILURE(status)) { log_err("FAIL: %s\n", str); return; } @@ -64,38 +65,38 @@ void TestPatterns(void) u_uastrcpy(upat, pat[i]); fmt= unum_openPattern(upat, u_strlen(upat), "en_US", &status); if (U_FAILURE(status)) { - log_err("FAIL: Number format constructor failed for pattern %s\n", pat[i]); - continue; + log_err("FAIL: Number format constructor failed for pattern %s\n", pat[i]); + continue; } lneed=0; lneed=unum_toPattern(fmt, FALSE, NULL, lneed, &status); if(status==U_BUFFER_OVERFLOW_ERROR){ - status= U_ZERO_ERROR; - unewp=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); - unum_toPattern(fmt, FALSE, unewp, lneed+1, &status); + status= U_ZERO_ERROR; + unewp=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); + unum_toPattern(fmt, FALSE, unewp, lneed+1, &status); } if(U_FAILURE(status)){ - log_err("FAIL: Number format extracting the pattern failed for %s\n", pat[i]); + log_err("FAIL: Number format extracting the pattern failed for %s\n", pat[i]); } u_uastrcpy(unewpat, newpat[i]); if(u_strcmp(unewp, unewpat) != 0) - log_err("FAIL: Pattern %s should be transmute to %s; %s seen instead\n", pat[i], newpat[i], austrdup(unewp) ); - + log_err("FAIL: Pattern %s should be transmute to %s; %s seen instead\n", pat[i], newpat[i], austrdup(unewp) ); + lneed=0; lneed=unum_format(fmt, 0, NULL, lneed, &pos, &status); if(status==U_BUFFER_OVERFLOW_ERROR){ - status=U_ZERO_ERROR; - str=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); - unum_format(fmt, 0, str, lneed+1, &pos, &status); + status=U_ZERO_ERROR; + str=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); + unum_format(fmt, 0, str, lneed+1, &pos, &status); } - if(U_FAILURE(status)) { - log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) ); + if(U_FAILURE(status)) { + log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) ); } u_uastrcpy(unum, num[i]); if (u_strcmp(str, unum) != 0) { - log_err("FAIL: Pattern %s should format zero as %s; %s Seen instead\n", pat[i], num[i], austrdup(str) ); - + log_err("FAIL: Pattern %s should format zero as %s; %s Seen instead\n", pat[i], num[i], austrdup(str) ); + } free(unewp); free(str); @@ -126,7 +127,7 @@ void TestQuotes(void) str=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); unum_format(fmt, 123, str, lneed+1, &pos, &status); } - if(U_FAILURE(status)) { + if(U_FAILURE(status)) { log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) ); } log_verbose("Pattern \"%s\" \n", austrdup(pat) ); @@ -137,12 +138,12 @@ void TestQuotes(void) free(str); unum_close(fmt); - - + + u_uastrcpy(pat, ""); u_uastrcpy(pat, "a''b#"); - - + + fmt =unum_openPattern(pat, u_strlen(pat), "en_US", &status); if(U_FAILURE(status)){ log_err("Error in number format costruction using pattern \"a''b#\"\n"); @@ -154,7 +155,7 @@ void TestQuotes(void) str=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); unum_format(fmt, 123, str, lneed+1, &pos, &status); } - if(U_FAILURE(status)) { + if(U_FAILURE(status)) { log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) ); } log_verbose("Pattern \"%s\" \n", austrdup(pat) ); @@ -163,7 +164,7 @@ void TestQuotes(void) u_uastrcpy(res, "a'b123"); if(u_strcmp(str, res) != 0) log_err("FAIL: Expected a'b123\n"); - + free(str); unum_close(fmt); } @@ -189,7 +190,7 @@ void TestExponential(void) #endif const char* pat[] = { "0.####E0", "00.000E00", "##0.######E000", "0.###E0;[0.###E0]" }; int32_t lval[] = { 0, -1, 1, 123456789 }; - + const char* valFormat[] = { "1.234E-2", "1.2346E8", "1.23E300", "-3.1416E-271", @@ -238,74 +239,74 @@ void TestExponential(void) u_uastrcpy(upat, pat[p]); fmt=unum_openPattern(upat, u_strlen(upat), "en_US", &status); if (U_FAILURE(status)) { - log_err("FAIL: Bad status returned by Number format construction with pattern %s\n, pat[i]"); - continue; + log_err("FAIL: Bad status returned by Number format construction with pattern %s\n, pat[i]"); + continue; } lneed= u_strlen(upat) + 1; unum_toPattern(fmt, FALSE, pattern, lneed, &status); log_verbose("Pattern \" %s \" -toPattern-> \" %s \" \n", upat, austrdup(pattern) ); for (v=0; v %e\n", ppos, a); - - free(str); - } + + + u_uastrcpy(uvalfor, valFormat[v+ival]); + if(u_strcmp(str, uvalfor) != 0) + log_verbose("FAIL: Expected %s ( %s )\n", valFormat[v+ival], austrdup(uvalfor) ); + + /*parsing*/ + ppos=0; + a=unum_parseDouble(fmt, str, u_strlen(str), &ppos, &status); + if (ppos== u_strlen(str)) { + if (a != valParse[v+ival]) + printf("FAIL: Expected : %e\n", valParse[v+ival]); + } + else + printf(" FAIL: Partial parse ( %d chars ) -> %e\n", ppos, a); + + free(str); + } for (v=0; v %s\n", lval[v], austrdup(str) );*/ - u_uastrcpy(ulvalfor, lvalFormat[v+ilval]); - if(u_strcmp(str, ulvalfor) != 0) - log_err("FAIL: Expected %s ( %s )\n", valFormat[v+ilval], austrdup(ulvalfor) ); + /*format*/ + lneed=0; + lneed=unum_formatDouble(fmt, lval[v], NULL, lneed, &pos, &status); + if(status==U_BUFFER_OVERFLOW_ERROR){ + status=U_ZERO_ERROR; + str=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); + unum_formatDouble(fmt, lval[v], str, lneed+1, &pos, &status); + } + if(U_FAILURE(status)) { + log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) ); + } + /*printf(" Format %e -> %s\n", lval[v], austrdup(str) );*/ + u_uastrcpy(ulvalfor, lvalFormat[v+ilval]); + if(u_strcmp(str, ulvalfor) != 0) + log_err("FAIL: Expected %s ( %s )\n", valFormat[v+ilval], austrdup(ulvalfor) ); - /*parsing*/ - ppos=0; - a=unum_parseDouble(fmt, str, u_strlen(str), &ppos, &status); - if (ppos== u_strlen(str)) { - /*printf(" Parse -> %e\n", a);*/ - if (a != lvalParse[v+ilval]) - printf("FAIL: Expected : %e\n", valParse[v+ival]); - } - else - printf(" FAIL: Partial parse ( %d chars ) -> %e\n", ppos, a); - - free(str); + /*parsing*/ + ppos=0; + a=unum_parseDouble(fmt, str, u_strlen(str), &ppos, &status); + if (ppos== u_strlen(str)) { + /*printf(" Parse -> %e\n", a);*/ + if (a != lvalParse[v+ilval]) + printf("FAIL: Expected : %e\n", valParse[v+ival]); + } + else + printf(" FAIL: Partial parse ( %d chars ) -> %e\n", ppos, a); + + free(str); } ival += val_length; @@ -342,7 +343,7 @@ void TestCurrencySign(void) str=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); unum_formatDouble(fmt, 1234.56, str, lneed+1, &pos, &status); } - if(U_FAILURE(status)) { + if(U_FAILURE(status)) { log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) ); } lneed=0; @@ -354,7 +355,7 @@ void TestCurrencySign(void) } log_verbose("Pattern \" %s \" \n", austrdup(pat)); log_verbose("Format 1234.56 -> %s\n", austrdup(str) ); - + res=(UChar*)malloc(sizeof(UChar) * (strlen("$1,234.56")+1) ); u_uastrcpy(res, "$1,234.56"); if (u_strcmp(str, res) !=0) log_err("FAIL: Expected $1,234.56\n"); @@ -369,7 +370,7 @@ void TestCurrencySign(void) str=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); unum_formatDouble(fmt, -1234.56, str, lneed+1, &pos, &status); } - if(U_FAILURE(status)) { + if(U_FAILURE(status)) { log_err("Error in formatting using unum_format(.....): %s\n", myErrorName(status) ); } res=(UChar*)malloc(sizeof(UChar) * (strlen("-$1,234.56")+1) ); @@ -397,18 +398,19 @@ void TestCurrency(void) for(i=0; i < 3; i++) { currencyFmt = unum_open(UNUM_CURRENCY, locale[i], &status); - if(U_FAILURE(status)){log_err("Error in the construction of number format with style currency:\n%s\n", - myErrorName(status)); + if(U_FAILURE(status)){ + log_err("Error in the construction of number format with style currency:\n%s\n", + myErrorName(status)); } lneed=0; lneed= unum_formatDouble(currencyFmt, 1.50, NULL, lneed, &pos, &status); if(status==U_BUFFER_OVERFLOW_ERROR){ - status=U_ZERO_ERROR; - str=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); - unum_formatDouble(currencyFmt, 1.50, str, lneed+1, &pos, &status); + status=U_ZERO_ERROR; + str=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); + unum_formatDouble(currencyFmt, 1.50, str, lneed+1, &pos, &status); } - if(U_FAILURE(status)) { - log_err("Error in formatting using unum_formatDouble(.....): %s\n", myErrorName(status) ); + if(U_FAILURE(status)) { + log_err("Error in formatting using unum_formatDouble(.....): %s\n", myErrorName(status) ); } res=(UChar*)malloc(sizeof(UChar) * (strlen(result[i])+1) ); u_uastrcpy(res, result[i]); @@ -460,7 +462,7 @@ void roundingTest(UNumberFormat* nf, double x, int32_t maxFractionDigits, const out=(UChar*)malloc(sizeof(UChar) * (lneed+1) ); unum_formatDouble(nf, x, out, lneed+1, &pos, &status); } - if(U_FAILURE(status)) { + if(U_FAILURE(status)) { log_err("Error in formatting using unum_formatDouble(.....): %s\n", myErrorName(status) ); } /*Need to use log_verbose here. Problem with the float*/ @@ -478,27 +480,27 @@ void roundingTest(UNumberFormat* nf, double x, int32_t maxFractionDigits, const */ void TestDoubleAttribute(void) { - double mydata[] = { 1.11, 22.22, 333.33, 4444.44, 55555.55, 666666.66, 7777777.77, 88888888.88, 999999999.99}; - double dvalue; - int i; - UErrorCode status=U_ZERO_ERROR; - UNumberFormatAttribute attr; - UNumberFormatStyle style= UNUM_DEFAULT; - UNumberFormat *def; - def=unum_open(style, NULL, &status); + double mydata[] = { 1.11, 22.22, 333.33, 4444.44, 55555.55, 666666.66, 7777777.77, 88888888.88, 999999999.99}; + double dvalue; + int i; + UErrorCode status=U_ZERO_ERROR; + UNumberFormatAttribute attr; + UNumberFormatStyle style= UNUM_DEFAULT; + UNumberFormat *def; + def=unum_open(style, NULL, &status); log_verbose("\nTesting get and set DoubleAttributes\n"); attr=UNUM_ROUNDING_INCREMENT; dvalue=unum_getDoubleAttribute(def, attr); for (i = 0; i<9 ; i++) - { - dvalue = mydata[i]; - unum_setDoubleAttribute(def, attr, dvalue); - if(unum_getDoubleAttribute(def,attr)!=mydata[i]) - log_err("Fail: error in setting and getting double attributes for UNUM_ROUNDING_INCREMENT\n"); - else - log_verbose("Pass: setting and getting double attributes for UNUM_ROUNDING_INCREMENT works fine\n"); - } - unum_close(def); + { + dvalue = mydata[i]; + unum_setDoubleAttribute(def, attr, dvalue); + if(unum_getDoubleAttribute(def,attr)!=mydata[i]) + log_err("Fail: error in setting and getting double attributes for UNUM_ROUNDING_INCREMENT\n"); + else + log_verbose("Pass: setting and getting double attributes for UNUM_ROUNDING_INCREMENT works fine\n"); + } + unum_close(def); } /** diff --git a/icu4c/source/test/cintltst/cnormtst.c b/icu4c/source/test/cintltst/cnormtst.c index 42fa59fb52..062f30a4b2 100644 --- a/icu4c/source/test/cintltst/cnormtst.c +++ b/icu4c/source/test/cintltst/cnormtst.c @@ -12,6 +12,7 @@ * Madhu Katragadda Ported for C API *********************************************************************************/ /*tests for u_normalization*/ +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" @@ -123,8 +124,9 @@ void TestDecomp() assertEqual(result, CharsToUChars(canonTests[x][1]), x); free(result); } - ucol_close(myCollation); + ucol_close(myCollation); } + void TestCompatDecomp() { UErrorCode status = U_ZERO_ERROR; diff --git a/icu4c/source/test/cintltst/cnumtst.c b/icu4c/source/test/cintltst/cnumtst.c index bae15bc67d..d0b2c6b346 100644 --- a/icu4c/source/test/cintltst/cnumtst.c +++ b/icu4c/source/test/cintltst/cnumtst.c @@ -19,13 +19,14 @@ /* C API TEST FOR NUMBER FORMAT */ +#include +#include #include "unicode/uloc.h" #include "unicode/utypes.h" #include "unicode/unum.h" #include "unicode/ustring.h" #include "cintltst.h" #include "cnumtst.h" -#include /* ### remove this include after the number format test is fixed with jitterbug 411, applyPattern() */ #include "cstring.h" diff --git a/icu4c/source/test/cintltst/cregrtst.c b/icu4c/source/test/cintltst/cregrtst.c index 523498ec1d..9b7317328b 100644 --- a/icu4c/source/test/cintltst/cregrtst.c +++ b/icu4c/source/test/cintltst/cregrtst.c @@ -15,6 +15,7 @@ /* C FUNCTIONALITY AND REGRESSION TEST FOR BREAKITERATOR */ +#include #include #include #include "unicode/uloc.h" diff --git a/icu4c/source/test/cintltst/crestst.c b/icu4c/source/test/cintltst/crestst.c index 66c5213375..5f320014e4 100644 --- a/icu4c/source/test/cintltst/crestst.c +++ b/icu4c/source/test/cintltst/crestst.c @@ -15,13 +15,14 @@ */ +#include +#include #include "unicode/utypes.h" #include "cintltst.h" #include "unicode/utypes.h" #include "unicode/ustring.h" #include "string.h" #include "cstring.h" -#include #define RESTEST_HEAP_CHECK 0 @@ -289,329 +290,327 @@ UBool testTag(const char* frag, UBool in_te, UBool in_te_IN) { - UBool pass=TRUE; + UBool pass=TRUE; - /* Make array from input params */ + /* Make array from input params */ - UBool is_in[3]; - const char *NAME[] = { "ROOT", "TE", "TE_IN" }; + UBool is_in[3]; + const char *NAME[] = { "ROOT", "TE", "TE_IN" }; - /* Now try to load the desired items */ - UResourceBundle* theBundle = NULL; - char tag[99]; - char action[256]; - UErrorCode expected_status,status = U_ZERO_ERROR,expected_resource_status = U_ZERO_ERROR; - UChar* base = NULL; - UChar* expected_string = NULL; - const UChar* string = NULL; - char buf[5]; - char item_tag[10]; - int32_t i,j,k,row,col; - int32_t actual_bundle; - int32_t count = 0; - int32_t row_count=0; - int32_t column_count=0; - int32_t index = 0; - char testdatapath[256]; + /* Now try to load the desired items */ + UResourceBundle* theBundle = NULL; + char tag[99]; + char action[256]; + UErrorCode expected_status,status = U_ZERO_ERROR,expected_resource_status = U_ZERO_ERROR; + UChar* base = NULL; + UChar* expected_string = NULL; + const UChar* string = NULL; + char buf[5]; + char item_tag[10]; + int32_t i,j,k,row,col; + int32_t actual_bundle; + int32_t count = 0; + int32_t row_count=0; + int32_t column_count=0; + int32_t index = 0; + char testdatapath[256]; - const char* directory = ctest_getTestDirectory(); + const char* directory = ctest_getTestDirectory(); - uprv_strcpy(testdatapath, directory); - uprv_strcat(testdatapath, "testdata"); + uprv_strcpy(testdatapath, directory); + uprv_strcat(testdatapath, "testdata"); - is_in[0] = in_Root; - is_in[1] = in_te; - is_in[2] = in_te_IN; + is_in[0] = in_Root; + is_in[1] = in_te; + is_in[2] = in_te_IN; - strcpy(item_tag, "tag"); + strcpy(item_tag, "tag"); - status = U_ZERO_ERROR; - theBundle = ures_open(testdatapath, "root", &status); - if(U_FAILURE(status)) - { - ures_close(theBundle); - log_err("Couldn't open root bundle in %s", testdatapath); - return FALSE; - } - ures_close(theBundle); - theBundle = NULL; - - - for (i=0; i default */ - else if(i == 3) - actual_bundle = 1; /* te_NE -> te */ - else if(i == 4) - actual_bundle = 2; /* te_IN_NE -> te_IN */ - else - actual_bundle = i; - - expected_resource_status = U_MISSING_RESOURCE_ERROR; - for (j=e_te_IN; j>=e_Root; --j) - { - if (is_in[j] && param[i].inherits[j]) - { - - if(j == actual_bundle) /* it's in the same bundle OR it's a nonexistent=default bundle (5) */ - expected_resource_status = U_ZERO_ERROR; - else if(j == 0) - expected_resource_status = U_USING_DEFAULT_ERROR; - else - expected_resource_status = U_USING_FALLBACK_ERROR; - - log_verbose("%s[%d]::%s: in<%d:%s> inherits<%d:%s>. actual_bundle=%s\n", - param[i].name, - i, - frag, - j, - is_in[j]?"Yes":"No", - j, - param[i].inherits[j]?"Yes":"No", - param[actual_bundle].name); - - break; - } - } - - for (j=param[i].where; j>=0; --j) - { - if (is_in[j]) - { - if(base != NULL) { - free(base); - base = NULL; - } - - base=(UChar*)malloc(sizeof(UChar)*(strlen(NAME[j]) + 1)); - u_uastrcpy(base,NAME[j]); - - break; - } - else { - if(base != NULL) { - free(base); - base = NULL; - } - base = (UChar*) malloc(sizeof(UChar) * 1); - *base = 0x0000; - } - } - - /*-------------------------------------------------------------------- */ - /* string */ - - strcpy(tag,"string_"); - strcat(tag,frag); - - strcpy(action,param[i].name); - strcat(action, ".ures_get(" ); - strcat(action,tag); - strcat(action, ")"); - - string= kERROR; - - status = U_ZERO_ERROR; - - ures_get(theBundle, tag, &status); - if(U_SUCCESS(status)) - { - status = U_ZERO_ERROR; - string=ures_get(theBundle, tag, &status); - } - - log_verbose("%s got %d, expected %d\n", action, status, expected_resource_status); - - CONFIRM_ErrorCode(status, expected_resource_status); - - - if(U_SUCCESS(status)){ - expected_string=(UChar*)malloc(sizeof(UChar)*(u_strlen(base) + 3)); - u_strcpy(expected_string,base); - - - } - else + for (i=0; i default */ + else if(i == 3) + actual_bundle = 1; /* te_NE -> te */ + else if(i == 4) + actual_bundle = 2; /* te_IN_NE -> te_IN */ + else + actual_bundle = i; - - - /*-------------------------------------------------------------------- */ - /*-------------------------------------------------------------------- */ - /* arrayItem */ - - strcpy(tag,"array_"); - strcat(tag,frag); - - strcpy(action,param[i].name); - strcat(action, ".ures_getArrayItem("); - strcat(action, tag); - strcat(action, ")"); - count=ures_countArrayItems(theBundle, tag, &status); - - - for(j = 0; j < count; j++) + expected_resource_status = U_MISSING_RESOURCE_ERROR; + for (j=e_te_IN; j>=e_Root; --j) { - - status = U_ZERO_ERROR; - string = kERROR; - - index=j; - ures_getArrayItem(theBundle, tag,index , &status); - if(U_SUCCESS(status)) - string=ures_getArrayItem(theBundle, tag, index, &status); - - - /* how could 'index==j' ever be >= count ? */ - expected_status = (index >= 0 && index < count) ? expected_resource_status : U_MISSING_RESOURCE_ERROR; - - log_verbose("Status for %s was %d, expected %d\n", action, status, expected_status); - - CONFIRM_ErrorCode(status,expected_status); - - if (U_SUCCESS(status)) + if (is_in[j] && param[i].inherits[j]) { - UChar element[3]; - u_uastrcpy(element, itoa1(index,buf)); - - u_strcpy(expected_string,base); - u_strcat(expected_string,element); + if(j == actual_bundle) /* it's in the same bundle OR it's a nonexistent=default bundle (5) */ + expected_resource_status = U_ZERO_ERROR; + else if(j == 0) + expected_resource_status = U_USING_DEFAULT_ERROR; + else + expected_resource_status = U_USING_FALLBACK_ERROR; + log_verbose("%s[%d]::%s: in<%d:%s> inherits<%d:%s>. actual_bundle=%s\n", + param[i].name, + i, + frag, + j, + is_in[j]?"Yes":"No", + j, + param[i].inherits[j]?"Yes":"No", + param[actual_bundle].name); + break; } - else + } + + for (j=param[i].where; j>=0; --j) + { + if (is_in[j]) { - u_strcpy(expected_string,kERROR); + if(base != NULL) { + free(base); + base = NULL; + } + + base=(UChar*)malloc(sizeof(UChar)*(strlen(NAME[j]) + 1)); + u_uastrcpy(base,NAME[j]); + + break; } - CONFIRM_EQ(string,expected_string); + else { + if(base != NULL) { + free(base); + base = NULL; + } + base = (UChar*) malloc(sizeof(UChar) * 1); + *base = 0x0000; + } + } + + /*-------------------------------------------------------------------- */ + /* string */ + + strcpy(tag,"string_"); + strcat(tag,frag); + + strcpy(action,param[i].name); + strcat(action, ".ures_get(" ); + strcat(action,tag); + strcat(action, ")"); + + string= kERROR; + + status = U_ZERO_ERROR; + + ures_get(theBundle, tag, &status); + if(U_SUCCESS(status)) + { + status = U_ZERO_ERROR; + string=ures_get(theBundle, tag, &status); + } + + log_verbose("%s got %d, expected %d\n", action, status, expected_resource_status); + + CONFIRM_ErrorCode(status, expected_resource_status); + + + if(U_SUCCESS(status)){ + expected_string=(UChar*)malloc(sizeof(UChar)*(u_strlen(base) + 3)); + u_strcpy(expected_string,base); + + } + else + { + expected_string = (UChar*)malloc(sizeof(UChar)*(u_strlen(kERROR) + 1)); + u_strcpy(expected_string,kERROR); + } - /*-------------------------------------------------------------------- */ - /* 2dArrayItem */ - strcpy(tag,"array_2d_"); - strcat(tag,frag); - - strcpy(action,param[i].name); - strcat(action, ".get2dArrayItem("); - strcat(action, tag); - strcat(action, ")"); - row_count=ures_countArrayItems(theBundle, tag, &status); - column_count=2; - - for(k=0;k= 0 && row < row_count && col >= 0 && col < column_count) ? - expected_resource_status : U_MISSING_RESOURCE_ERROR; - - CONFIRM_ErrorCode(status,expected_status); - - if (U_SUCCESS(status)) - { - UChar element[3]; - u_strcpy(expected_string,base); - u_uastrcpy(element,itoa1(row,buf)); - u_strcat(expected_string, element); - u_uastrcpy(element,itoa1(col,buf)); - u_strcat(expected_string, element); - - } - else - { - - u_strcpy(expected_string,kERROR); - } - CONFIRM_EQ(string,expected_string); - } - } + CONFIRM_EQ(string, expected_string); - /*-------------------------------------------------------------------- */ - /* taggedArrayItem */ + /*-------------------------------------------------------------------- */ + /*-------------------------------------------------------------------- */ + /* arrayItem */ - strcpy(tag,"tagged_array_"); - strcat(tag,frag); + strcpy(tag,"array_"); + strcat(tag,frag); - strcpy(action,param[i].name); - strcat(action,".getTaggedArrayItem("); - strcat(action, tag); - strcat(action,")"); + strcpy(action,param[i].name); + strcat(action, ".ures_getArrayItem("); + strcat(action, tag); + strcat(action, ")"); + count=ures_countArrayItems(theBundle, tag, &status); - count = 0; - for (index=-20; index<20; ++index) + + for(j = 0; j < count; j++) { - strcpy(item_tag, "tag"); - strcat(item_tag, itoa1(index,buf)); - status = U_ZERO_ERROR; - string = kERROR; + status = U_ZERO_ERROR; + string = kERROR; + + index=j; + ures_getArrayItem(theBundle, tag,index , &status); + if(U_SUCCESS(status)) + string=ures_getArrayItem(theBundle, tag, index, &status); - ures_getTaggedArrayItem( theBundle, tag, item_tag, &status); - if(U_SUCCESS(status)) - string=ures_getTaggedArrayItem(theBundle, tag, item_tag, &status); + /* how could 'index==j' ever be >= count ? */ + expected_status = (index >= 0 && index < count) ? expected_resource_status : U_MISSING_RESOURCE_ERROR; + log_verbose("Status for %s was %d, expected %d\n", action, status, expected_status); - if (index < 0) + CONFIRM_ErrorCode(status,expected_status); + + if (U_SUCCESS(status)) { - CONFIRM_ErrorCode(status,U_MISSING_RESOURCE_ERROR); + UChar element[3]; + + u_uastrcpy(element, itoa1(index,buf)); + + u_strcpy(expected_string,base); + u_strcat(expected_string,element); + + } - else - { - UChar* element; - if (strcmp(myErrorName(status),"U_MISSING_RESOURCE_ERROR")!=0) { - count++; - u_strcpy(expected_string,base); - element=(UChar*)malloc(sizeof(UChar) * (strlen(buf)+1)); - u_uastrcpy(element,buf); - u_strcat(expected_string,element); - free(element); - CONFIRM_EQ(string,expected_string); - } - } - + else + { + u_strcpy(expected_string,kERROR); + } + CONFIRM_EQ(string,expected_string); } - - free(expected_string); - ures_close(theBundle); + + + /*-------------------------------------------------------------------- */ + /* 2dArrayItem */ + + strcpy(tag,"array_2d_"); + strcat(tag,frag); + + strcpy(action,param[i].name); + strcat(action, ".get2dArrayItem("); + strcat(action, tag); + strcat(action, ")"); + row_count=ures_countArrayItems(theBundle, tag, &status); + column_count=2; + + for(k=0;k= 0 && row < row_count && col >= 0 && col < column_count) ? + expected_resource_status : U_MISSING_RESOURCE_ERROR; + + CONFIRM_ErrorCode(status,expected_status); + + if (U_SUCCESS(status)) + { + UChar element[3]; + u_strcpy(expected_string,base); + u_uastrcpy(element,itoa1(row,buf)); + u_strcat(expected_string, element); + u_uastrcpy(element,itoa1(col,buf)); + u_strcat(expected_string, element); + + } + else + { + u_strcpy(expected_string,kERROR); + } + CONFIRM_EQ(string,expected_string); + } + } + + + + /*-------------------------------------------------------------------- */ + /* taggedArrayItem */ + + strcpy(tag,"tagged_array_"); + strcat(tag,frag); + + strcpy(action,param[i].name); + strcat(action,".getTaggedArrayItem("); + strcat(action, tag); + strcat(action,")"); + + count = 0; + for (index=-20; index<20; ++index) + { + strcpy(item_tag, "tag"); + strcat(item_tag, itoa1(index,buf)); + + status = U_ZERO_ERROR; + string = kERROR; + + + ures_getTaggedArrayItem( theBundle, tag, item_tag, &status); + if(U_SUCCESS(status)) + string=ures_getTaggedArrayItem(theBundle, tag, item_tag, &status); + + + if (index < 0) + { + CONFIRM_ErrorCode(status,U_MISSING_RESOURCE_ERROR); + } + else + { + UChar* element; + if (strcmp(myErrorName(status),"U_MISSING_RESOURCE_ERROR")!=0) { + count++; + u_strcpy(expected_string,base); + element=(UChar*)malloc(sizeof(UChar) * (strlen(buf)+1)); + u_uastrcpy(element,buf); + u_strcat(expected_string,element); + free(element); + CONFIRM_EQ(string,expected_string); + } + } + + } + + free(expected_string); + ures_close(theBundle); } - free(base); - return pass; + free(base); + return pass; } void record_pass() @@ -634,7 +633,7 @@ void TestFallback() UErrorCode status = U_ZERO_ERROR; UResourceBundle *fr_FR = NULL; const UChar *junk; /* ignored */ - + log_verbose("Opening fr_FR.."); fr_FR = ures_open(NULL, "fr_FR", &status); if(U_FAILURE(status)) @@ -659,9 +658,9 @@ void TestFallback() if(status != U_USING_DEFAULT_ERROR) { log_err("Expected U_USING_DEFAULT_ERROR when trying to get Version from fr_FR, got %d\n", - status); + status); } - + status = U_ZERO_ERROR; /* and this is a Fallback, to fr */ @@ -669,10 +668,10 @@ void TestFallback() if(status != U_USING_FALLBACK_ERROR) { log_err("Expected U_USING_FALLBACK_ERROR when trying to get ShortLanguage from fr_FR, got %d\n", - status); + status); } - + status = U_ZERO_ERROR; - + ures_close(fr_FR); } diff --git a/icu4c/source/test/cintltst/creststn.c b/icu4c/source/test/cintltst/creststn.c index 983318d8ff..86d5af07be 100644 --- a/icu4c/source/test/cintltst/creststn.c +++ b/icu4c/source/test/cintltst/creststn.c @@ -15,13 +15,15 @@ */ +#include +#include +#include #include "unicode/utypes.h" #include "cintltst.h" #include "unicode/utypes.h" #include "unicode/ustring.h" #include "string.h" #include "cstring.h" -#include #define RESTEST_HEAP_CHECK 0 @@ -29,7 +31,6 @@ #include "unicode/ures.h" #include "creststn.h" #include "unicode/ctest.h" -#include /*****************************************************************************/ /** @@ -160,16 +161,15 @@ static void printUChars(UChar*); void addNEWResourceBundleTest(TestNode** root) { - addTest(root, &TestConstruction1, "tsutil/creststn/TestConstruction1"); - addTest(root, &TestConstruction2, "tsutil/creststn/TestConstruction2"); - addTest(root, &TestResourceBundles, "tsutil/creststn/TestResourceBundle"); - addTest(root, &TestFallback, "tsutil/creststn/TestFallback"); - addTest(root, &TestAliasConflict, "tsutil/creststn/TestAlias"); - addTest(root, &TestNewTypes, "tsutil/creststn/TestNewTypes"); - addTest(root, &TestBinaryCollationData, "tsutil/creststn/TestBinaryCollationData"); - addTest(root, &TestAPI, "tsutil/creststn/TestAPI"); - addTest(root, &TestErrorConditions, "tsutil/creststn/TestErrorConditions"); - + addTest(root, &TestConstruction1, "tsutil/creststn/TestConstruction1"); + addTest(root, &TestConstruction2, "tsutil/creststn/TestConstruction2"); + addTest(root, &TestResourceBundles, "tsutil/creststn/TestResourceBundle"); + addTest(root, &TestFallback, "tsutil/creststn/TestFallback"); + addTest(root, &TestAliasConflict, "tsutil/creststn/TestAlias"); + addTest(root, &TestNewTypes, "tsutil/creststn/TestNewTypes"); + addTest(root, &TestBinaryCollationData, "tsutil/creststn/TestBinaryCollationData"); + addTest(root, &TestAPI, "tsutil/creststn/TestAPI"); + addTest(root, &TestErrorConditions, "tsutil/creststn/TestErrorConditions"); } @@ -179,7 +179,7 @@ void TestAliasConflict(void) { UResourceBundle *he = NULL; UResourceBundle *iw = NULL; const UChar *result = NULL; - + he = ures_open(NULL, "he", &status); iw = ures_open(NULL, "iw", &status); if(U_FAILURE(status)) { @@ -194,88 +194,88 @@ void TestAliasConflict(void) { } void TestNewTypes() { - UResourceBundle* theBundle = NULL; - char action[256]; - char testdatapath[256]; - const char* directory = ctest_getTestDirectory(); - UErrorCode status = U_ZERO_ERROR; - UResourceBundle* res = NULL; - uint8_t *binResult = NULL; - int32_t len = 0; - int32_t i = 0; - int32_t intResult = 0; + UResourceBundle* theBundle = NULL; + char action[256]; + char testdatapath[256]; + const char* directory = ctest_getTestDirectory(); + UErrorCode status = U_ZERO_ERROR; + UResourceBundle* res = NULL; + uint8_t *binResult = NULL; + int32_t len = 0; + int32_t i = 0; + int32_t intResult = 0; - strcpy(action, "Construction of testtypes bundle"); + strcpy(action, "Construction of testtypes bundle"); - strcpy(testdatapath, directory); - strcat(testdatapath, "testdata"); - theBundle = ures_open(testdatapath, "testtypes", &status); + strcpy(testdatapath, directory); + strcat(testdatapath, "testdata"); + theBundle = ures_open(testdatapath, "testtypes", &status); - CONFIRM_ErrorCode(status, U_ZERO_ERROR); - - CONFIRM_INT_NE(theBundle, NULL); - - strcpy(action, "getting and testing of binary type"); - res = ures_getByKey(theBundle, "binarytest", res, &status); - CONFIRM_ErrorCode(status, U_ZERO_ERROR); - CONFIRM_INT_EQ(ures_getType(res), RES_BINARY); - binResult=(uint8_t*)ures_getBinary(res, &len, &status); - if(U_SUCCESS(status)){ CONFIRM_ErrorCode(status, U_ZERO_ERROR); - CONFIRM_INT_EQ(len, 15); - for(i = 0; i<15; i++) { - CONFIRM_INT_EQ(binResult[i], i); + + CONFIRM_INT_NE(theBundle, NULL); + + strcpy(action, "getting and testing of binary type"); + res = ures_getByKey(theBundle, "binarytest", res, &status); + CONFIRM_ErrorCode(status, U_ZERO_ERROR); + CONFIRM_INT_EQ(ures_getType(res), RES_BINARY); + binResult=(uint8_t*)ures_getBinary(res, &len, &status); + if(U_SUCCESS(status)){ + CONFIRM_ErrorCode(status, U_ZERO_ERROR); + CONFIRM_INT_EQ(len, 15); + for(i = 0; i<15; i++) { + CONFIRM_INT_EQ(binResult[i], i); + } } - } - strcpy(action, "getting and testing of imported binary type"); - res = ures_getByKey(theBundle, "importtest", res, &status); - CONFIRM_ErrorCode(status, U_ZERO_ERROR); - CONFIRM_INT_EQ(ures_getType(res), RES_BINARY); - binResult=(uint8_t*)ures_getBinary(res, &len, &status); - if(U_SUCCESS(status)){ + strcpy(action, "getting and testing of imported binary type"); + res = ures_getByKey(theBundle, "importtest", res, &status); CONFIRM_ErrorCode(status, U_ZERO_ERROR); - CONFIRM_INT_EQ(len, 15); - for(i = 0; i<15; i++) { - CONFIRM_INT_EQ(binResult[i], i); + CONFIRM_INT_EQ(ures_getType(res), RES_BINARY); + binResult=(uint8_t*)ures_getBinary(res, &len, &status); + if(U_SUCCESS(status)){ + CONFIRM_ErrorCode(status, U_ZERO_ERROR); + CONFIRM_INT_EQ(len, 15); + for(i = 0; i<15; i++) { + CONFIRM_INT_EQ(binResult[i], i); + } } - } - strcpy(action, "getting and testing of integer types"); - res = ures_getByKey(theBundle, "one", res, &status); - CONFIRM_ErrorCode(status, U_ZERO_ERROR); - CONFIRM_INT_EQ(ures_getType(res), RES_INT); - intResult=ures_getInt(res, &status); - if(U_SUCCESS(status)){ + strcpy(action, "getting and testing of integer types"); + res = ures_getByKey(theBundle, "one", res, &status); CONFIRM_ErrorCode(status, U_ZERO_ERROR); - CONFIRM_INT_EQ(intResult, 1); - } + CONFIRM_INT_EQ(ures_getType(res), RES_INT); + intResult=ures_getInt(res, &status); + if(U_SUCCESS(status)){ + CONFIRM_ErrorCode(status, U_ZERO_ERROR); + CONFIRM_INT_EQ(intResult, 1); + } - res = ures_getByKey(theBundle, "onehundredtwentythree", res, &status); - CONFIRM_ErrorCode(status, U_ZERO_ERROR); - CONFIRM_INT_EQ(ures_getType(res), RES_INT); - intResult=ures_getInt(res, &status); - if(U_SUCCESS(status)){ + res = ures_getByKey(theBundle, "onehundredtwentythree", res, &status); CONFIRM_ErrorCode(status, U_ZERO_ERROR); - CONFIRM_INT_EQ(intResult, 123); - } + CONFIRM_INT_EQ(ures_getType(res), RES_INT); + intResult=ures_getInt(res, &status); + if(U_SUCCESS(status)){ + CONFIRM_ErrorCode(status, U_ZERO_ERROR); + CONFIRM_INT_EQ(intResult, 123); + } - ures_close(res); - ures_close(theBundle); + ures_close(res); + ures_close(theBundle); } void TestBinaryCollationData(){ - UErrorCode status=U_ZERO_ERROR; + UErrorCode status=U_ZERO_ERROR; const char* directory=NULL; const char* locale="te"; char testdatapath[256]; - UResourceBundle *teRes = NULL; - UResourceBundle *coll=NULL; - UResourceBundle *binColl = NULL; - uint8_t *binResult = NULL; - int32_t len=0; - char* action="testing the binary collaton data"; + UResourceBundle *teRes = NULL; + UResourceBundle *coll=NULL; + UResourceBundle *binColl = NULL; + uint8_t *binResult = NULL; + int32_t len=0; + char* action="testing the binary collaton data"; directory= ctest_getTestDirectory(); uprv_strcpy(testdatapath, directory); @@ -283,34 +283,34 @@ void TestBinaryCollationData(){ log_verbose("Testing binary collation data resource......\n"); - teRes=ures_open(testdatapath, locale, &status); - if(U_FAILURE(status)){ - log_err("ERROR: Failed to get resource for \"te\" with %s", myErrorName(status)); - return; - } - status=U_ZERO_ERROR; + teRes=ures_open(testdatapath, locale, &status); + if(U_FAILURE(status)){ + log_err("ERROR: Failed to get resource for \"te\" with %s", myErrorName(status)); + return; + } + status=U_ZERO_ERROR; coll = ures_getByKey(teRes, "CollationElements", coll, &status); - if(U_SUCCESS(status)){ + if(U_SUCCESS(status)){ CONFIRM_ErrorCode(status, U_ZERO_ERROR); CONFIRM_INT_EQ(ures_getType(coll), RES_TABLE); binColl=ures_getByKey(teRes, "%%Collation", binColl, &status); - if(U_SUCCESS(status)){ - CONFIRM_ErrorCode(status, U_ZERO_ERROR); - CONFIRM_INT_EQ(ures_getType(binColl), RES_BINARY); - binResult=(uint8_t*)ures_getBinary(binColl, &len, &status); - if(U_SUCCESS(status)){ - CONFIRM_ErrorCode(status, U_ZERO_ERROR); - CONFIRM_INT_GE(len, 1); - } + if(U_SUCCESS(status)){ + CONFIRM_ErrorCode(status, U_ZERO_ERROR); + CONFIRM_INT_EQ(ures_getType(binColl), RES_BINARY); + binResult=(uint8_t*)ures_getBinary(binColl, &len, &status); + if(U_SUCCESS(status)){ + CONFIRM_ErrorCode(status, U_ZERO_ERROR); + CONFIRM_INT_GE(len, 1); + } - }else{ - log_err("ERROR: ures_getByKey(locale(te), %%Collation) failed"); - } - } - else{ - log_err("ERROR: ures_getByKey(locale(te), CollationElements) failed"); - return; - } + }else{ + log_err("ERROR: ures_getByKey(locale(te), %%Collation) failed"); + } + } + else{ + log_err("ERROR: ures_getByKey(locale(te), CollationElements) failed"); + return; + } ures_close(binColl); ures_close(coll); ures_close(teRes); @@ -324,10 +324,10 @@ void TestAPI(){ const UChar* value=NULL; char testdatapath[256]; UChar utestdatapath[256]; - UResourceBundle *teRes = NULL; + UResourceBundle *teRes = NULL; UResourceBundle *teFillin=NULL; UResourceBundle *teFillin2=NULL; - directory= ctest_getTestDirectory(); + directory= ctest_getTestDirectory(); uprv_strcpy(testdatapath, directory); uprv_strcat(testdatapath, "testdata"); u_charsToUChars(testdatapath, utestdatapath, strlen(testdatapath)+1); @@ -335,11 +335,11 @@ void TestAPI(){ /*Test ures_openU */ log_verbose("Testing ures_openU()......\n"); - teRes=ures_openU(utestdatapath, "te", &status); - if(U_FAILURE(status)){ - log_err("ERROR: ures_openU() failed path =%s with %s", austrdup(utestdatapath), myErrorName(status)); - return; - } + teRes=ures_openU(utestdatapath, "te", &status); + if(U_FAILURE(status)){ + log_err("ERROR: ures_openU() failed path =%s with %s", austrdup(utestdatapath), myErrorName(status)); + return; + } /*Test ures_getLocale() */ log_verbose("Testing ures_getLocale() .....\n"); if(strcmp(ures_getLocale(teRes, &status), "te") != 0){ @@ -377,9 +377,9 @@ void TestAPI(){ status=U_ZERO_ERROR; log_err("ERROR: ures_getByIndex on string resource fetched the key=%s, expected \"TE\" \n", austrdup(ures_getString(teFillin2, &len, &status))); } - + /*ures_close(teRes);*/ - + /*Test ures_openFillIn*/ log_verbose("Testing ures_openFillIn......\n"); status=U_ZERO_ERROR; @@ -401,13 +401,13 @@ void TestAPI(){ log_err("ERROR: calling getNextResource where index out of bounds should return U_INDEX_OUTOFBOUNDS_ERROR, Got : %s\n", myErrorName(status)); } - + ures_close(teFillin); ures_close(teFillin2); ures_close(teRes); - + } void TestErrorConditions(){ UErrorCode status; @@ -417,14 +417,14 @@ void TestErrorConditions(){ char testdatapath[256]; UChar utestdatapath[256]; int32_t len=0; - UResourceBundle *teRes = NULL; + UResourceBundle *teRes = NULL; UResourceBundle *coll=NULL; - UResourceBundle *binColl = NULL; + UResourceBundle *binColl = NULL; UResourceBundle *teFillin=NULL; UResourceBundle *teFillin2=NULL; - uint8_t *binResult = NULL; + uint8_t *binResult = NULL; - directory= ctest_getTestDirectory(); + directory= ctest_getTestDirectory(); uprv_strcpy(testdatapath, directory); uprv_strcat(testdatapath, "testdata"); u_uastrcpy(utestdatapath, testdatapath); @@ -432,9 +432,9 @@ void TestErrorConditions(){ /*Test ures_openU with status != U_ZERO_ERROR*/ log_verbose("Testing ures_openU() with status != U_ZERO_ERROR.....\n"); status=U_ILLEGAL_ARGUMENT_ERROR; - teRes=ures_openU(utestdatapath, "te", &status); - if(U_FAILURE(status)){ - log_verbose("ERROR: ures_openU() failed as expected path =%s with status != U_ZERO_ERROR", austrdup(utestdatapath)); + teRes=ures_openU(utestdatapath, "te", &status); + if(U_FAILURE(status)){ + log_verbose("ERROR: ures_openU() failed as expected path =%s with status != U_ZERO_ERROR", austrdup(utestdatapath)); }else{ log_err("ERROR: ures_openU() is supposed to fail path =%s with status != U_ZERO_ERROR", austrdup(utestdatapath)); ures_close(teRes); @@ -450,10 +450,10 @@ void TestErrorConditions(){ /*Test ures_getLocale() with status != U_ZERO_ERROR*/ status=U_ZERO_ERROR; teRes=ures_openU(utestdatapath, "te", &status); - if(U_FAILURE(status)){ - log_err("ERROR: ures_openU() failed path =%s with %s", austrdup(utestdatapath), myErrorName(status)); - return; - } + if(U_FAILURE(status)){ + log_err("ERROR: ures_openU() failed path =%s with %s", austrdup(utestdatapath), myErrorName(status)); + return; + } status=U_ILLEGAL_ARGUMENT_ERROR; if(ures_getLocale(teRes, &status) != NULL){ log_err("ERROR: ures_getLocale is supposed to fail with errorCode != U_ZERO_ERROR\n"); @@ -533,10 +533,10 @@ void TestErrorConditions(){ /*Test ures_getBinary(0 status != U_ILLEGAL_ARGUMENT_ERROR*/ status=U_ZERO_ERROR; coll = ures_getByKey(teRes, "CollationElements", coll, &status); - binColl=ures_getByKey(teRes, "%%Collation", binColl, &status); - + binColl=ures_getByKey(teRes, "%%Collation", binColl, &status); + status=U_ILLEGAL_ARGUMENT_ERROR; - binResult=(uint8_t*)ures_getBinary(binColl, &len, &status); + binResult=(uint8_t*)ures_getBinary(binColl, &len, &status); if(binResult != NULL){ log_err("ERROR: ures_getBinary() with status != U_ZERO_ERROR is supposed to fail\n"); } @@ -637,121 +637,121 @@ void TestResourceBundles() void TestConstruction1() { - UResourceBundle *test1 = 0, *test2 = 0; - const UChar *result1, *result2; - UErrorCode status= U_ZERO_ERROR; - UErrorCode err = U_ZERO_ERROR; - const char* directory=NULL; - const char* locale="te_IN"; - char testdatapath[256]; - int32_t len1=0; - int32_t len2=0; - UVersionInfo versionInfo; - char versionString[256]; + UResourceBundle *test1 = 0, *test2 = 0; + const UChar *result1, *result2; + UErrorCode status= U_ZERO_ERROR; + UErrorCode err = U_ZERO_ERROR; + const char* directory=NULL; + const char* locale="te_IN"; + char testdatapath[256]; + int32_t len1=0; + int32_t len2=0; + UVersionInfo versionInfo; + char versionString[256]; - U_STRING_DECL(rootVal, "ROOT", 4); - U_STRING_DECL(te_inVal, "TE_IN", 5); + U_STRING_DECL(rootVal, "ROOT", 4); + U_STRING_DECL(te_inVal, "TE_IN", 5); - U_STRING_INIT(rootVal, "ROOT", 4); - U_STRING_INIT(te_inVal, "TE_IN", 5); + U_STRING_INIT(rootVal, "ROOT", 4); + U_STRING_INIT(te_inVal, "TE_IN", 5); - directory= ctest_getTestDirectory(); - uprv_strcpy(testdatapath, directory); - uprv_strcat(testdatapath, "testdata"); - log_verbose("Testing ures_open()......\n"); + directory= ctest_getTestDirectory(); + uprv_strcpy(testdatapath, directory); + uprv_strcat(testdatapath, "testdata"); + log_verbose("Testing ures_open()......\n"); - test1=ures_open(testdatapath, NULL, &err); - test2=ures_open(testdatapath, locale, &err); + test1=ures_open(testdatapath, NULL, &err); + test2=ures_open(testdatapath, locale, &err); - if(U_FAILURE(err)) + if(U_FAILURE(err)) { - log_err("construction did not succeed : %s \n", myErrorName(status)); - return; + log_err("construction did not succeed : %s \n", myErrorName(status)); + return; } - result1= ures_getStringByKey(test1, "string_in_Root_te_te_IN", &len1, &err); - result2= ures_getStringByKey(test2, "string_in_Root_te_te_IN", &len2, &err); - if (U_FAILURE(err) || len1==0 || len2==0) { - log_err("Something threw an error in TestConstruction(): %s\n", myErrorName(status)); - return; - } - log_verbose("for string_in_Root_te_te_IN, default.txt had %s\n", austrdup(result1)); - log_verbose("for string_in_Root_te_te_IN, te_IN.txt had %s\n", austrdup(result2)); - if(u_strcmp(result1, rootVal) !=0 || u_strcmp(result2, te_inVal) !=0 ){ - log_err("construction test failed. Run Verbose for more information"); - } + result1= ures_getStringByKey(test1, "string_in_Root_te_te_IN", &len1, &err); + result2= ures_getStringByKey(test2, "string_in_Root_te_te_IN", &len2, &err); + if (U_FAILURE(err) || len1==0 || len2==0) { + log_err("Something threw an error in TestConstruction(): %s\n", myErrorName(status)); + return; + } + log_verbose("for string_in_Root_te_te_IN, default.txt had %s\n", austrdup(result1)); + log_verbose("for string_in_Root_te_te_IN, te_IN.txt had %s\n", austrdup(result2)); + if(u_strcmp(result1, rootVal) !=0 || u_strcmp(result2, te_inVal) !=0 ){ + log_err("construction test failed. Run Verbose for more information"); + } - /* Test getVersionNumber*/ - log_verbose("Testing version number\n"); - log_verbose("for getVersionNumber : %s\n", ures_getVersionNumber(test1)); + /* Test getVersionNumber*/ + log_verbose("Testing version number\n"); + log_verbose("for getVersionNumber : %s\n", ures_getVersionNumber(test1)); - log_verbose("Testing version \n"); - ures_getVersion(test1, versionInfo); - u_versionToString(versionInfo, versionString); + log_verbose("Testing version \n"); + ures_getVersion(test1, versionInfo); + u_versionToString(versionInfo, versionString); - log_verbose("for getVersion : %s\n", versionString); + log_verbose("for getVersion : %s\n", versionString); - if(strcmp(versionString, ures_getVersionNumber(test1)) != 0) { - log_err("Versions differ: %s vs %s\n", versionString, ures_getVersionNumber(test1)); - } + if(strcmp(versionString, ures_getVersionNumber(test1)) != 0) { + log_err("Versions differ: %s vs %s\n", versionString, ures_getVersionNumber(test1)); + } - ures_close(test1); - ures_close(test2); + ures_close(test1); + ures_close(test2); } void TestConstruction2() { - - UChar temp[7]; - UResourceBundle *test4 = 0; - const UChar* result4; - UErrorCode err = U_ZERO_ERROR; - const char* directory; - const char* locale="te_IN"; - wchar_t widedirectory[256]; - char testdatapath[256]; - int32_t len=0; - directory= ctest_getTestDirectory(); - uprv_strcpy(testdatapath, directory); - uprv_strcat(testdatapath, "testdata"); - mbstowcs(widedirectory, testdatapath, 256); + UChar temp[7]; + UResourceBundle *test4 = 0; + const UChar* result4; + UErrorCode err = U_ZERO_ERROR; + const char* directory; + const char* locale="te_IN"; + wchar_t widedirectory[256]; + char testdatapath[256]; + int32_t len=0; - log_verbose("Testing ures_openW().......\n"); + directory= ctest_getTestDirectory(); + uprv_strcpy(testdatapath, directory); + uprv_strcat(testdatapath, "testdata"); + mbstowcs(widedirectory, testdatapath, 256); - test4=ures_openW(widedirectory, locale, &err); - if(U_FAILURE(err)){ - log_err("Error in the construction using ures_openW(): %s\n", myErrorName(err)); - return; - } + log_verbose("Testing ures_openW().......\n"); - result4=ures_getStringByKey(test4, "string_in_Root_te_te_IN", &len, &err); - if (U_FAILURE(err) || len==0) { - log_err("Something threw an error in TestConstruction() %s\n", myErrorName(err)); - return; - } + test4=ures_openW(widedirectory, locale, &err); + if(U_FAILURE(err)){ + log_err("Error in the construction using ures_openW(): %s\n", myErrorName(err)); + return; + } - log_verbose("for string_in_Root_te_te_IN, te_IN.txt had %s\n", austrdup(result4)); - u_uastrcpy(temp, "TE_IN"); + result4=ures_getStringByKey(test4, "string_in_Root_te_te_IN", &len, &err); + if (U_FAILURE(err) || len==0) { + log_err("Something threw an error in TestConstruction() %s\n", myErrorName(err)); + return; + } - if(u_strcmp(result4, temp)!=0) - { + log_verbose("for string_in_Root_te_te_IN, te_IN.txt had %s\n", austrdup(result4)); + u_uastrcpy(temp, "TE_IN"); - log_err("Construction test failed for ures_openW();\n"); - if(!VERBOSITY) - log_info("(run verbose for more information)\n"); + if(u_strcmp(result4, temp)!=0) + { - log_verbose("\nGot->"); - printUChars((UChar*)result4); - log_verbose(" Want->"); - printUChars(temp); - log_verbose("\n"); - } - - - ures_close(test4); + log_err("Construction test failed for ures_openW();\n"); + if(!VERBOSITY) + log_info("(run verbose for more information)\n"); + + log_verbose("\nGot->"); + printUChars((UChar*)result4); + log_verbose(" Want->"); + printUChars(temp); + log_verbose("\n"); + } + + + ures_close(test4); } /*****************************************************************************/ @@ -762,229 +762,229 @@ UBool testTag(const char* frag, UBool in_te, UBool in_te_IN) { - UBool pass=TRUE; + UBool pass=TRUE; - /* Make array from input params */ + /* Make array from input params */ - UBool is_in[3]; - const char *NAME[] = { "ROOT", "TE", "TE_IN" }; + UBool is_in[3]; + const char *NAME[] = { "ROOT", "TE", "TE_IN" }; - /* Now try to load the desired items */ - UResourceBundle* theBundle = NULL; - char tag[99]; - char action[256]; - UErrorCode expected_status,status = U_ZERO_ERROR,expected_resource_status = U_ZERO_ERROR; - UChar* base = NULL; - UChar* expected_string = NULL; - const UChar* string = NULL; - char buf[5]; - char item_tag[10]; - int32_t i,j,row,col, len; - int32_t actual_bundle; - int32_t count = 0; - int32_t row_count=0; - int32_t column_count=0; - int32_t index = 0; - int32_t tag_count= 0; - char testdatapath[256]; - UResourceBundle* array=NULL; - UResourceBundle* array2d=NULL; - UResourceBundle* tags=NULL; - UResourceBundle* arrayItem1=NULL; + /* Now try to load the desired items */ + UResourceBundle* theBundle = NULL; + char tag[99]; + char action[256]; + UErrorCode expected_status,status = U_ZERO_ERROR,expected_resource_status = U_ZERO_ERROR; + UChar* base = NULL; + UChar* expected_string = NULL; + const UChar* string = NULL; + char buf[5]; + char item_tag[10]; + int32_t i,j,row,col, len; + int32_t actual_bundle; + int32_t count = 0; + int32_t row_count=0; + int32_t column_count=0; + int32_t index = 0; + int32_t tag_count= 0; + char testdatapath[256]; + UResourceBundle* array=NULL; + UResourceBundle* array2d=NULL; + UResourceBundle* tags=NULL; + UResourceBundle* arrayItem1=NULL; - const char* directory = ctest_getTestDirectory(); + const char* directory = ctest_getTestDirectory(); - uprv_strcpy(testdatapath, directory); - uprv_strcat(testdatapath, "testdata"); + uprv_strcpy(testdatapath, directory); + uprv_strcat(testdatapath, "testdata"); - is_in[0] = in_Root; - is_in[1] = in_te; - is_in[2] = in_te_IN; + is_in[0] = in_Root; + is_in[1] = in_te; + is_in[2] = in_te_IN; - strcpy(item_tag, "tag"); + strcpy(item_tag, "tag"); - for (i=0; i default */ - else if(i == 3) - actual_bundle = 1; /* te_NE -> te */ - else if(i == 4) - actual_bundle = 2; /* te_IN_NE -> te_IN */ - else - actual_bundle = i; + if(i == 5) + actual_bundle = 0; /* ne -> default */ + else if(i == 3) + actual_bundle = 1; /* te_NE -> te */ + else if(i == 4) + actual_bundle = 2; /* te_IN_NE -> te_IN */ + else + actual_bundle = i; - expected_resource_status = U_MISSING_RESOURCE_ERROR; - for (j=e_te_IN; j>=e_Root; --j) + expected_resource_status = U_MISSING_RESOURCE_ERROR; + for (j=e_te_IN; j>=e_Root; --j) { - if (is_in[j] && param[i].inherits[j]) + if (is_in[j] && param[i].inherits[j]) { - - if(j == actual_bundle) /* it's in the same bundle OR it's a nonexistent=default bundle (5) */ - expected_resource_status = U_ZERO_ERROR; - else if(j == 0) - expected_resource_status = U_USING_DEFAULT_ERROR; - else - expected_resource_status = U_USING_FALLBACK_ERROR; - log_verbose("%s[%d]::%s: in<%d:%s> inherits<%d:%s>. actual_bundle=%s\n", - param[i].name, - i, - frag, - j, - is_in[j]?"Yes":"No", - j, - param[i].inherits[j]?"Yes":"No", - param[actual_bundle].name); + if(j == actual_bundle) /* it's in the same bundle OR it's a nonexistent=default bundle (5) */ + expected_resource_status = U_ZERO_ERROR; + else if(j == 0) + expected_resource_status = U_USING_DEFAULT_ERROR; + else + expected_resource_status = U_USING_FALLBACK_ERROR; - break; + log_verbose("%s[%d]::%s: in<%d:%s> inherits<%d:%s>. actual_bundle=%s\n", + param[i].name, + i, + frag, + j, + is_in[j]?"Yes":"No", + j, + param[i].inherits[j]?"Yes":"No", + param[actual_bundle].name); + + break; } } - for (j=param[i].where; j>=0; --j) + for (j=param[i].where; j>=0; --j) { - if (is_in[j]) - { - if(base != NULL) { - free(base); - base = NULL; - } - base=(UChar*)malloc(sizeof(UChar)*(strlen(NAME[j]) + 1)); - u_uastrcpy(base,NAME[j]); + if (is_in[j]) + { + if(base != NULL) { + free(base); + base = NULL; + } + base=(UChar*)malloc(sizeof(UChar)*(strlen(NAME[j]) + 1)); + u_uastrcpy(base,NAME[j]); - break; + break; + } + else { + if(base != NULL) { + free(base); + base = NULL; + } + base = (UChar*) malloc(sizeof(UChar) * 1); + *base = 0x0000; } - else { - if(base != NULL) { - free(base); - base = NULL; - } - base = (UChar*) malloc(sizeof(UChar) * 1); - *base = 0x0000; - } } - /*----string---------------------------------------------------------------- */ - - strcpy(tag,"string_"); - strcat(tag,frag); + /*----string---------------------------------------------------------------- */ - strcpy(action,param[i].name); - strcat(action, ".ures_getStringByKey(" ); - strcat(action,tag); - strcat(action, ")"); + strcpy(tag,"string_"); + strcat(tag,frag); - - status = U_ZERO_ERROR; - len=0; + strcpy(action,param[i].name); + strcat(action, ".ures_getStringByKey(" ); + strcat(action,tag); + strcat(action, ")"); - string=ures_getStringByKey(theBundle, tag, &len, &status); - if(U_SUCCESS(status)) { - expected_string=(UChar*)malloc(sizeof(UChar)*(u_strlen(base) + 4)); - u_strcpy(expected_string,base); - CONFIRM_INT_EQ(len, u_strlen(expected_string)); - }else{ - expected_string = (UChar*)malloc(sizeof(UChar)*(u_strlen(kERROR) + 1)); - u_strcpy(expected_string,kERROR); - string=kERROR; - } - log_verbose("%s got %d, expected %d\n", action, status, expected_resource_status); - - CONFIRM_ErrorCode(status, expected_resource_status); - CONFIRM_EQ(string, expected_string); - - - /*--------------array------------------------------------------------- */ - - strcpy(tag,"array_"); - strcat(tag,frag); + status = U_ZERO_ERROR; + len=0; - strcpy(action,param[i].name); - strcat(action, ".ures_getByKey(" ); - strcat(action,tag); - strcat(action, ")"); + string=ures_getStringByKey(theBundle, tag, &len, &status); + if(U_SUCCESS(status)) { + expected_string=(UChar*)malloc(sizeof(UChar)*(u_strlen(base) + 4)); + u_strcpy(expected_string,base); + CONFIRM_INT_EQ(len, u_strlen(expected_string)); + }else{ + expected_string = (UChar*)malloc(sizeof(UChar)*(u_strlen(kERROR) + 1)); + u_strcpy(expected_string,kERROR); + string=kERROR; + } + log_verbose("%s got %d, expected %d\n", action, status, expected_resource_status); - len=0; + CONFIRM_ErrorCode(status, expected_resource_status); + CONFIRM_EQ(string, expected_string); - count = kERROR_COUNT; - status = U_ZERO_ERROR; - array=ures_getByKey(theBundle, tag, array, &status); - CONFIRM_ErrorCode(status,expected_resource_status); - if (U_SUCCESS(status)) { - /*confirm the resource type is an array*/ - CONFIRM_INT_EQ(ures_getType(array), RES_ARRAY); - /*confirm the size*/ - count=ures_getSize(array); + + + /*--------------array------------------------------------------------- */ + + strcpy(tag,"array_"); + strcat(tag,frag); + + strcpy(action,param[i].name); + strcat(action, ".ures_getByKey(" ); + strcat(action,tag); + strcat(action, ")"); + + len=0; + + count = kERROR_COUNT; + status = U_ZERO_ERROR; + array=ures_getByKey(theBundle, tag, array, &status); + CONFIRM_ErrorCode(status,expected_resource_status); + if (U_SUCCESS(status)) { + /*confirm the resource type is an array*/ + CONFIRM_INT_EQ(ures_getType(array), RES_ARRAY); + /*confirm the size*/ + count=ures_getSize(array); CONFIRM_INT_GE(count,1); for (j=0; j= 0 && index < count) ? expected_resource_status : U_MISSING_RESOURCE_ERROR; - CONFIRM_ErrorCode(status,expected_status); - CONFIRM_EQ(string,expected_string); - - } - - - /*--------------2dArray------------------------------------------------- */ - - strcpy(tag,"array_2d_"); + strcpy(action,param[i].name); + strcat(action, ".ures_getStringByIndex("); + strcat(action, tag); + strcat(action, ")"); + + + for (j=0; j<10; ++j){ + index = count ? (randi(count * 3) - count) : (randi(200) - 100); + status = U_ZERO_ERROR; + string=kERROR; + array=ures_getByKey(theBundle, tag, array, &status); + if(!U_FAILURE(status)){ + UChar *t=NULL; + t=(UChar*)ures_getStringByIndex(array, index, &len, &status); + if(!U_FAILURE(status)){ + UChar element[3]; + string=t; + u_strcpy(expected_string, base); + u_uastrcpy(element, itoa1(index,buf)); + u_strcat(expected_string, element); + } else { + u_strcpy(expected_string, kERROR); + } + + } + expected_status = (index >= 0 && index < count) ? expected_resource_status : U_MISSING_RESOURCE_ERROR; + CONFIRM_ErrorCode(status,expected_status); + CONFIRM_EQ(string,expected_string); + + } + + + /*--------------2dArray------------------------------------------------- */ + + strcpy(tag,"array_2d_"); strcat(tag,frag); strcpy(action,param[i].name); @@ -996,194 +996,194 @@ UBool testTag(const char* frag, row_count = kERROR_COUNT, column_count = kERROR_COUNT; status = U_ZERO_ERROR; - array2d=ures_getByKey(theBundle, tag, array2d, &status); + array2d=ures_getByKey(theBundle, tag, array2d, &status); CONFIRM_ErrorCode(status,expected_resource_status); if (U_SUCCESS(status)) { - /*confirm the resource type is an 2darray*/ + /*confirm the resource type is an 2darray*/ CONFIRM_INT_EQ(ures_getType(array2d), RES_ARRAY); - row_count=ures_getSize(array2d); - CONFIRM_INT_GE(row_count,1); - - for(row=0; row= 0 && row < row_count && col >= 0 && col < column_count) ? - expected_resource_status: U_MISSING_RESOURCE_ERROR; - CONFIRM_ErrorCode(status,expected_status); - - if (U_SUCCESS(status)){ - UChar element[3]; - u_strcpy(expected_string, base); - u_uastrcpy(element, itoa1(row, buf)); - u_strcat(expected_string, element); - u_uastrcpy(element, itoa1(col, buf)); - u_strcat(expected_string, element); - } else { - u_strcpy(expected_string,kERROR); - } - CONFIRM_EQ(string,expected_string); - } - /*--------------taggedArray----------------------------------------------- */ - strcpy(tag,"tagged_array_"); - strcat(tag,frag); + /*------2dArrayItem-------------------------------------------------------------- */ + /* 2dArrayItem*/ + for (j=0; j<10; ++j) + { + row = row_count ? (randi(row_count * 3) - row_count) : (randi(200) - 100); + col = column_count ? (randi(column_count * 3) - column_count) : (randi(200) - 100); + status = U_ZERO_ERROR; + string = kERROR; + len=0; + array2d=ures_getByKey(theBundle, tag, array2d, &status); + if(U_SUCCESS(status)){ + UResourceBundle *tableRow=NULL; + tableRow=ures_getByIndex(array2d, row, tableRow, &status); + if(U_SUCCESS(status)) { + UChar *t=NULL; + t=(UChar*)ures_getStringByIndex(tableRow, col, &len, &status); + if(U_SUCCESS(status)){ + string=t; + } + } + ures_close(tableRow); + } + expected_status = (row >= 0 && row < row_count && col >= 0 && col < column_count) ? + expected_resource_status: U_MISSING_RESOURCE_ERROR; + CONFIRM_ErrorCode(status,expected_status); - strcpy(action,param[i].name); - strcat(action,".ures_getByKey("); - strcat(action, tag); - strcat(action,")"); - - - status = U_ZERO_ERROR; - tag_count=0; - tags=ures_getByKey(theBundle, tag, tags, &status); - CONFIRM_ErrorCode(status, expected_resource_status); - if (U_SUCCESS(status)) { + if (U_SUCCESS(status)){ + UChar element[3]; + u_strcpy(expected_string, base); + u_uastrcpy(element, itoa1(row, buf)); + u_strcat(expected_string, element); + u_uastrcpy(element, itoa1(col, buf)); + u_strcat(expected_string, element); + } else { + u_strcpy(expected_string,kERROR); + } + CONFIRM_EQ(string,expected_string); + + } + + + /*--------------taggedArray----------------------------------------------- */ + strcpy(tag,"tagged_array_"); + strcat(tag,frag); + + strcpy(action,param[i].name); + strcat(action,".ures_getByKey("); + strcat(action, tag); + strcat(action,")"); + + + status = U_ZERO_ERROR; + tag_count=0; + tags=ures_getByKey(theBundle, tag, tags, &status); + CONFIRM_ErrorCode(status, expected_resource_status); + if (U_SUCCESS(status)) { UResType bundleType=ures_getType(tags); - CONFIRM_INT_EQ(bundleType, RES_TABLE); - - tag_count=ures_getSize(tags); + CONFIRM_INT_EQ(bundleType, RES_TABLE); + + tag_count=ures_getSize(tags); CONFIRM_INT_GE((int32_t)tag_count, (int32_t)0); - for(index=0; index #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" diff --git a/icu4c/source/test/cintltst/cucdtst.c b/icu4c/source/test/cintltst/cucdtst.c index 1a85b498b9..1e127e84fd 100644 --- a/icu4c/source/test/cintltst/cucdtst.c +++ b/icu4c/source/test/cintltst/cucdtst.c @@ -13,6 +13,7 @@ ********************************************************************************* */ +#include #include #include #include "unicode/uchar.h" diff --git a/icu4c/source/test/cintltst/encoll.c b/icu4c/source/test/cintltst/encoll.c index 9b2db5a9bc..9a5eb3b0dd 100644 --- a/icu4c/source/test/cintltst/encoll.c +++ b/icu4c/source/test/cintltst/encoll.c @@ -18,6 +18,8 @@ * collation rules as its sorting sequence. */ +#include +#include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/uloc.h" @@ -25,7 +27,6 @@ #include "encoll.h" #include "ccolltst.h" #include "unicode/ustring.h" -#include static UCollator *myCollation = NULL; const static UChar testSourceCases[][MAX_TOKEN_LEN] = { diff --git a/icu4c/source/test/cintltst/mstrmtst.c b/icu4c/source/test/cintltst/mstrmtst.c index c1d663a51d..8930562e8a 100644 --- a/icu4c/source/test/cintltst/mstrmtst.c +++ b/icu4c/source/test/cintltst/mstrmtst.c @@ -13,10 +13,11 @@ ******************************************************************************* */ +#include +#include #include "unicode/utypes.h" #include "cintltst.h" #include "umemstrm.h" -#include void TestMemoryStreamAPI(); static void printUSeqErr(const uint8_t *a, int len); diff --git a/icu4c/source/test/cintltst/putiltst.c b/icu4c/source/test/cintltst/putiltst.c index 16a614f153..ab8b63c635 100644 --- a/icu4c/source/test/cintltst/putiltst.c +++ b/icu4c/source/test/cintltst/putiltst.c @@ -13,12 +13,13 @@ ******************************************************************************* */ +#include +#include +#include #include "unicode/utypes.h" #include "cintltst.h" #include "unicode/putil.h" #include "unicode/ustring.h" -#include -#include void TestPUtilAPI(); void testIEEEremainder();