]>
Commit | Line | Data |
---|---|---|
b75a7d8f | 1 | /******************************************************************** |
729e4ab9 | 2 | * Copyright (c) 1997-2009, International Business Machines |
46f4442e A |
3 | * Corporation and others. All Rights Reserved. |
4 | ******************************************************************** | |
5 | * | |
6 | * File CFINTST.C | |
7 | * | |
8 | * Modification History: | |
9 | * Name Description | |
10 | * Madhu Katragadda Ported for C API | |
11 | ******************************************************************** | |
12 | */ | |
13 | ||
b75a7d8f A |
14 | /** |
15 | * CollationFinnishTest is a third level test class. This tests the locale | |
16 | * specific primary, secondary and tertiary rules. For example, the ignorable | |
17 | * character '-' in string "black-bird". The en_US locale uses the default | |
18 | * collation rules as its sorting sequence. | |
19 | */ | |
20 | ||
21 | #include <stdlib.h> | |
22 | ||
23 | #include "unicode/utypes.h" | |
24 | ||
25 | #if !UCONFIG_NO_COLLATION | |
26 | ||
27 | #include "unicode/ucol.h" | |
28 | #include "unicode/uloc.h" | |
29 | #include "cintltst.h" | |
30 | #include "ccolltst.h" | |
31 | #include "callcoll.h" | |
32 | #include "cfintst.h" | |
33 | #include "unicode/ustring.h" | |
34 | #include "string.h" | |
35 | ||
36 | static UCollator *myCollation; | |
37 | const static UChar testSourceCases[][MAX_TOKEN_LEN] = { | |
38 | {0x0077/*'w'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000}, | |
39 | {0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000}, | |
40 | {0x0061/*'a'*/, 0x00FC, 0x0062/*'b'*/, 0x0065/*'e'*/, 0x0063/*'c'*/, 0x006b/*'k'*/, 0x0000}, | |
41 | {0x004c/*'L'*/, 0x00E5, 0x0076/*'v'*/, 0x0069/*'i'*/, 0x0000}, | |
42 | {0x0077/*'w'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000} | |
43 | }; | |
44 | ||
45 | const static UChar testTargetCases[][MAX_TOKEN_LEN] = { | |
46 | {0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000}, | |
47 | {0x0077/*'w'*/, 0x0061/*'a'*/, 0x0079/*'y'*/, 0x0000}, | |
48 | {0x0061/*'a'*/, 0x0078/*'x'*/, 0x0062/*'b'*/, 0x0065/*'e'*/, 0x0063/*'c'*/, 0x006b/*'k'*/, 0x0000}, | |
49 | {0x004c/*'L'*/, 0x00E4, 0x0077/*'w'*/, 0x0065/*'e'*/, 0x0000}, | |
50 | {0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000} | |
51 | }; | |
52 | ||
53 | const static UCollationResult results[] = { | |
54 | UCOL_GREATER, | |
55 | UCOL_LESS, | |
56 | UCOL_GREATER, | |
57 | UCOL_LESS, | |
58 | /* test primary > 4*/ | |
59 | UCOL_EQUAL | |
60 | }; | |
61 | ||
62 | ||
63 | ||
64 | void addFinnishCollTest(TestNode** root) | |
65 | { | |
66 | ||
67 | ||
68 | addTest(root, &TestPrimary, "tscoll/cficoll/TestPrimary"); | |
69 | addTest(root, &TestTertiary, "tscoll/cficoll/TestTertiary"); | |
70 | ||
71 | ||
72 | ||
73 | } | |
74 | ||
75 | ||
76 | static void TestTertiary( ) | |
77 | { | |
78 | ||
79 | int32_t i; | |
80 | UErrorCode status = U_ZERO_ERROR; | |
46f4442e | 81 | myCollation = ucol_open("fi_FI@collation=standard", &status); |
b75a7d8f | 82 | if(U_FAILURE(status)){ |
729e4ab9 | 83 | log_err_status(status, "ERROR: in creation of rule based collator: %s\n", myErrorName(status)); |
b75a7d8f A |
84 | } |
85 | log_verbose("Testing Finnish Collation with Tertiary strength\n"); | |
86 | ucol_setStrength(myCollation, UCOL_TERTIARY); | |
87 | for (i = 0; i < 4 ; i++) | |
88 | { | |
89 | doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]); | |
90 | } | |
91 | ucol_close(myCollation); | |
92 | } | |
93 | ||
94 | static void TestPrimary() | |
95 | { | |
96 | ||
97 | int32_t i; | |
98 | UErrorCode status = U_ZERO_ERROR; | |
46f4442e | 99 | myCollation = ucol_open("fi_FI@collation=standard", &status); |
b75a7d8f | 100 | if(U_FAILURE(status)){ |
729e4ab9 | 101 | log_err_status(status, "ERROR: in creation of rule based collator: %s\n", myErrorName(status)); |
b75a7d8f A |
102 | } |
103 | log_verbose("Testing Finnish Collation with Tertiary strength\n"); | |
104 | ucol_setStrength(myCollation, UCOL_PRIMARY); | |
374ca955 | 105 | for (i = 4; i < 5; i++) |
b75a7d8f A |
106 | { |
107 | doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]); | |
108 | } | |
109 | ucol_close(myCollation); | |
110 | } | |
111 | ||
112 | #endif /* #if !UCONFIG_NO_COLLATION */ |