1
/********************************************************************
3
* Copyright (c) 1997-2001, International Business Machines Corporation and
4
* others. All Rights Reserved.
5
********************************************************************/
6
/********************************************************************************
10
* Modification History:
12
* Madhu Katragadda Ported for C API
13
*********************************************************************************/
15
* CollationTurkishTest 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
{0x0073/*'s'*/, 0x0327, 0x0000},
39
{0x0076/*'v'*/, 0x00E4, 0x0074/*'t'*/, 0x0000},
40
{0x006f/*'o'*/, 0x006c/*'l'*/, 0x0064/*'d'*/, 0x0000},
41
{0x00FC, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064/*'d'*/, 0x0000},
42
{0x0068/*'h'*/, 0x011E, 0x0061/*'a'*/, 0x006c/*'l'*/, 0x0074/*'t'*/, 0x0000},
43
{0x0073/*'s'*/, 0x0074/*'t'*/, 0x0072/*'r'*/, 0x0065/*'e'*/, 0x0073/*'s'*/, 0x015E, 0x0000},
44
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0131, 0x0064/*'d'*/, 0x0000},
45
{0x0069/*'i'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
46
{0x00FC, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
47
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0131, 0x0064 /*d'*/, 0x0000},
48
{0x0069/*'i'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
51
const static UChar testTargetCases[][MAX_TOKEN_LEN] = {
52
{0x0075/*'u'*/, 0x0308, 0x0000},
53
{0x0076/*'v'*/, 0x0062/*'b'*/, 0x0074/*'t'*/, 0x0000},
54
{0x00D6, 0x0061/*'a'*/, 0x0079/*'y'*/, 0x0000},
55
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
56
{0x0068/*'h'*/, 0x0061/*'a'*/, 0x006c/*'l'*/, 0x0074/*'t'*/, 0x0000},
57
{0x015E, 0x0074/*'t'*/, 0x0072/*'r'*/, 0x0065/*'e'*/, 0x015E, 0x0073/*'s'*/, 0x0000},
58
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
59
{0x0049/*'I'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
60
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
61
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
62
{0x0049/*'I'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
65
const static UCollationResult results[] = {
74
/* test priamry > 8 */
76
UCOL_LESS, /*Turkish translator made a primary differnce between dotted and dotless I */
82
void addTurkishCollTest(TestNode** root)
85
addTest(root, &TestPrimary, "tscoll/cturtst/TestPrimary");
86
addTest(root, &TestTertiary, "tscoll/cturtst/TestTertiary");
91
static void TestTertiary( )
96
UErrorCode status = U_ZERO_ERROR;
97
myCollation = ucol_open("tr", &status);
98
if(U_FAILURE(status)){
99
log_err("ERROR: in creation of rule based collator: %s\n", myErrorName(status));
102
log_verbose("Testing Turkish Collation with Tertiary strength\n");
103
ucol_setStrength(myCollation, UCOL_TERTIARY);
104
for (i = 0; i < 8 ; i++)
106
doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
108
ucol_close(myCollation);
111
static void TestPrimary()
116
UErrorCode status = U_ZERO_ERROR;
117
myCollation = ucol_open("tr", &status);
118
if(U_FAILURE(status)){
119
log_err("ERROR: in creation of rule based collator: %s\n", myErrorName(status));
122
log_verbose("Testing Turkish Collation with Primary strength\n");
123
ucol_setStrength(myCollation, UCOL_PRIMARY);
124
for (i = 8; i < 11; i++)
126
doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
128
ucol_close(myCollation);
131
#endif /* #if !UCONFIG_NO_COLLATION */