X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/51004dcb01e06fef634b61be77ed73dd61cb6db9..38fbf2fd31f5cd99b500914d6037b1d06b608645:/icuSources/test/cintltst/cucdtst.c diff --git a/icuSources/test/cintltst/cucdtst.c b/icuSources/test/cintltst/cucdtst.c index b31338dd..8b9e8bb6 100644 --- a/icuSources/test/cintltst/cucdtst.c +++ b/icuSources/test/cintltst/cucdtst.c @@ -1,6 +1,8 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html /******************************************************************** * COPYRIGHT: - * Copyright (c) 1997-2013, International Business Machines Corporation and + * Copyright (c) 1997-2016, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /******************************************************************************* @@ -32,10 +34,9 @@ #include "uprops.h" #include "uset_imp.h" #include "usc_impl.h" -#include "udatamem.h" /* for testing ucase_openBinary() */ +#include "udatamem.h" #include "cucdapi.h" - -#define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) +#include "cmemory.h" /* prototypes --------------------------------------------------------------- */ @@ -50,6 +51,7 @@ static void TestCodeUnit(void); static void TestCodePoint(void); static void TestCharLength(void); static void TestCharNames(void); +static void TestUCharFromNameUnderflow(void); static void TestMirroring(void); static void TestUScriptRunAPI(void); static void TestAdditionalProperties(void); @@ -57,7 +59,6 @@ static void TestNumericProperties(void); static void TestPropertyNames(void); static void TestPropertyValues(void); static void TestConsistency(void); -static void TestUCase(void); static void TestUBiDiProps(void); static void TestCaseFolding(void); @@ -104,7 +105,6 @@ parseUCDFile(const char *filename, /* test data ---------------------------------------------------------------- */ -static const UChar LAST_CHAR_CODE_IN_FILE = 0xFFFD; static const char tagStrings[] = "MnMcMeNdNlNoZsZlZpCcCfCsCoCnLuLlLtLmLoPcPdPsPePoSmScSkSoPiPf"; static const int32_t tagValues[] = { @@ -159,7 +159,12 @@ static const char dirStrings[][5] = { "RLO", "PDF", "NSM", - "BN" + "BN", + /* new in Unicode 6.3/ICU 52 */ + "FSI", + "LRI", + "RLI", + "PDI" }; void addUnicodeTest(TestNode** root); @@ -180,6 +185,7 @@ void addUnicodeTest(TestNode** root) addTest(root, &TestControlPrint, "tsutil/cucdtst/TestControlPrint"); addTest(root, &TestIdentifier, "tsutil/cucdtst/TestIdentifier"); addTest(root, &TestCharNames, "tsutil/cucdtst/TestCharNames"); + addTest(root, &TestUCharFromNameUnderflow, "tsutil/cucdtst/TestUCharFromNameUnderflow"); addTest(root, &TestMirroring, "tsutil/cucdtst/TestMirroring"); addTest(root, &TestUScriptCodeAPI, "tsutil/cucdtst/TestUScriptCodeAPI"); addTest(root, &TestHasScript, "tsutil/cucdtst/TestHasScript"); @@ -189,7 +195,6 @@ void addUnicodeTest(TestNode** root) addTest(root, &TestPropertyNames, "tsutil/cucdtst/TestPropertyNames"); addTest(root, &TestPropertyValues, "tsutil/cucdtst/TestPropertyValues"); addTest(root, &TestConsistency, "tsutil/cucdtst/TestConsistency"); - addTest(root, &TestUCase, "tsutil/cucdtst/TestUCase"); addTest(root, &TestUBiDiProps, "tsutil/cucdtst/TestUBiDiProps"); addTest(root, &TestCaseFolding, "tsutil/cucdtst/TestCaseFolding"); } @@ -318,7 +323,7 @@ Checks LetterLike Symbols which were previously a source of confusion 0x1FFC, 0x1FFC, }; - int32_t num = sizeof(expected)/sizeof(expected[0]); + int32_t num = UPRV_LENGTHOF(expected); for(i=0; i=18 && i<(int32_t)(sizeof(codePoint)/sizeof(codePoint[0]))){ + else if(i >=18 && i", &errorCode); + if(U_SUCCESS(errorCode)) { + log_err("u_charFromName() = U+%04x but should fail - %s\n", c, u_errorName(errorCode)); + } + + // Test related edge cases. + errorCode=U_ZERO_ERROR; + c=u_charFromName(U_EXTENDED_CHAR_NAME, "<-00a0>", &errorCode); + if(U_SUCCESS(errorCode)) { + log_err("u_charFromName(<-00a0>) = U+%04x but should fail - %s\n", c, u_errorName(errorCode)); + } + + errorCode=U_ZERO_ERROR; + c=u_charFromName(U_EXTENDED_CHAR_NAME, "", &errorCode); + if(U_SUCCESS(errorCode)) { + log_err("u_charFromName() = U+%04x but should fail - %s\n", c, u_errorName(errorCode)); + } + + errorCode=U_ZERO_ERROR; + c=u_charFromName(U_EXTENDED_CHAR_NAME, "", &errorCode); + if(U_SUCCESS(errorCode)) { + log_err("u_charFromName() = U+%04x but should fail - %s\n", c, u_errorName(errorCode)); + } +} + /* test u_isMirrored() and u_charMirror() ----------------------------------- */ static void @@ -1979,6 +2004,18 @@ TestMirroring() { if(c3!=start) { log_err("u_charMirror() does not roundtrip: U+%04lx->U+%04lx->U+%04lx\n", (long)start, (long)c2, (long)c3); } + c3=u_getBidiPairedBracket(start); + if(u_getIntPropertyValue(start, UCHAR_BIDI_PAIRED_BRACKET_TYPE)==U_BPT_NONE) { + if(c3!=start) { + log_err("u_getBidiPairedBracket(U+%04lx) != self for bpt(c)==None\n", + (long)start); + } + } else { + if(c3!=c2) { + log_err("u_getBidiPairedBracket(U+%04lx) != U+%04lx = bmg(c)'\n", + (long)start, (long)c2); + } + } } while(++start<=end); } } @@ -2058,11 +2095,11 @@ TestUScriptRunAPI() const RunTestData *testData; int32_t nRuns; } testDataEntries[] = { - {testData1, LENGTHOF(testData1)}, - {testData2, LENGTHOF(testData2)} + {testData1, UPRV_LENGTHOF(testData1)}, + {testData2, UPRV_LENGTHOF(testData2)} }; - static const int32_t nTestEntries = LENGTHOF(testDataEntries); + static const int32_t nTestEntries = UPRV_LENGTHOF(testDataEntries); int32_t testEntry; for (testEntry = 0; testEntry < nTestEntries; testEntry += 1) { @@ -2347,7 +2384,7 @@ TestAdditionalProperties() { { 0x0149, UCHAR_DEPRECATED, TRUE }, /* changed in Unicode 5.2 */ { 0x0341, UCHAR_DEPRECATED, FALSE }, /* changed in Unicode 5.2 */ - { 0xe0041, UCHAR_DEPRECATED, TRUE }, /* changed from Unicode 5 to 5.1 */ + { 0xe0001, UCHAR_DEPRECATED, TRUE }, /* changed from Unicode 5 to 5.1 */ { 0xe0100, UCHAR_DEPRECATED, FALSE }, { 0x00a0, UCHAR_GRAPHEME_BASE, TRUE }, @@ -2407,8 +2444,7 @@ TestAdditionalProperties() { { 0x10909, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT }, { 0x10fe4, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT }, - { 0x0605, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT_ARABIC }, - { 0x061c, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT_ARABIC }, + { 0x061d, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT_ARABIC }, { 0x063f, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT_ARABIC }, { 0x070e, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT_ARABIC }, { 0x0775, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT_ARABIC }, @@ -2421,7 +2457,7 @@ TestAdditionalProperties() { { 0x155A, UCHAR_BLOCK, UBLOCK_UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS }, { 0x1717, UCHAR_BLOCK, UBLOCK_TAGALOG }, { 0x1900, UCHAR_BLOCK, UBLOCK_LIMBU }, - { 0x1AFF, UCHAR_BLOCK, UBLOCK_NO_BLOCK }, + { 0x1CBF, UCHAR_BLOCK, UBLOCK_NO_BLOCK }, { 0x3040, UCHAR_BLOCK, UBLOCK_HIRAGANA }, { 0x1D0FF, UCHAR_BLOCK, UBLOCK_BYZANTINE_MUSICAL_SYMBOLS }, { 0x50000, UCHAR_BLOCK, UBLOCK_NO_BLOCK }, @@ -2615,6 +2651,40 @@ TestAdditionalProperties() { { 0x08ba, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT_ARABIC }, { 0x1eee4, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT_ARABIC }, + { -1, 0x630, 0 }, /* version break for Unicode 6.3 */ + + /* unassigned code points in the currency symbols block now default to ET */ + { 0x20C0, UCHAR_BIDI_CLASS, U_EUROPEAN_NUMBER_TERMINATOR }, + { 0x20CF, UCHAR_BIDI_CLASS, U_EUROPEAN_NUMBER_TERMINATOR }, + + /* new property in Unicode 6.3 */ + { 0x0027, UCHAR_BIDI_PAIRED_BRACKET_TYPE, U_BPT_NONE }, + { 0x0028, UCHAR_BIDI_PAIRED_BRACKET_TYPE, U_BPT_OPEN }, + { 0x0029, UCHAR_BIDI_PAIRED_BRACKET_TYPE, U_BPT_CLOSE }, + { 0xFF5C, UCHAR_BIDI_PAIRED_BRACKET_TYPE, U_BPT_NONE }, + { 0xFF5B, UCHAR_BIDI_PAIRED_BRACKET_TYPE, U_BPT_OPEN }, + { 0xFF5D, UCHAR_BIDI_PAIRED_BRACKET_TYPE, U_BPT_CLOSE }, + + { -1, 0x700, 0 }, /* version break for Unicode 7.0 */ + + /* new character range with Joining_Group values */ + { 0x10ABF, UCHAR_JOINING_GROUP, U_JG_NO_JOINING_GROUP }, + { 0x10AC0, UCHAR_JOINING_GROUP, U_JG_MANICHAEAN_ALEPH }, + { 0x10AC1, UCHAR_JOINING_GROUP, U_JG_MANICHAEAN_BETH }, + { 0x10AEF, UCHAR_JOINING_GROUP, U_JG_MANICHAEAN_HUNDRED }, + { 0x10AF0, UCHAR_JOINING_GROUP, U_JG_NO_JOINING_GROUP }, + + { -1, 0xa00, 0 }, // version break for Unicode 10 + + { 0x1F1E5, UCHAR_REGIONAL_INDICATOR, FALSE }, + { 0x1F1E7, UCHAR_REGIONAL_INDICATOR, TRUE }, + { 0x1F1FF, UCHAR_REGIONAL_INDICATOR, TRUE }, + { 0x1F200, UCHAR_REGIONAL_INDICATOR, FALSE }, + + { 0x0600, UCHAR_PREPENDED_CONCATENATION_MARK, TRUE }, + { 0x0606, UCHAR_PREPENDED_CONCATENATION_MARK, FALSE }, + { 0x110BD, UCHAR_PREPENDED_CONCATENATION_MARK, TRUE }, + /* undefined UProperty values */ { 0x61, 0x4a7, 0 }, { 0x234bc, 0x15ed, 0 } @@ -2637,7 +2707,7 @@ TestAdditionalProperties() { } /* test u_charAge() */ - for(i=0; ipHeader, -1, &errorCode); - if(U_FAILURE(errorCode)) { - log_err("ucase_openBinary() fails for the contents of " UCASE_DATA_NAME "." UCASE_DATA_TYPE ": %s\n", - u_errorName(errorCode)); - udata_close(pData); - return; - } - - if(UCASE_LOWER!=ucase_getType(csp, 0xdf)) { /* verify islower(sharp s) */ - log_err("ucase_openBinary() does not seem to return working UCaseProps\n"); - } - - ucase_close(csp); - udata_close(pData); - - /* coverage for ucase_getDummy() */ - errorCode=U_ZERO_ERROR; - ccsp=ucase_getDummy(&errorCode); - if(ucase_tolower(ccsp, 0x41)!=0x41) { - log_err("ucase_tolower(dummy, A)!=A\n"); - } -#endif -} - /* API coverage for ubidi_props.c */ static void TestUBiDiProps() { #if !HARDCODED_DATA_4497 @@ -3293,7 +3323,7 @@ testFold(UChar32 c, int which, log_err("u_foldCase(U+%04lx, default)=U+%04lx != U+%04lx\n", (long)c, (long)c2, (long)simple); } if((which&CF_FULL)!=0) { - length2=u_strFoldCase(t, LENGTHOF(t), s, length, 0, &errorCode); + length2=u_strFoldCase(t, UPRV_LENGTHOF(t), s, length, 0, &errorCode); if(length2!=fullLength || 0!=u_memcmp(t, full, fullLength)) { log_err("u_strFoldCase(U+%04lx, default) does not fold properly\n", (long)c); } @@ -3303,7 +3333,7 @@ testFold(UChar32 c, int which, log_err("u_foldCase(U+%04lx, turkic)=U+%04lx != U+%04lx\n", (long)c, (long)c2, (long)simple); } - length2=u_strFoldCase(t, LENGTHOF(t), s, length, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode); + length2=u_strFoldCase(t, UPRV_LENGTHOF(t), s, length, U_FOLD_CASE_EXCLUDE_SPECIAL_I, &errorCode); if(length2!=turkicFullLength || 0!=u_memcmp(t, turkicFull, length2)) { log_err("u_strFoldCase(U+%04lx, turkic) does not fold properly\n", (long)c); }