]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/cintltst/cfintst.c
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
4 * Copyright (c) 1997-2009,2014, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 ********************************************************************
10 * Modification History:
12 * Madhu Katragadda Ported for C API
13 ********************************************************************
17 * CollationFinnishTest is a third level test class. This tests the locale
18 * specific primary, secondary and tertiary rules. For example, the ignorable
19 * character '-' in string "black-bird". The en_US locale uses the default
20 * collation rules as its sorting sequence.
25 #include "unicode/utypes.h"
27 #if !UCONFIG_NO_COLLATION
29 #include "unicode/ucol.h"
30 #include "unicode/uloc.h"
35 #include "unicode/ustring.h"
38 static UCollator
*myCollation
;
39 const static UChar testSourceCases
[][MAX_TOKEN_LEN
] = {
40 {0x0077/*'w'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000},
41 {0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000},
42 {0x0061/*'a'*/, 0x00FC, 0x0062/*'b'*/, 0x0065/*'e'*/, 0x0063/*'c'*/, 0x006b/*'k'*/, 0x0000},
43 {0x004c/*'L'*/, 0x00E5, 0x0076/*'v'*/, 0x0069/*'i'*/, 0x0000},
44 {0x0077/*'w'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000}
47 const static UChar testTargetCases
[][MAX_TOKEN_LEN
] = {
48 {0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000},
49 {0x0077/*'w'*/, 0x0061/*'a'*/, 0x0079/*'y'*/, 0x0000},
50 {0x0061/*'a'*/, 0x0078/*'x'*/, 0x0062/*'b'*/, 0x0065/*'e'*/, 0x0063/*'c'*/, 0x006b/*'k'*/, 0x0000},
51 {0x004c/*'L'*/, 0x00E4, 0x0077/*'w'*/, 0x0065/*'e'*/, 0x0000},
52 {0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000}
55 const static UCollationResult results
[] = {
61 UCOL_GREATER
/* v < w per cldrbug 6615 */
66 void addFinnishCollTest(TestNode
** root
)
70 addTest(root
, &TestPrimary
, "tscoll/cfintst/TestPrimary");
71 addTest(root
, &TestTertiary
, "tscoll/cfintst/TestTertiary");
78 static void TestTertiary( )
82 UErrorCode status
= U_ZERO_ERROR
;
83 myCollation
= ucol_open("fi_FI@collation=standard", &status
);
84 if(U_FAILURE(status
)){
85 log_err_status(status
, "ERROR: in creation of rule based collator: %s\n", myErrorName(status
));
87 log_verbose("Testing Finnish Collation with Tertiary strength\n");
88 ucol_setStrength(myCollation
, UCOL_TERTIARY
);
89 for (i
= 0; i
< 4 ; i
++)
91 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
93 ucol_close(myCollation
);
96 static void TestPrimary()
100 UErrorCode status
= U_ZERO_ERROR
;
101 myCollation
= ucol_open("fi_FI@collation=standard", &status
);
102 if(U_FAILURE(status
)){
103 log_err_status(status
, "ERROR: in creation of rule based collator: %s\n", myErrorName(status
));
105 log_verbose("Testing Finnish Collation with Primary strength\n");
106 ucol_setStrength(myCollation
, UCOL_PRIMARY
);
107 for (i
= 4; i
< 5; i
++)
109 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
111 ucol_close(myCollation
);
114 #endif /* #if !UCONFIG_NO_COLLATION */