ICU-1855 Tests for suppressing contractions and UCA copying

X-SVN-Rev: 10090
This commit is contained in:
Vladimir Weinstein 2002-10-30 05:44:54 +00:00
parent d66615d32b
commit b87db9ac1b
2 changed files with 63 additions and 9 deletions

View File

@ -2551,6 +2551,7 @@ static void TestCyrillicTailoring(void) {
"\\u0410\\u0306a",
"\\u04d0A"
};
/* Russian overrides contractions, so this test is not valid anymore */
/*genericLocaleStarter("ru", test, 3);*/
@ -2563,6 +2564,23 @@ static void TestCyrillicTailoring(void) {
genericRulesStarter("&Z < \\u0410 < \\u0410\\u0301", test, 3);
}
static void TestSuppressContractions(void) {
static const char *testNoCont2[] = {
"\\u0410\\u0302a",
"\\u0410\\u0306b",
"\\u0410c"
};
static const char *testNoCont[] = {
"a\\u0410",
"A\\u0410\\u0306",
"\\uFF21\\u0410\\u0302"
};
genericRulesStarter("[suppressContractions [\\u0400-\\u047f]]", testNoCont, 3);
genericRulesStarter("[suppressContractions [\\u0400-\\u047f]]", testNoCont2, 3);
}
static void TestContraction(void) {
const static char *testrules[] = {
"&A = AB / B",
@ -3625,15 +3643,14 @@ static void TestRuleOptions(void) {
static void TestUnicodeSetRules(void) {
static struct {
const char *rules;
const char *data[50];
const uint32_t len;
} tests[] = {
/* - all befores here amount to zero */
{ "[optimize [\\uAC00-\\uD7FF]]&a = a",
{ "a", "b"}, 2} /* you cannot go before first tertiary ignorable */
{ "[optimize [\\uAC00-\\uD7FF]]",
{ "a", "b"}, 2}
};
uint32_t i;
@ -3641,9 +3658,10 @@ static void TestUnicodeSetRules(void) {
for(i = 0; i<(sizeof(tests)/sizeof(tests[0])); i++) {
genericRulesStarter(tests[i].rules, tests[i].data, tests[i].len);
}
}
#define TEST(x) addTest(root, &x, "tscoll/cmsccoll/" # x)
void addMiscCollTest(TestNode** root)
{
addTest(root, &TestRuleOptions, "tscoll/cmsccoll/TestRuleOptions");
@ -3688,7 +3706,8 @@ void addMiscCollTest(TestNode** root)
addTest(root, &TestExpansion, "tscoll/cmsccoll/TestExpansion");
/*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 */
addTest(root, &TestUnicodeSetRules, "tscoll/cmsccoll/TestUnicodeSetRules");
TEST(TestUnicodeSetRules);
TEST(TestSuppressContractions);
}
#endif /* #if !UCONFIG_NO_COLLATION */

View File

@ -1,4 +1,4 @@
/*
/*
*******************************************************************************
* Copyright (C) 2002, International Business Machines Corporation and *
* others. All Rights Reserved. *
@ -27,7 +27,7 @@ public class CollationMiscTest extends TestFmwk{
public static void main(String[] args) throws Exception {
new CollationMiscTest().run(args);
// new CollationMiscTest().TestLocaleRuleBasedCollators();
// new CollationMiscTest().TestLocaleRuleBasedCollators();
}
public void TestRuleOptions() {
@ -622,7 +622,7 @@ public class CollationMiscTest extends TestFmwk{
"\u0410\u0306a",
"\u04d0A"
};
genericLocaleStarter(new Locale("ru", ""), test);
genericLocaleStarter(new Locale("en", ""), test);
genericRulesStarter("&\u0410 = \u0410", test);
genericRulesStarter("&Z < \u0410", test);
genericRulesStarter("&\u0410 = \u0410 < \u04d0", test);
@ -630,7 +630,23 @@ public class CollationMiscTest extends TestFmwk{
genericRulesStarter("&\u0410 = \u0410 < \u0410\u0301", test);
genericRulesStarter("&Z < \u0410 < \u0410\u0301", test);
}
public void TestSuppressContractions() {
String testNoCont2[] = {
"\u0410\u0302a",
"\u0410\u0306b",
"\u0410c"
};
String testNoCont[] = {
"a\u0410",
"A\u0410\u0306",
"\uFF21\u0410\u0302"
};
genericRulesStarter("[suppressContractions [\u0400-\u047f]]", testNoCont);
genericRulesStarter("[suppressContractions [\u0400-\u047f]]", testNoCont2);
}
public void TestCase() {
String gRules = "\u0026\u0030\u003C\u0031\u002C\u2460\u003C\u0061\u002C\u0041";
String[] testCase = {
@ -1607,4 +1623,23 @@ public class CollationMiscTest extends TestFmwk{
}
}
}
public void TestOptimize() {
/* this is not really a test - just trying out
* whether copying of UCA contents will fail
* Cannot really test, since the functionality
* remains the same.
*/
String rules[] = {
"[optimize [\\uAC00-\\uD7FF]]"
};
String data[][] = {
{ "a", "b"}
};
int i = 0;
for(i = 0; i<rules.length; i++) {
genericRulesStarter(rules[i], data[i]);
}
}
}