]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/cintltst/cfintst.c
1 /********************************************************************
2 * Copyright (c) 1997-2009,2014, International Business Machines
3 * Corporation and others. All Rights Reserved.
4 ********************************************************************
8 * Modification History:
10 * Madhu Katragadda Ported for C API
11 ********************************************************************
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.
23 #include "unicode/utypes.h"
25 #if !UCONFIG_NO_COLLATION
27 #include "unicode/ucol.h"
28 #include "unicode/uloc.h"
33 #include "unicode/ustring.h"
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}
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}
53 const static UCollationResult results
[] = {
59 UCOL_GREATER
/* v < w per cldrbug 6615 */
64 void addFinnishCollTest(TestNode
** root
)
68 addTest(root
, &TestPrimary
, "tscoll/cfintst/TestPrimary");
69 addTest(root
, &TestTertiary
, "tscoll/cfintst/TestTertiary");
76 static void TestTertiary( )
80 UErrorCode status
= U_ZERO_ERROR
;
81 myCollation
= ucol_open("fi_FI@collation=standard", &status
);
82 if(U_FAILURE(status
)){
83 log_err_status(status
, "ERROR: in creation of rule based collator: %s\n", myErrorName(status
));
85 log_verbose("Testing Finnish Collation with Tertiary strength\n");
86 ucol_setStrength(myCollation
, UCOL_TERTIARY
);
87 for (i
= 0; i
< 4 ; i
++)
89 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
91 ucol_close(myCollation
);
94 static void TestPrimary()
98 UErrorCode status
= U_ZERO_ERROR
;
99 myCollation
= ucol_open("fi_FI@collation=standard", &status
);
100 if(U_FAILURE(status
)){
101 log_err_status(status
, "ERROR: in creation of rule based collator: %s\n", myErrorName(status
));
103 log_verbose("Testing Finnish Collation with Primary strength\n");
104 ucol_setStrength(myCollation
, UCOL_PRIMARY
);
105 for (i
= 4; i
< 5; i
++)
107 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
109 ucol_close(myCollation
);
112 #endif /* #if !UCONFIG_NO_COLLATION */