diff --git a/icu4c/source/test/cintltst/cucdtst.c b/icu4c/source/test/cintltst/cucdtst.c index c1d5fdab6d..68d4d2425b 100644 --- a/icu4c/source/test/cintltst/cucdtst.c +++ b/icu4c/source/test/cintltst/cucdtst.c @@ -46,11 +46,14 @@ static void TestUnescape(void); static void TestUScriptCodeAPI(void); static void TestUScriptRunAPI(void); static void TestAdditionalProperties(void); +static void TestNumericProperties(void); /* internal methods used */ static int32_t MakeProp(char* str); static int32_t MakeDir(char* str); +#define LENGTHOF(array) (sizeof(array)/sizeof((array)[0])) + /* get the sign of an integer */ #define _SIGN(value) ((value)==0 ? 0 : ((int32_t)(value)>>31)|1) @@ -121,6 +124,7 @@ void addUnicodeTest(TestNode** root) { addTest(root, &TestUnicodeData, "tsutil/cucdtst/TestUnicodeData"); addTest(root, &TestAdditionalProperties, "tsutil/cucdtst/TestAdditionalProperties"); + addTest(root, &TestNumericProperties, "tsutil/cucdtst/TestNumericProperties"); addTest(root, &TestUpperLower, "tsutil/cucdtst/TestUpperLower"); addTest(root, &TestLetterNumber, "tsutil/cucdtst/TestLetterNumber"); addTest(root, &TestMisc, "tsutil/cucdtst/TestMisc"); @@ -555,9 +559,11 @@ unicodeDataLineFn(void *context, char *fields[][2], int32_t fieldCount, UErrorCode *pErrorCode) { + char buffer[100]; char *end; uint32_t value; UChar32 c; + int32_t i; int8_t type; /* get the character code, field 0 */ @@ -588,16 +594,27 @@ unicodeDataLineFn(void *context, log_err("error in UnicodeData.txt: combining class %lu out of range\n", value); return; } - if(value!=u_getCombiningClass(c)) { + if(value!=u_getCombiningClass(c) || value!=(uint32_t)u_getIntPropertyValue(c, UCHAR_CANONICAL_COMBINING_CLASS)) { log_err("error: u_getCombiningClass(U+%04lx)==%hu instead of %lu\n", c, u_getCombiningClass(c), value); } /* get BiDi category, field 4 */ *fields[4][1]=0; - if(u_charDirection(c)!=MakeDir(fields[4][0])) { + i=MakeDir(fields[4][0]); + if(i!=u_charDirection(c) || i!=u_getIntPropertyValue(c, UCHAR_BIDI_CLASS)) { log_err("error: u_charDirection(U+%04lx)==%u instead of %u (%s)\n", c, u_charDirection(c), MakeDir(fields[4][0]), fields[4][0]); } + /* get ISO Comment, field 11 */ + *fields[11][1]=0; + i=u_getISOComment(c, buffer, sizeof(buffer), pErrorCode); + if(U_FAILURE(*pErrorCode) || 0!=uprv_strcmp(fields[11][0], buffer)) { + log_err("error: u_getISOComment(U+%04lx) wrong (%s): \"%s\" should be \"%s\"\n", + c, u_errorName(*pErrorCode), + U_FAILURE(*pErrorCode) ? buffer : "[error]", + fields[11][0]); + } + /* get uppercase mapping, field 12 */ if(fields[12][0]!=fields[12][1]) { value=uprv_strtoul(fields[12][0], &end, 16); @@ -663,6 +680,7 @@ enumTypeRange(const void *context, UChar32 start, UChar32 limit, UCharCategory t if(0!=uprv_strcmp((const char *)context, "a1")) { log_err("error: u_enumCharTypes() passes on an incorrect context pointer\n"); + return FALSE; } count=sizeof(test)/sizeof(test[0]); @@ -682,6 +700,25 @@ enumTypeRange(const void *context, UChar32 start, UChar32 limit, UCharCategory t start, limit, (long)type); return FALSE; } + + /* + * LineBreak.txt specifies: + * # - Assigned characters that are not listed explicitly are given the value + * # "AL". + * # - Unassigned characters are given the value "XX". + * + * PUA characters are listed explicitly with "XX". + * Verify that no assigned character has "XX". + */ + if(type!=U_UNASSIGNED && type!=U_PRIVATE_USE_CHAR) { + while(start