X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/51004dcb01e06fef634b61be77ed73dd61cb6db9..HEAD:/icuSources/test/cintltst/udatatst.c?ds=inline diff --git a/icuSources/test/cintltst/udatatst.c b/icuSources/test/cintltst/udatatst.c index a2f02451..5c57d5aa 100644 --- a/icuSources/test/cintltst/udatatst.c +++ b/icuSources/test/cintltst/udatatst.c @@ -1,10 +1,12 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** * COPYRIGHT: - * Copyright (c) 1998-2012, International Business Machines Corporation and + * Copyright (c) 1998-2016, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /* -* File test.c +* File udatatst.c * * Modification History: * @@ -16,6 +18,7 @@ #include "unicode/utypes.h" #include "unicode/putil.h" #include "unicode/udata.h" +#include "unicode/ucal.h" #include "unicode/uchar.h" #include "unicode/ucnv.h" #include "unicode/ures.h" @@ -27,19 +30,10 @@ #include "udatamem.h" #include "cintltst.h" #include "ubrkimpl.h" - -#include -#include -#include +#include "toolutil.h" /* for uprv_fileExists() */ #include #include -#if U_PLATFORM_USES_ONLY_WIN32_API -#include -#else -#include -#endif - /* includes for TestSwapData() */ #include "udataswp.h" @@ -64,8 +58,6 @@ unorm2_swap(const UDataSwapper *ds, /* other definitions and prototypes */ -#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) - #if !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION static void TestUDataOpen(void); static void TestUDataOpenChoiceDemo1(void); @@ -81,7 +73,9 @@ static void TestICUDataName(void); static void PointerTableOfContents(void); static void SetBadCommonData(void); static void TestUDataFileAccess(void); - +#if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION +static void TestTZDataDir(void); +#endif void addUDataTest(TestNode** root); @@ -103,6 +97,9 @@ addUDataTest(TestNode** root) addTest(root, &PointerTableOfContents, "udatatst/PointerTableOfContents" ); addTest(root, &SetBadCommonData, "udatatst/SetBadCommonData" ); addTest(root, &TestUDataFileAccess, "udatatst/TestUDataFileAccess" ); +#if !UCONFIG_NO_FORMATTING && !UCONFIG_NO_FILE_IO && !UCONFIG_NO_LEGACY_CONVERSION + addTest(root, &TestTZDataDir, "udatatst/TestTZDataDir" ); +#endif } #if 0 @@ -136,10 +133,9 @@ static void TestUDataOpen(){ char* path=(char*)malloc(sizeof(char) * (strlen(ctest_dataOutDir()) + strlen(U_ICUDATA_NAME) - + strlen("/build")+1 ) ); + + strlen("/build/tmp/..")+1 ) ); char *icuDataFilePath = 0; - struct stat stat_buf; const char* testPath=loadTestData(&status); if(U_FAILURE(status)) { @@ -149,10 +145,7 @@ static void TestUDataOpen(){ } /* lots_of_mallocs(); */ - - strcat(strcpy(path, ctest_dataOutDir()), U_ICUDATA_NAME); - - log_verbose("Testing udata_open()\n"); + log_verbose("Testing udata_open(%s)\n", testPath); result=udata_open(testPath, type, name, &status); if(U_FAILURE(status)){ log_data_err("FAIL: udata_open() failed for path = %s, name=%s, type=%s, \n errorcode=%s\n", testPath, name, type, myErrorName(status)); @@ -161,20 +154,23 @@ static void TestUDataOpen(){ udata_close(result); } - /* If the ICU system common data file is present in this confiugration, - * verify that udata_open can explicitly fetch items from it. - * If packaging mode == dll, the file may not exist. So, if the file is - * missing, skip this test without error. - */ - icuDataFilePath = (char *)malloc(strlen(path) + 10); - strcpy(icuDataFilePath, path); - strcat(icuDataFilePath, ".dat"); - /* lots_of_mallocs(); */ - if (stat(icuDataFilePath, &stat_buf) == 0) { - int i; - log_verbose("Testing udata_open() on %s\n", icuDataFilePath); - for(i=0; isize>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && @@ -552,6 +591,7 @@ static UBool U_CALLCONV isAcceptable2(void *context, const char *type, const char *name, const UDataInfo *pInfo){ + (void)context; // suppress compiler warnings about unused variable UVersionInfo unicodeVersion; u_getUnicodeVersion(unicodeVersion); @@ -580,6 +620,7 @@ static UBool U_CALLCONV isAcceptable3(void *context, const char *type, const char *name, const UDataInfo *pInfo){ + (void)context; // suppress compiler warnings about unused variable if( pInfo->size>=20 && pInfo->isBigEndian==U_IS_BIG_ENDIAN && @@ -1096,7 +1137,7 @@ static void TestICUDataName() switch(U_CHARSET_FAMILY) { case U_ASCII_FAMILY: - switch(U_IS_BIG_ENDIAN) + switch((int)U_IS_BIG_ENDIAN) { case 1: typeChar = 'b'; @@ -1195,7 +1236,8 @@ static const struct { {0x31, 0x31, 0x31, 0x31}, /* dataFormat="1111" */ {0, 0, 0, 0}, /* formatVersion */ - {0, 0, 0, 0}} /* dataVersion */ + {0, 0, 0, 0}}, /* dataVersion */ + 0 }; #endif @@ -1272,8 +1314,11 @@ static const struct { #if !UCONFIG_NO_COLLATION /* standalone collation data files */ {"ucadata", "icu", ucol_swap}, +#if 0 + /* Starting with ICU 53, the "inverse UCA" data is integrated into ucadata.icu. */ {"invuca", "icu", ucol_swapInverseUCA}, #endif +#endif #if !UCONFIG_NO_LEGACY_CONVERSION /* conversion table files */ @@ -1332,15 +1377,18 @@ static const struct { * to testdata) for code coverage in tests. * See Jitterbug 4497. * - * ICU4C 4.4 adds normalization data files again, e.g., nfc.nrm. + * ICU4C 4.4 adds normalization data files again, e.g., nfkc.nrm. */ {"uprops", "icu", uprops_swap}, {"ucase", "icu", ucase_swap}, {"ubidi", "icu", ubidi_swap}, #endif #if !UCONFIG_NO_NORMALIZATION && !UCONFIG_ONLY_COLLATION - {"nfc", "nrm", unorm2_swap}, - {"confusables", "cfu", uspoof_swap}, + {"nfkc", "nrm", unorm2_swap}, +#if !UCONFIG_NO_REGULAR_EXPRESSIONS + {"confusables", "cfu", uspoof_swap}, /* spoof data missing without regex */ +#endif + #endif {"unames", "icu", uchar_swapNames} /* the last item should not be #if'ed so that it can reliably omit the last comma */ @@ -1351,6 +1399,7 @@ static const struct { static void U_CALLCONV printError(void *context, const char *fmt, va_list args) { + (void)context; // suppress compiler warnings about unused variable vlog_info("[swap] ", fmt, args); log_err("\n"); /* Register error */ } @@ -1644,17 +1693,16 @@ TestSwapData() { } errorCode=U_ZERO_ERROR; - /* Test argument checking. ucol_swapBinary is normally tested via ures_swap, and isn't normally called directly. */ + /* Test argument checking. ucol_swap is normally tested via ures_swap, and isn't normally called directly. */ #if !UCONFIG_NO_COLLATION - ucol_swapBinary(NULL, NULL, -1, NULL, NULL); - ucol_swapBinary(NULL, NULL, -1, NULL, &errorCode); + ucol_swap(NULL, NULL, -1, NULL, &errorCode); if (errorCode != U_ILLEGAL_ARGUMENT_ERROR) { - log_err("ucol_swapBinary did not fail as expected\n", name); + log_err("ucol_swap did not fail as expected\n", name); } errorCode=U_ZERO_ERROR; #endif - for(i=0; i