]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/cintltst/cturtst.c
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 1997-2009, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
8 /********************************************************************************
12 * Modification History:
14 * Madhu Katragadda Ported for C API
15 *********************************************************************************/
17 * CollationTurkishTest 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 {0x0073/*'s'*/, 0x0327, 0x0000},
41 {0x0076/*'v'*/, 0x00E4, 0x0074/*'t'*/, 0x0000},
42 {0x006f/*'o'*/, 0x006c/*'l'*/, 0x0064/*'d'*/, 0x0000},
43 {0x00FC, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064/*'d'*/, 0x0000},
44 {0x0068/*'h'*/, 0x011E, 0x0061/*'a'*/, 0x006c/*'l'*/, 0x0074/*'t'*/, 0x0000},
45 {0x0073/*'s'*/, 0x0074/*'t'*/, 0x0072/*'r'*/, 0x0065/*'e'*/, 0x0073/*'s'*/, 0x015E, 0x0000},
46 {0x0076/*'v'*/, 0x006f/*'o'*/, 0x0131, 0x0064/*'d'*/, 0x0000},
47 {0x0069/*'i'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
48 {0x00FC, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
49 {0x0076/*'v'*/, 0x006f/*'o'*/, 0x0131, 0x0064 /*d'*/, 0x0000},
50 {0x0069/*'i'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
53 const static UChar testTargetCases
[][MAX_TOKEN_LEN
] = {
54 {0x0075/*'u'*/, 0x0308, 0x0000},
55 {0x0076/*'v'*/, 0x0062/*'b'*/, 0x0074/*'t'*/, 0x0000},
56 {0x00D6, 0x0061/*'a'*/, 0x0079/*'y'*/, 0x0000},
57 {0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
58 {0x0068/*'h'*/, 0x0061/*'a'*/, 0x006c/*'l'*/, 0x0074/*'t'*/, 0x0000},
59 {0x015E, 0x0074/*'t'*/, 0x0072/*'r'*/, 0x0065/*'e'*/, 0x015E, 0x0073/*'s'*/, 0x0000},
60 {0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
61 {0x0049/*'I'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
62 {0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
63 {0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
64 {0x0049/*'I'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
67 const static UCollationResult results
[] = {
76 /* test priamry > 8 */
78 UCOL_LESS
, /*Turkish translator made a primary differnce between dotted and dotless I */
84 void addTurkishCollTest(TestNode
** root
)
87 addTest(root
, &TestPrimary
, "tscoll/cturtst/TestPrimary");
88 addTest(root
, &TestTertiary
, "tscoll/cturtst/TestTertiary");
93 static void TestTertiary( )
98 UErrorCode status
= U_ZERO_ERROR
;
99 myCollation
= ucol_open("tr", &status
);
100 if(U_FAILURE(status
)){
101 log_err_status(status
, "ERROR: in creation of rule based collator: %s\n", myErrorName(status
));
104 log_verbose("Testing Turkish Collation with Tertiary strength\n");
105 ucol_setStrength(myCollation
, UCOL_TERTIARY
);
106 for (i
= 0; i
< 8 ; i
++)
108 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
110 ucol_close(myCollation
);
113 static void TestPrimary()
118 UErrorCode status
= U_ZERO_ERROR
;
119 myCollation
= ucol_open("tr", &status
);
120 if(U_FAILURE(status
)){
121 log_err_status(status
, "ERROR: in creation of rule based collator: %s\n", myErrorName(status
));
124 log_verbose("Testing Turkish Collation with Primary strength\n");
125 ucol_setStrength(myCollation
, UCOL_PRIMARY
);
126 for (i
= 8; i
< 11; i
++)
128 doTest(myCollation
, testSourceCases
[i
], testTargetCases
[i
], results
[i
]);
130 ucol_close(myCollation
);
133 #endif /* #if !UCONFIG_NO_COLLATION */