summaryrefslogtreecommitdiff
path: root/Build/source/libs/icu-xetex/test/cintltst/cucdtst.c
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/icu-xetex/test/cintltst/cucdtst.c')
-rw-r--r--Build/source/libs/icu-xetex/test/cintltst/cucdtst.c236
1 files changed, 175 insertions, 61 deletions
diff --git a/Build/source/libs/icu-xetex/test/cintltst/cucdtst.c b/Build/source/libs/icu-xetex/test/cintltst/cucdtst.c
index 67ab67a76d3..0aa15affa92 100644
--- a/Build/source/libs/icu-xetex/test/cintltst/cucdtst.c
+++ b/Build/source/libs/icu-xetex/test/cintltst/cucdtst.c
@@ -1,6 +1,6 @@
/********************************************************************
* COPYRIGHT:
- * Copyright (c) 1997-2005, International Business Machines Corporation and
+ * Copyright (c) 1997-2006, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************/
/********************************************************************************
@@ -211,7 +211,8 @@ Checks LetterLike Symbols which were previously a source of confusion
*/
for (i=0x2100;i<0x2138;i++)
{
- if(i!=0x2126 && i!=0x212a && i!=0x212b)
+ /* Unicode 5.0 adds lowercase U+214E (TURNED SMALL F) to U+2132 (TURNED CAPITAL F) */
+ if(i!=0x2126 && i!=0x212a && i!=0x212b && i!=0x2132)
{
if (i != (int)u_tolower(i)) /* itself */
log_err("Failed case conversion with itself: U+%04x\n", i);
@@ -324,57 +325,77 @@ Checks LetterLike Symbols which were previously a source of confusion
}
}
-/* compare two sets, which is not easy with the current (ICU 2.4) C API... */
-
+/* compare two sets and verify that their difference or intersection is empty */
static UBool
showADiffB(const USet *a, const USet *b,
const char *a_name, const char *b_name,
UBool expect, UBool diffIsError) {
+ USet *aa;
int32_t i, start, end, length;
- UBool equal;
UErrorCode errorCode;
+ /*
+ * expect:
+ * TRUE -> a-b should be empty, that is, b should contain all of a
+ * FALSE -> a&b should be empty, that is, a should contain none of b (and vice versa)
+ */
+ if(expect ? uset_containsAll(b, a) : uset_containsNone(a, b)) {
+ return TRUE;
+ }
+
+ /* clone a to aa because a is const */
+ aa=uset_open(1, 0);
+ if(aa==NULL) {
+ /* unusual problem - out of memory? */
+ return FALSE;
+ }
+ uset_addAll(aa, a);
+
+ /* compute the set in question */
+ if(expect) {
+ /* a-b */
+ uset_removeAll(aa, b);
+ } else {
+ /* a&b */
+ uset_retainAll(aa, b);
+ }
+
+ /* aa is not empty because of the initial tests above; show its contents */
errorCode=U_ZERO_ERROR;
- equal=TRUE;
i=0;
for(;;) {
- length=uset_getItem(a, i, &start, &end, NULL, 0, &errorCode);
+ length=uset_getItem(aa, i, &start, &end, NULL, 0, &errorCode);
if(errorCode==U_INDEX_OUTOFBOUNDS_ERROR) {
- return equal; /* done */
+ break; /* done */
}
if(U_FAILURE(errorCode)) {
- log_err("error comparing %s with %s at item %d: %s\n",
+ log_err("error comparing %s with %s at difference item %d: %s\n",
a_name, b_name, i, u_errorName(errorCode));
- return FALSE;
+ break;
}
if(length!=0) {
- return equal; /* done with code points, got a string or -1 */
+ break; /* done with code points, got a string or -1 */
}
- if(expect!=uset_containsRange(b, start, end)) {
- equal=FALSE;
- while(start<=end) {
- if(expect!=uset_contains(b, start)) {
- if(diffIsError) {
- if(expect) {
- log_err("error: %s contains U+%04x but %s does not\n", a_name, start, b_name);
- } else {
- log_err("error: %s and %s both contain U+%04x but should not intersect\n", a_name, b_name, start);
- }
- } else {
- if(expect) {
- log_verbose("info: %s contains U+%04x but %s does not\n", a_name, start, b_name);
- } else {
- log_verbose("info: %s and %s both contain U+%04x but should not intersect\n", a_name, b_name, start);
- }
- }
- }
- ++start;
+ if(diffIsError) {
+ if(expect) {
+ log_err("error: %s contains U+%04x..U+%04x but %s does not\n", a_name, start, end, b_name);
+ } else {
+ log_err("error: %s and %s both contain U+%04x..U+%04x but should not intersect\n", a_name, b_name, start, end);
+ }
+ } else {
+ if(expect) {
+ log_verbose("info: %s contains U+%04x..U+%04x but %s does not\n", a_name, start, end, b_name);
+ } else {
+ log_verbose("info: %s and %s both contain U+%04x..U+%04x but should not intersect\n", a_name, b_name, start, end);
}
}
++i;
}
+
+ uset_close(aa);
+ return FALSE;
}
static UBool
@@ -395,8 +416,12 @@ static UBool
compareUSets(const USet *a, const USet *b,
const char *a_name, const char *b_name,
UBool diffIsError) {
+ /*
+ * Use an arithmetic & not a logical && so that both branches
+ * are always taken and all differences are shown.
+ */
return
- showAMinusB(a, b, a_name, b_name, diffIsError) &&
+ showAMinusB(a, b, a_name, b_name, diffIsError) &
showAMinusB(b, a, b_name, a_name, diffIsError);
}
@@ -1810,18 +1835,18 @@ TestMirroring() {
errorCode=U_ZERO_ERROR;
set=uset_openPattern(mirroredPattern, 17, &errorCode);
- if (U_FAILURE(errorCode)) {
- log_data_err("uset_openPattern(mirroredPattern, 17, &errorCode) failed!");
- } else {
- for(i=0; 0==uset_getItem(set, i, &start, &end, NULL, 0, &errorCode); ++i) {
- do {
- c2=u_charMirror(start);
- c3=u_charMirror(c2);
- if(c3!=start) {
- log_err("u_charMirror() does not roundtrip: U+%04lx->U+%04lx->U+%04lx\n", (long)start, (long)c2, (long)c3);
- }
- } while(++start<=end);
- }
+ if (U_FAILURE(errorCode)) {
+ log_data_err("uset_openPattern(mirroredPattern, 17, &errorCode) failed!");
+ } else {
+ for(i=0; 0==uset_getItem(set, i, &start, &end, NULL, 0, &errorCode); ++i) {
+ do {
+ c2=u_charMirror(start);
+ c3=u_charMirror(c2);
+ if(c3!=start) {
+ log_err("u_charMirror() does not roundtrip: U+%04lx->U+%04lx->U+%04lx\n", (long)start, (long)c2, (long)c3);
+ }
+ } while(++start<=end);
+ }
}
uset_close(set);
@@ -2229,7 +2254,8 @@ TestAdditionalProperties() {
{ 0x0590, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
{ 0x05cf, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
{ 0x05ed, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
- { 0x07f2, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
+ { 0x07f2, UCHAR_BIDI_CLASS, U_DIR_NON_SPACING_MARK }, /* Nko, new in Unicode 5.0 */
+ { 0x07fe, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT }, /* unassigned R */
{ 0x08ba, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
{ 0xfb37, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
{ 0xfb42, UCHAR_BIDI_CLASS, U_RIGHT_TO_LEFT },
@@ -2447,21 +2473,60 @@ TestAdditionalProperties() {
) {
log_err("error: u_getIntPropertyMinValue() wrong\n");
}
-
- if( u_getIntPropertyMaxValue(UCHAR_DASH)!=1 ||
- u_getIntPropertyMaxValue(UCHAR_ID_CONTINUE)!=1 ||
- u_getIntPropertyMaxValue(UCHAR_BINARY_LIMIT-1)!=1 ||
- u_getIntPropertyMaxValue(UCHAR_BIDI_CLASS)!=(int32_t)U_CHAR_DIRECTION_COUNT-1 ||
- u_getIntPropertyMaxValue(UCHAR_BLOCK)!=(int32_t)UBLOCK_COUNT-1 ||
- u_getIntPropertyMaxValue(UCHAR_LINE_BREAK)!=(int32_t)U_LB_COUNT-1 ||
- u_getIntPropertyMaxValue(UCHAR_SCRIPT)!=(int32_t)USCRIPT_CODE_LIMIT-1 ||
- u_getIntPropertyMaxValue(0x2345)!=-1 /*JB#2410*/ ||
- u_getIntPropertyMaxValue(UCHAR_DECOMPOSITION_TYPE) != (int32_t) (U_DT_COUNT - 1) ||
- u_getIntPropertyMaxValue(UCHAR_JOINING_GROUP) != (int32_t) (U_JG_COUNT -1) ||
- u_getIntPropertyMaxValue(UCHAR_JOINING_TYPE) != (int32_t) (U_JT_COUNT -1) ||
- u_getIntPropertyMaxValue(UCHAR_EAST_ASIAN_WIDTH) != (int32_t) (U_EA_COUNT -1)
- ) {
- log_err("error: u_getIntPropertyMaxValue() wrong\n");
+ if( u_getIntPropertyMaxValue(UCHAR_DASH)!=1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_DASH) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_ID_CONTINUE)!=1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_ID_CONTINUE) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_BINARY_LIMIT-1)!=1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_BINARY_LIMIT-1) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_BIDI_CLASS)!=(int32_t)U_CHAR_DIRECTION_COUNT-1 ) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_BIDI_CLASS) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_BLOCK)!=(int32_t)UBLOCK_COUNT-1 ) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_BLOCK) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_LINE_BREAK)!=(int32_t)U_LB_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_LINE_BREAK) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_SCRIPT)!=(int32_t)USCRIPT_CODE_LIMIT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_SCRIPT) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_NUMERIC_TYPE)!=(int32_t)U_NT_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_NUMERIC_TYPE) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_GENERAL_CATEGORY)!=(int32_t)U_CHAR_CATEGORY_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_GENERAL_CATEGORY) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_HANGUL_SYLLABLE_TYPE)!=(int32_t)U_HST_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_HANGUL_SYLLABLE_TYPE) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_GRAPHEME_CLUSTER_BREAK)!=(int32_t)U_GCB_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_GRAPHEME_CLUSTER_BREAK) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_SENTENCE_BREAK)!=(int32_t)U_SB_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_SENTENCE_BREAK) wrong\n");
+ }
+ if(u_getIntPropertyMaxValue(UCHAR_WORD_BREAK)!=(int32_t)U_WB_COUNT-1) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_WORD_BREAK) wrong\n");
+ }
+ /*JB#2410*/
+ if( u_getIntPropertyMaxValue(0x2345)!=-1) {
+ log_err("error: u_getIntPropertyMaxValue(0x2345) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_DECOMPOSITION_TYPE) != (int32_t) (U_DT_COUNT - 1)) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_DECOMPOSITION_TYPE) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_JOINING_GROUP) != (int32_t) (U_JG_COUNT -1)) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_JOINING_GROUP) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_JOINING_TYPE) != (int32_t) (U_JT_COUNT -1)) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_JOINING_TYPE) wrong\n");
+ }
+ if( u_getIntPropertyMaxValue(UCHAR_EAST_ASIAN_WIDTH) != (int32_t) (U_EA_COUNT -1)) {
+ log_err("error: u_getIntPropertyMaxValue(UCHAR_EAST_ASIAN_WIDTH) wrong\n");
}
/* test u_hasBinaryProperty() and u_getIntPropertyValue() */
@@ -2722,7 +2787,7 @@ TestPropertyValues(void) {
max);
}
- /* Script should return 0 for an invalid code point. */
+ /* Script should return USCRIPT_INVALID_CODE for an invalid code point. */
for (i=0; i<2; ++i) {
int32_t script;
const char* desc;
@@ -2742,7 +2807,7 @@ TestPropertyValues(void) {
}
/* We don't explicitly test ec. It should be U_FAILURE but it
isn't documented as such. */
- if (script != 0) {
+ if (script != (int32_t)USCRIPT_INVALID_CODE) {
log_err("FAIL: %s = %d, exp. 0\n",
desc, script);
}
@@ -2784,12 +2849,28 @@ TestConsistency() {
U_STRING_DECL(formatPattern, "[:Cf:]", 6);
U_STRING_DECL(alphaPattern, "[:Alphabetic:]", 14);
+ U_STRING_DECL(mathBlocksPattern,
+ "[[:block=Mathematical Operators:][:block=Miscellaneous Mathematical Symbols-A:][:block=Miscellaneous Mathematical Symbols-B:][:block=Supplemental Mathematical Operators:][:block=Mathematical Alphanumeric Symbols:]]",
+ 1+32+46+46+45+43+1+1); /* +1 for NUL */
+ U_STRING_DECL(mathPattern, "[:Math:]", 8);
+ U_STRING_DECL(unassignedPattern, "[:Cn:]", 6);
+ U_STRING_DECL(unknownPattern, "[:sc=Unknown:]", 14);
+ U_STRING_DECL(reservedPattern, "[[:Cn:][:Co:][:Cs:]]", 20);
+
U_STRING_INIT(hyphenPattern, "[:Hyphen:]", 10);
U_STRING_INIT(dashPattern, "[:Dash:]", 8);
U_STRING_INIT(lowerPattern, "[:Lowercase:]", 13);
U_STRING_INIT(formatPattern, "[:Cf:]", 6);
U_STRING_INIT(alphaPattern, "[:Alphabetic:]", 14);
+ U_STRING_INIT(mathBlocksPattern,
+ "[[:block=Mathematical Operators:][:block=Miscellaneous Mathematical Symbols-A:][:block=Miscellaneous Mathematical Symbols-B:][:block=Supplemental Mathematical Operators:][:block=Mathematical Alphanumeric Symbols:]]",
+ 1+32+46+46+45+43+1+1); /* +1 for NUL */
+ U_STRING_INIT(mathPattern, "[:Math:]", 8);
+ U_STRING_INIT(unassignedPattern, "[:Cn:]", 6);
+ U_STRING_INIT(unknownPattern, "[:sc=Unknown:]", 14);
+ U_STRING_INIT(reservedPattern, "[[:Cn:][:Co:][:Cs:]]", 20);
+
/*
* It used to be that UCD.html and its precursors said
* "Those dashes used to mark connections between pieces of words,
@@ -2909,6 +2990,39 @@ TestConsistency() {
uset_close(set2);
#endif
+
+ /* verify that all assigned characters in Math blocks are exactly Math characters */
+ errorCode=U_ZERO_ERROR;
+ set1=uset_openPattern(mathBlocksPattern, -1, &errorCode);
+ set2=uset_openPattern(mathPattern, 8, &errorCode);
+ set3=uset_openPattern(unassignedPattern, 6, &errorCode);
+ if(U_SUCCESS(errorCode)) {
+ uset_retainAll(set2, set1); /* [math blocks]&[:Math:] */
+ uset_complement(set3); /* assigned characters */
+ uset_retainAll(set1, set3); /* [math blocks]&[assigned] */
+ compareUSets(set1, set2,
+ "[assigned Math block chars]", "[math blocks]&[:Math:]",
+ TRUE);
+ } else {
+ log_err("error opening [math blocks] or [:Math:] or [:Cn:] - %s\n", u_errorName(errorCode));
+ }
+ uset_close(set1);
+ uset_close(set2);
+ uset_close(set3);
+
+ /* new in Unicode 5.0: exactly all unassigned+PUA+surrogate code points have script=Unknown */
+ errorCode=U_ZERO_ERROR;
+ set1=uset_openPattern(unknownPattern, 14, &errorCode);
+ set2=uset_openPattern(reservedPattern, 20, &errorCode);
+ if(U_SUCCESS(errorCode)) {
+ compareUSets(set1, set2,
+ "[:sc=Unknown:]", "[[:Cn:][:Co:][:Cs:]]",
+ TRUE);
+ } else {
+ log_err("error opening [:sc=Unknown:] or [[:Cn:][:Co:][:Cs:]] - %s\n", u_errorName(errorCode));
+ }
+ uset_close(set1);
+ uset_close(set2);
}
/*