ICU-1229 deprecate UCOL_ constants in UNormalizationMode

X-SVN-Rev: 5894
This commit is contained in:
Markus Scherer 2001-09-22 01:24:03 +00:00
parent 88bce4404c
commit 050177989d
3 changed files with 32 additions and 42 deletions

View file

@ -65,8 +65,7 @@ void TestGetDefaultRules(){
const UChar * defaultRulesArray=ucol_getDefaultRulesArray(&size);
log_verbose("Test the function ucol_getDefaultRulesArray()\n");
coll = ucol_openRules(defaultRulesArray, size, UCOL_DECOMP_CAN, UCOL_PRIMARY, &status);
ucol_setNormalization(coll, UCOL_DEFAULT_NORMALIZATION);
coll = ucol_openRules(defaultRulesArray, size, UCOL_ON, UCOL_PRIMARY, &status);
if(U_SUCCESS(status) && coll !=NULL) {
binColData = (uint8_t*)ucol_cloneRuleData(coll, &len1, &status);
@ -219,10 +218,10 @@ void TestProperty()
doAssert( (ucol_getStrength(col) == UCOL_SECONDARY), "collation object has the wrong strength");
log_verbose("testing ucol_setDecomposition() method ...\n");
ucol_setNormalization(col, UCOL_NO_NORMALIZATION);
doAssert( (ucol_getNormalization(col) != UCOL_DECOMP_CAN_COMP_COMPAT), "collation object's normalization mode is Canonical decomposition followed by canonical composition");
doAssert( (ucol_getNormalization(col) != UCOL_DECOMP_CAN), "collation object's normalization mode is canonical decomposition");
doAssert( (ucol_getNormalization(col) == UCOL_NO_NORMALIZATION), "collation object has the wrong normalization mode");
ucol_setNormalization(col, UNORM_NONE);
doAssert( (ucol_getNormalization(col) != UNORM_NFC), "collation object's normalization mode is Canonical decomposition followed by canonical composition");
doAssert( (ucol_getNormalization(col) != UNORM_NFD), "collation object's normalization mode is canonical decomposition");
doAssert( (ucol_getNormalization(col) == UNORM_NONE), "collation object has the wrong normalization mode");
log_verbose("Get display name for the default collation in German : \n");
@ -328,7 +327,7 @@ void TestRuleBasedColl()
u_uastrcpy(ruleset1, "&9 < a, A < b, B < c, C; ch, cH, Ch, CH < d, D, e, E");
u_uastrcpy(ruleset2, "&9 < a, A < b, B < c, C < d, D, e, E");
col1 = ucol_openRules(ruleset1, u_strlen(ruleset1), UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT_STRENGTH, NULL,&status);
col1 = ucol_openRules(ruleset1, u_strlen(ruleset1), UCOL_DEFAULT, UCOL_DEFAULT_STRENGTH, NULL,&status);
if (U_FAILURE(status)) {
log_err("RuleBased Collator creation failed.: %s\n", myErrorName(status));
return;
@ -337,7 +336,7 @@ void TestRuleBasedColl()
log_verbose("PASS: RuleBased Collator creation passed\n");
status = U_ZERO_ERROR;
col2 = ucol_openRules(ruleset2, u_strlen(ruleset2), UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT_STRENGTH, NULL, &status);
col2 = ucol_openRules(ruleset2, u_strlen(ruleset2), UCOL_DEFAULT, UCOL_DEFAULT_STRENGTH, NULL, &status);
if (U_FAILURE(status)) {
log_err("RuleBased Collator creation failed.: %s\n", myErrorName(status));
return;
@ -363,7 +362,7 @@ void TestRuleBasedColl()
doAssert((u_strcmp(rule2, rule3) != 0), "Default collator getRules failed");
doAssert((u_strcmp(rule1, rule3) != 0), "Default collator getRules failed");
col4=ucol_openRules(rule2, u_strlen(rule2), UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT_STRENGTH, NULL, &status);
col4=ucol_openRules(rule2, u_strlen(rule2), UCOL_DEFAULT, UCOL_DEFAULT_STRENGTH, NULL, &status);
if (U_FAILURE(status)) {
log_err("RuleBased Collator creation failed.: %s\n", myErrorName(status));
return;
@ -441,12 +440,12 @@ void TestDecomposition() {
}
/* there is no reason to have canonical decomposition in en_US OR default locale */
if(ucol_getNormalization(vi_VN) != UCOL_DECOMP_CAN)
if(ucol_getNormalization(vi_VN) != UNORM_NFD)
{
log_err("ERROR: vi_VN collation did not have cannonical decomposition for normalization!\n");
}
if(ucol_getNormalization(el_GR) != UCOL_DECOMP_CAN)
if(ucol_getNormalization(el_GR) != UNORM_NFD)
{
log_err("ERROR: el_GR collation did not have cannonical decomposition for normalization!\n");
}
@ -778,7 +777,7 @@ void TestElemIter()
UErrorCode status = U_ZERO_ERROR;
log_verbose("testing UCollatorElements begins...\n");
col = ucol_open("en_US", &status);
ucol_setNormalization(col, UCOL_NO_NORMALIZATION);
ucol_setNormalization(col, UNORM_NONE);
if (U_FAILURE(status)) {
log_err("ERROR: Default collation creation failed.: %s\n", myErrorName(status));
return;

View file

@ -181,8 +181,7 @@ static void IncompleteCntTest( )
u_uastrcpy(temp, " & Z < ABC < Q < B");
coll = ucol_openRules(temp, u_strlen(temp), UCOL_NO_NORMALIZATION,
UCOL_DEFAULT_STRENGTH, NULL,&status);
coll = ucol_openRules(temp, u_strlen(temp), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL,&status);
if(U_SUCCESS(status)) {
size = sizeof(cnt1)/sizeof(cnt1[0]);
@ -208,8 +207,7 @@ static void IncompleteCntTest( )
u_uastrcpy(temp, " & Z < DAVIS < MARK <DAV");
coll = ucol_openRules(temp, u_strlen(temp), UCOL_NO_NORMALIZATION,
UCOL_DEFAULT_STRENGTH,NULL, &status);
coll = ucol_openRules(temp, u_strlen(temp), UCOL_OFF, UCOL_DEFAULT_STRENGTH,NULL, &status);
if(U_SUCCESS(status)) {
size = sizeof(cnt2)/sizeof(cnt2[0]);
@ -1263,7 +1261,7 @@ static void RamsRulesTest( ) {
log_verbose("Testing rule: %s\n", rulesToTest[i]);
u_uastrcpy(rule, rulesToTest[i]);
ruleLen = u_strlen(rule);
coll = ucol_openRules(rule, ruleLen, UCOL_NO_NORMALIZATION, UCOL_TERTIARY, NULL,&status);
coll = ucol_openRules(rule, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status);
if(U_SUCCESS(status)) {
testCollator(coll, &status);
testCEs(coll, &status);
@ -1293,7 +1291,7 @@ static void IsTailoredTest( ) {
u_uastrcpy(notTailored, "ZabD");
notTailoredLen = u_strlen(notTailored);
coll = ucol_openRules(rule, ruleLen, UCOL_NO_NORMALIZATION, UCOL_TERTIARY, NULL,&status);
coll = ucol_openRules(rule, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status);
if(U_SUCCESS(status)) {
for(i = 0; i<tailoredLen; i++) {
if(!isTailored(coll, tailored[i], &status)) {
@ -1363,8 +1361,7 @@ static void genericRulesStarterWithOptions(const char *rules, const char *s[], u
uint32_t rlen = u_unescape(rules, rlz, 2048);
uint32_t i;
/* Changed UCOL_DEFAULT -> UCOL_DEFAULT_NORMALIZATION due to an inconsistent API and compiler errors */
UCollator *coll = ucol_openRules(rlz, rlen, UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT,NULL, &status);
UCollator *coll = ucol_openRules(rlz, rlen, UCOL_DEFAULT, UCOL_DEFAULT,NULL, &status);
log_verbose("Rules starter for %s\n", rules);
@ -1385,8 +1382,7 @@ static void genericRulesStarter(const char *rules, const char *s[], uint32_t siz
UChar rlz[2048] = { 0 };
uint32_t rlen = u_unescape(rules, rlz, 2048);
/* Changed UCOL_DEFAULT -> UCOL_DEFAULT_NORMALIZATION due to an inconsistent API and compiler errors */
UCollator *coll = ucol_openRules(rlz, rlen, UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT,NULL, &status);
UCollator *coll = ucol_openRules(rlz, rlen, UCOL_DEFAULT, UCOL_DEFAULT,NULL, &status);
log_verbose("Rules starter for %s\n", rules);
@ -1462,7 +1458,7 @@ static void TestImplicitTailoring(void) {
UCollator *coll = NULL;
ruleLen = u_unescape(rule, t1, 256);
coll = ucol_openRules(t1, ruleLen, UCOL_NO_NORMALIZATION, UCOL_TERTIARY,NULL, &status);
coll = ucol_openRules(t1, ruleLen, UCOL_OFF, UCOL_TERTIARY,NULL, &status);
if(U_SUCCESS(status)) {
size = sizeof(impTest)/sizeof(impTest[0]);
@ -1581,7 +1577,7 @@ static void TestComposeDecompose(void) {
static void TestEmptyRule() {
UErrorCode status = U_ZERO_ERROR;
UChar rulez[] = { 0 };
UCollator *coll = ucol_openRules(rulez, 0, UCOL_NO_NORMALIZATION, UCOL_TERTIARY,NULL, &status);
UCollator *coll = ucol_openRules(rulez, 0, UCOL_OFF, UCOL_TERTIARY,NULL, &status);
ucol_close(coll);
}
@ -1600,7 +1596,7 @@ static void TestUCARules() {
ruleLen = ucol_getRulesEx(coll, UCOL_FULL_RULES, rules, ruleLen);
}
log_verbose("Rules length is %d\n", ruleLen);
UCAfromRules = ucol_openRules(rules, ruleLen, UNORM_NONE, UCOL_TERTIARY, NULL,&status);
UCAfromRules = ucol_openRules(rules, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status);
if(U_SUCCESS(status)) {
ucol_close(UCAfromRules);
} else {
@ -1799,10 +1795,9 @@ static void TestRedundantRules() {
log_verbose("testing rule %s, expected to be %s\n", rules[i], expectedRules[i]);
rlen = u_unescape(rules[i], rlz, 2048);
/* Changed UCOL_DEFAULT -> UCOL_DEFAULT_NORMALIZATION due to an inconsistent API and compiler errors */
credundant = ucol_openRules(rlz, rlen, UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT, NULL,&status);
credundant = ucol_openRules(rlz, rlen, UCOL_DEFAULT, UCOL_DEFAULT, NULL,&status);
rlen = u_unescape(expectedRules[i], rlz, 2048);
cresulting = ucol_openRules(rlz, rlen, UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT, NULL,&status);
cresulting = ucol_openRules(rlz, rlen, UCOL_DEFAULT, UCOL_DEFAULT, NULL,&status);
testAgainstUCA(cresulting, credundant, "expected", TRUE, &status);
@ -1855,10 +1850,9 @@ static void TestExpansionSyntax() {
log_verbose("testing rule %s, expected to be %s\n", rules[i], expectedRules[i]);
rlen = u_unescape(rules[i], rlz, 2048);
/* Changed UCOL_DEFAULT -> UCOL_DEFAULT_NORMALIZATION due to an inconsistent API and compiler errors */
credundant = ucol_openRules(rlz, rlen, UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT,NULL, &status);
credundant = ucol_openRules(rlz, rlen, UCOL_DEFAULT, UCOL_DEFAULT, NULL, &status);
rlen = u_unescape(expectedRules[i], rlz, 2048);
cresulting = ucol_openRules(rlz, rlen, UCOL_DEFAULT_NORMALIZATION, UCOL_DEFAULT, NULL,&status);
cresulting = ucol_openRules(rlz, rlen, UCOL_DEFAULT, UCOL_DEFAULT, NULL,&status);
/* testAgainstUCA still doesn't handle expansions correctly, so this is not run */
/* as a hard error test, but only in information mode */
@ -1927,7 +1921,7 @@ static void TestCase( )
}
ucol_close(myCollation);
myCollation = ucol_openRules(gRules, u_strlen(gRules), UNORM_NONE, UCOL_TERTIARY,NULL, &status);
myCollation = ucol_openRules(gRules, u_strlen(gRules), UCOL_OFF, UCOL_TERTIARY,NULL, &status);
if(U_FAILURE(status)){
log_err("ERROR: in creation of rule based collator: %s\n", myErrorName(status));
return;
@ -2391,7 +2385,7 @@ static void TestContraction() {
int j = 0;
log_verbose("Rule %s for testing\n", testrules[i]);
rlen = u_unescape(testrules[i], rule, 32);
coll = ucol_openRules(rule, rlen, UNORM_NFD, UCOL_TERTIARY,NULL, &status);
coll = ucol_openRules(rule, rlen, UCOL_ON, UCOL_TERTIARY,NULL, &status);
if (U_FAILURE(status)) {
log_err("Collator creation failed %s\n", testrules[i]);
return;
@ -2430,7 +2424,7 @@ static void TestContraction() {
}
rlen = u_unescape("& a < b < c < ch < d & c = ch / h", rule, 256);
coll = ucol_openRules(rule, rlen, UNORM_NFD, UCOL_TERTIARY,NULL, &status);
coll = ucol_openRules(rule, rlen, UCOL_ON, UCOL_TERTIARY,NULL, &status);
if (ucol_strcoll(coll, testdata2[0], 2, testdata2[1], 2) != UCOL_LESS) {
log_err("Expected \\u%04x\\u%04x < \\u%04x\\u%04x\n",
testdata2[0][0], testdata2[0][1], testdata2[1][0],
@ -2453,9 +2447,9 @@ static void TestContraction() {
UChar ch = 0x0042 /* 'B' */;
uint32_t ce;
rlen = u_unescape(testrules3[i], rule, 32);
coll1 = ucol_openRules(rule, rlen, UNORM_NFD, UCOL_TERTIARY,NULL, &status);
coll1 = ucol_openRules(rule, rlen, UCOL_ON, UCOL_TERTIARY,NULL, &status);
rlen = u_unescape(testrules3[i + 1], rule, 32);
coll2 = ucol_openRules(rule, rlen, UNORM_NFD, UCOL_TERTIARY,NULL, &status);
coll2 = ucol_openRules(rule, rlen, UCOL_ON, UCOL_TERTIARY,NULL, &status);
if (U_FAILURE(status)) {
log_err("Collator creation failed %s\n", testrules[i]);
return;
@ -2517,7 +2511,7 @@ static void TestExpansion() {
int j = 0;
log_verbose("Rule %s for testing\n", testrules[i]);
rlen = u_unescape(testrules[i], rule, 32);
coll = ucol_openRules(rule, rlen, UNORM_NFD, UCOL_TERTIARY,NULL, &status);
coll = ucol_openRules(rule, rlen, UCOL_ON, UCOL_TERTIARY,NULL, &status);
if (U_FAILURE(status)) {
log_err("Collator creation failed %s\n", testrules[i]);
return;
@ -2936,4 +2930,3 @@ void addMiscCollTest(TestNode** root)
/*addTest(root, &PrintMarkDavis, "tscoll/cmsccoll/PrintMarkDavis");*/ /* this test doesn't test - just prints sortkeys */
/*addTest(root, &TestGetCaseBit, "tscoll/cmsccoll/TestGetCaseBit");*/ /*this one requires internal things to be exported */
}

View file

@ -95,8 +95,7 @@ TestDeprecatedCollationAPI(void)
u_uastrcpy(temp, " & Z < ABC < Q < B");
coll = ucol_openRules(temp, u_strlen(temp), UCOL_NO_NORMALIZATION,
UCOL_DEFAULT_STRENGTH, &status);
coll = ucol_openRules(temp, u_strlen(temp), UCOL_OFF, UCOL_DEFAULT_STRENGTH, &status);
if(U_SUCCESS(status)) {
size = sizeof(cnt1)/sizeof(cnt1[0]);
@ -119,8 +118,7 @@ TestDeprecatedCollationAPI(void)
u_uastrcpy(temp, " & Z < DAVIS < MARK <DAV");
coll = ucol_openRules(temp, u_strlen(temp), UCOL_NO_NORMALIZATION,
UCOL_DEFAULT_STRENGTH, &status);
coll = ucol_openRules(temp, u_strlen(temp), UCOL_OFF, UCOL_DEFAULT_STRENGTH, &status);
if(U_SUCCESS(status)) {
size = sizeof(cnt2)/sizeof(cnt2[0]);