Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(633)

Side by Side Diff: source/test/intltest/intltest.cpp

Issue 1621843002: ICU 56 update step 1 (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@561
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/test/intltest/intltest.h ('k') | source/test/intltest/intltest.vcxproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /******************************************************************** 1 /********************************************************************
2 * COPYRIGHT: 2 * COPYRIGHT:
3 * Copyright (c) 1997-2014, International Business Machines Corporation and 3 * Copyright (c) 1997-2015, International Business Machines Corporation and
4 * others. All Rights Reserved. 4 * others. All Rights Reserved.
5 ********************************************************************/ 5 ********************************************************************/
6 6
7 7
8 #include "unicode/utypes.h" 8 #include "unicode/utypes.h"
9 9
10 /** 10 /**
11 * IntlTest is a base class for tests. 11 * IntlTest is a base class for tests.
12 */ 12 */
13 13
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 if (pBackSlash != NULL) { 438 if (pBackSlash != NULL) {
439 /* We found and truncated three names from the path. 439 /* We found and truncated three names from the path.
440 * Now append "source\data" and set the environment 440 * Now append "source\data" and set the environment
441 */ 441 */
442 strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING); 442 strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
443 u_setDataDirectory(p); /* p is "ICU_DATA=wherever\icu\source\da ta" */ 443 u_setDataDirectory(p); /* p is "ICU_DATA=wherever\icu\source\da ta" */
444 return; 444 return;
445 } 445 }
446 else { 446 else {
447 /* __FILE__ on MSVC7 does not contain the directory */ 447 /* __FILE__ on MSVC7 does not contain the directory */
448 u_setDataDirectory(".."U_FILE_SEP_STRING".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING); 448 u_setDataDirectory(".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "da ta" U_FILE_SEP_STRING "out" U_FILE_SEP_STRING);
449 return; 449 return;
450 } 450 }
451 } 451 }
452 #endif 452 #endif
453 453
454 /* No location for the data dir was identifiable. 454 /* No location for the data dir was identifiable.
455 * Add other fallbacks for the test data location here if the need arises 455 * Add other fallbacks for the test data location here if the need arises
456 */ 456 */
457 } 457 }
458 458
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 } 554 }
555 555
556 void IntlTest::setCaller( IntlTest* callingTest ) 556 void IntlTest::setCaller( IntlTest* callingTest )
557 { 557 {
558 caller = callingTest; 558 caller = callingTest;
559 if (caller) { 559 if (caller) {
560 warn_on_missing_data = caller->warn_on_missing_data; 560 warn_on_missing_data = caller->warn_on_missing_data;
561 verbose = caller->verbose; 561 verbose = caller->verbose;
562 no_err_msg = caller->no_err_msg; 562 no_err_msg = caller->no_err_msg;
563 quick = caller->quick; 563 quick = caller->quick;
564 threadCount = caller->threadCount;
564 testoutfp = caller->testoutfp; 565 testoutfp = caller->testoutfp;
565 LL_indentlevel = caller->LL_indentlevel + indentLevel_offset; 566 LL_indentlevel = caller->LL_indentlevel + indentLevel_offset;
566 numProps = caller->numProps; 567 numProps = caller->numProps;
567 for (int32_t i = 0; i < numProps; i++) { 568 for (int32_t i = 0; i < numProps; i++) {
568 proplines[i] = caller->proplines[i]; 569 proplines[i] = caller->proplines[i];
569 } 570 }
570 } 571 }
571 } 572 }
572 573
573 UBool IntlTest::callTest( IntlTest& testToBeCalled, char* par ) 574 UBool IntlTest::callTest( IntlTest& testToBeCalled, char* par )
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 UBool IntlTest::logKnownIssue(const char *ticket) { 967 UBool IntlTest::logKnownIssue(const char *ticket) {
967 return logKnownIssue(ticket, UnicodeString()); 968 return logKnownIssue(ticket, UnicodeString());
968 } 969 }
969 970
970 UBool IntlTest::logKnownIssue(const char *ticket, const UnicodeString &msg) { 971 UBool IntlTest::logKnownIssue(const char *ticket, const UnicodeString &msg) {
971 if(noKnownIssues) return FALSE; 972 if(noKnownIssues) return FALSE;
972 973
973 char fullpath[2048]; 974 char fullpath[2048];
974 strcpy(fullpath, basePath); 975 strcpy(fullpath, basePath);
975 strcat(fullpath, currName); 976 strcat(fullpath, currName);
976 UnicodeString msg2 =msg; 977 UnicodeString msg2 = msg;
977 UBool firstForTicket, firstForWhere; 978 UBool firstForTicket = TRUE, firstForWhere = TRUE;
978 knownList = udbg_knownIssue_openU(knownList, ticket, fullpath, msg2.getTermina tedBuffer(), &firstForTicket, &firstForWhere); 979 knownList = udbg_knownIssue_openU(knownList, ticket, fullpath, msg2.getTermina tedBuffer(), &firstForTicket, &firstForWhere);
979 980
980 msg2 = UNICODE_STRING_SIMPLE("(Known issue #") + 981 msg2 = UNICODE_STRING_SIMPLE("(Known issue #") +
981 UnicodeString(ticket, -1, US_INV) + UNICODE_STRING_SIMPLE(") ") + msg; 982 UnicodeString(ticket, -1, US_INV) + UNICODE_STRING_SIMPLE(") ") + msg;
982 if(firstForTicket || firstForWhere) { 983 if(firstForTicket || firstForWhere) {
983 infoln(msg2); 984 infoln(msg2);
984 } else { 985 } else {
985 logln(msg2); 986 logln(msg2);
986 } 987 }
987 988
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 1160
1160 1161
1161 #if UCONFIG_NO_LEGACY_CONVERSION 1162 #if UCONFIG_NO_LEGACY_CONVERSION
1162 # define TRY_CNV_1 "iso-8859-1" 1163 # define TRY_CNV_1 "iso-8859-1"
1163 # define TRY_CNV_2 "ibm-1208" 1164 # define TRY_CNV_2 "ibm-1208"
1164 #else 1165 #else
1165 # define TRY_CNV_1 "iso-8859-7" 1166 # define TRY_CNV_1 "iso-8859-7"
1166 # define TRY_CNV_2 "sjis" 1167 # define TRY_CNV_2 "sjis"
1167 #endif 1168 #endif
1168 1169
1170 #ifdef UNISTR_COUNT_FINAL_STRING_LENGTHS
1171 U_CAPI void unistr_printLengths();
1172 #endif
1173
1169 int 1174 int
1170 main(int argc, char* argv[]) 1175 main(int argc, char* argv[])
1171 { 1176 {
1172 UBool syntax = FALSE; 1177 UBool syntax = FALSE;
1173 UBool all = FALSE; 1178 UBool all = FALSE;
1174 UBool verbose = FALSE; 1179 UBool verbose = FALSE;
1175 UBool no_err_msg = FALSE; 1180 UBool no_err_msg = FALSE;
1176 UBool no_time = FALSE; 1181 UBool no_time = FALSE;
1177 UBool quick = TRUE; 1182 UBool quick = TRUE;
1178 UBool name = FALSE; 1183 UBool name = FALSE;
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 fprintf(stdout, " Options: \n"); 1329 fprintf(stdout, " Options: \n");
1325 fprintf(stdout, " all (a) : %s\n", (all? "O n" : "Off")); 1330 fprintf(stdout, " all (a) : %s\n", (all? "O n" : "Off"));
1326 fprintf(stdout, " Verbose (v) : %s\n", (verbose? "O n" : "Off")); 1331 fprintf(stdout, " Verbose (v) : %s\n", (verbose? "O n" : "Off"));
1327 fprintf(stdout, " No error messages (n) : %s\n", (no_err_msg? "O n" : "Off")); 1332 fprintf(stdout, " No error messages (n) : %s\n", (no_err_msg? "O n" : "Off"));
1328 fprintf(stdout, " Exhaustive (e) : %s\n", (!quick? "O n" : "Off")); 1333 fprintf(stdout, " Exhaustive (e) : %s\n", (!quick? "O n" : "Off"));
1329 fprintf(stdout, " Leaks (l) : %s\n", (leaks? "O n" : "Off")); 1334 fprintf(stdout, " Leaks (l) : %s\n", (leaks? "O n" : "Off"));
1330 fprintf(stdout, " utf-8 (u) : %s\n", (utf8? "O n" : "Off")); 1335 fprintf(stdout, " utf-8 (u) : %s\n", (utf8? "O n" : "Off"));
1331 fprintf(stdout, " notime (T) : %s\n", (no_time? "On" : "Off")); 1336 fprintf(stdout, " notime (T) : %s\n", (no_time? "On" : "Off"));
1332 fprintf(stdout, " noknownissues (K) : %s\n", (noKnownIssues? " On" : "Off")); 1337 fprintf(stdout, " noknownissues (K) : %s\n", (noKnownIssues? " On" : "Off"));
1333 fprintf(stdout, " Warn on missing data (w) : %s\n", (warnOnMissingData? "O n" : "Off")); 1338 fprintf(stdout, " Warn on missing data (w) : %s\n", (warnOnMissingData? "O n" : "Off"));
1334 #if (ICU_USE_THREADS==0)
1335 fprintf(stdout, " Threads : Disabled\n");
1336 #else
1337 fprintf(stdout, " Threads : %d\n", threadCount); 1339 fprintf(stdout, " Threads : %d\n", threadCount);
1338 #endif
1339 for (int32_t i = 0; i < nProps; i++) { 1340 for (int32_t i = 0; i < nProps; i++) {
1340 fprintf(stdout, " Custom property (prop:) : %s\n", props[i]); 1341 fprintf(stdout, " Custom property (prop:) : %s\n", props[i]);
1341 } 1342 }
1342 fprintf(stdout, "-----------------------------------------------\n"); 1343 fprintf(stdout, "-----------------------------------------------\n");
1343 1344
1344 if(utf8) { 1345 if(utf8) {
1345 ucnv_setDefaultName("utf-8"); 1346 ucnv_setDefaultName("utf-8");
1346 } 1347 }
1347 /* Check whether ICU will initialize without forcing the build data director y into 1348 /* Check whether ICU will initialize without forcing the build data director y into
1348 * the ICU_DATA path. Success here means either the data dll contains data , or that 1349 * the ICU_DATA path. Success here means either the data dll contains data , or that
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1517 if (major.getDataErrors() != 0) { 1518 if (major.getDataErrors() != 0) {
1518 fprintf(stdout, "\t*Note* some errors are data-loading related. If t he data used is not the \n" 1519 fprintf(stdout, "\t*Note* some errors are data-loading related. If t he data used is not the \n"
1519 "\tstock ICU data (i.e some have been added or removed), con sider using\n" 1520 "\tstock ICU data (i.e some have been added or removed), con sider using\n"
1520 "\tthe '-w' option to turn these errors into warnings.\n"); 1521 "\tthe '-w' option to turn these errors into warnings.\n");
1521 } 1522 }
1522 1523
1523 /* Call afterwards to display errors. */ 1524 /* Call afterwards to display errors. */
1524 u_cleanup(); 1525 u_cleanup();
1525 } 1526 }
1526 1527
1528 #ifdef UNISTR_COUNT_FINAL_STRING_LENGTHS
1529 unistr_printLengths();
1530 #endif
1531
1527 fprintf(stdout, "--------------------------------------\n"); 1532 fprintf(stdout, "--------------------------------------\n");
1528 1533
1529 if (execCount <= 0) { 1534 if (execCount <= 0) {
1530 fprintf(stdout, "***** Not all called tests actually exist! *****\n"); 1535 fprintf(stdout, "***** Not all called tests actually exist! *****\n");
1531 } 1536 }
1532 if(!no_time) { 1537 if(!no_time) {
1533 endTime = uprv_getRawUTCtime(); 1538 endTime = uprv_getRawUTCtime();
1534 diffTime = (int32_t)(endTime - startTime); 1539 diffTime = (int32_t)(endTime - startTime);
1535 printf("Elapsed Time: %02d:%02d:%02d.%03d\n", 1540 printf("Elapsed Time: %02d:%02d:%02d.%03d\n",
1536 (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR), 1541 (int)((diffTime%U_MILLIS_PER_DAY)/U_MILLIS_PER_HOUR),
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1595 srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING"test" U_FILE_SEP_STRING "testdata " U_FILE_SEP_STRING; 1600 srcDataDir = U_TOPSRCDIR U_FILE_SEP_STRING"test" U_FILE_SEP_STRING "testdata " U_FILE_SEP_STRING;
1596 #else 1601 #else
1597 srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP _STRING "testdata" U_FILE_SEP_STRING; 1602 srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP _STRING "testdata" U_FILE_SEP_STRING;
1598 FILE *f = fopen(".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_ SEP_STRING "testdata" U_FILE_SEP_STRING "rbbitst.txt", "r"); 1603 FILE *f = fopen(".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_ SEP_STRING "testdata" U_FILE_SEP_STRING "rbbitst.txt", "r");
1599 if (f) { 1604 if (f) {
1600 /* We're in icu/source/test/intltest/ */ 1605 /* We're in icu/source/test/intltest/ */
1601 fclose(f); 1606 fclose(f);
1602 } 1607 }
1603 else { 1608 else {
1604 /* We're in icu/source/test/intltest/Platform/(Debug|Release) */ 1609 /* We're in icu/source/test/intltest/Platform/(Debug|Release) */
1605 srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_S EP_STRING ".." U_FILE_SEP_STRING "test" U_FILE_SEP_STRING "testdata"U_FILE_SEP_S TRING; 1610 srcDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U_FILE_S EP_STRING ".." U_FILE_SEP_STRING
1611 "test" U_FILE_SEP_STRING "testdata" U_FILE_SEP_STRING;
1606 } 1612 }
1607 #endif 1613 #endif
1608 return srcDataDir; 1614 return srcDataDir;
1609 } 1615 }
1610 1616
1611 char *IntlTest::getUnidataPath(char path[]) { 1617 char *IntlTest::getUnidataPath(char path[]) {
1612 const int kUnicodeDataTxtLength = 15; // strlen("UnicodeData.txt") 1618 const int kUnicodeDataTxtLength = 15; // strlen("UnicodeData.txt")
1613 1619
1614 // Look inside ICU_DATA first. 1620 // Look inside ICU_DATA first.
1615 strcpy(path, pathToDataDirectory()); 1621 strcpy(path, pathToDataDirectory());
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1695 1701
1696 if (pBackSlash != NULL) { 1702 if (pBackSlash != NULL) {
1697 /* We found and truncated three names from the path. 1703 /* We found and truncated three names from the path.
1698 * Now append "source\data" and set the environment 1704 * Now append "source\data" and set the environment
1699 */ 1705 */
1700 strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING ); 1706 strcpy(pBackSlash, U_FILE_SEP_STRING "data" U_FILE_SEP_STRING );
1701 fgDataDir = p; 1707 fgDataDir = p;
1702 } 1708 }
1703 else { 1709 else {
1704 /* __FILE__ on MSVC7 does not contain the directory */ 1710 /* __FILE__ on MSVC7 does not contain the directory */
1705 FILE *file = fopen(".." U_FILE_SEP_STRING ".."U_FILE_SEP_STRING "dat a" U_FILE_SEP_STRING "Makefile.in", "r"); 1711 FILE *file = fopen(".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "da ta" U_FILE_SEP_STRING "Makefile.in", "r");
1706 if (file) { 1712 if (file) {
1707 fclose(file); 1713 fclose(file);
1708 fgDataDir = ".." U_FILE_SEP_STRING ".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING; 1714 fgDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
1709 } 1715 }
1710 else { 1716 else {
1711 fgDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U _FILE_SEP_STRING ".."U_FILE_SEP_STRING "data" U_FILE_SEP_STRING; 1717 fgDataDir = ".." U_FILE_SEP_STRING ".." U_FILE_SEP_STRING ".." U _FILE_SEP_STRING ".." U_FILE_SEP_STRING "data" U_FILE_SEP_STRING;
1712 } 1718 }
1713 } 1719 }
1714 } 1720 }
1715 #endif 1721 #endif
1716 1722
1717 return fgDataDir; 1723 return fgDataDir;
1718 1724
1719 } 1725 }
1720 1726
1721 /* 1727 /*
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
1919 } 1925 }
1920 #ifdef VERBOSE_ASSERTIONS 1926 #ifdef VERBOSE_ASSERTIONS
1921 else { 1927 else {
1922 logln((UnicodeString)"Ok: " + message + "; got int64 " + Int64ToUnicodeStr ing(actual)); 1928 logln((UnicodeString)"Ok: " + message + "; got int64 " + Int64ToUnicodeStr ing(actual));
1923 } 1929 }
1924 #endif 1930 #endif
1925 return TRUE; 1931 return TRUE;
1926 } 1932 }
1927 1933
1928 UBool IntlTest::assertEquals(const char* message, 1934 UBool IntlTest::assertEquals(const char* message,
1935 double expected,
1936 double actual) {
1937 if (expected != actual) {
1938 errln((UnicodeString)"FAIL: " + message + "; got " +
1939 actual +
1940 "; expected " + expected);
1941 return FALSE;
1942 }
1943 #ifdef VERBOSE_ASSERTIONS
1944 else {
1945 logln((UnicodeString)"Ok: " + message + "; got " + actual);
1946 }
1947 #endif
1948 return TRUE;
1949 }
1950
1951
1952 UBool IntlTest::assertEquals(const char* message,
1929 UBool expected, 1953 UBool expected,
1930 UBool actual) { 1954 UBool actual) {
1931 if (expected != actual) { 1955 if (expected != actual) {
1932 errln((UnicodeString)"FAIL: " + message + "; got " + 1956 errln((UnicodeString)"FAIL: " + message + "; got " +
1933 toString(actual) + 1957 toString(actual) +
1934 "; expected " + toString(expected)); 1958 "; expected " + toString(expected));
1935 return FALSE; 1959 return FALSE;
1936 } 1960 }
1937 #ifdef VERBOSE_ASSERTIONS 1961 #ifdef VERBOSE_ASSERTIONS
1938 else { 1962 else {
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 } 2072 }
2049 2073
2050 /* 2074 /*
2051 * Hey, Emacs, please set the following: 2075 * Hey, Emacs, please set the following:
2052 * 2076 *
2053 * Local Variables: 2077 * Local Variables:
2054 * indent-tabs-mode: nil 2078 * indent-tabs-mode: nil
2055 * End: 2079 * End:
2056 * 2080 *
2057 */ 2081 */
OLDNEW
« no previous file with comments | « source/test/intltest/intltest.h ('k') | source/test/intltest/intltest.vcxproj » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698