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
* 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.
22
#include "unicode/utypes.h"
23
#include "unicode/ucol.h"
24
#include "unicode/uloc.h"
29
#include "unicode/ustring.h"
32
static UCollator *myCollation;
33
const static UChar testSourceCases[][MAX_TOKEN_LEN] = {
34
{0x0077/*'w'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000},
35
{0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000},
36
{0x0061/*'a'*/, 0x00FC, 0x0062/*'b'*/, 0x0065/*'e'*/, 0x0063/*'c'*/, 0x006b/*'k'*/, 0x0000},
37
{0x004c/*'L'*/, 0x00E5, 0x0076/*'v'*/, 0x0069/*'i'*/, 0x0000},
38
{0x0077/*'w'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000}
41
const static UChar testTargetCases[][MAX_TOKEN_LEN] = {
42
{0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000},
43
{0x0077/*'w'*/, 0x0061/*'a'*/, 0x0079/*'y'*/, 0x0000},
44
{0x0061/*'a'*/, 0x0078/*'x'*/, 0x0062/*'b'*/, 0x0065/*'e'*/, 0x0063/*'c'*/, 0x006b/*'k'*/, 0x0000},
45
{0x004c/*'L'*/, 0x00E4, 0x0077/*'w'*/, 0x0065/*'e'*/, 0x0000},
46
{0x0076/*'v'*/, 0x0061/*'a'*/, 0x0074/*'t'*/, 0x0000}
49
const static UCollationResult results[] = {
60
void addFinnishCollTest(TestNode** root)
64
addTest(root, &TestPrimary, "tscoll/cficoll/TestPrimary");
65
addTest(root, &TestTertiary, "tscoll/cficoll/TestTertiary");
72
static void TestTertiary( )
76
UErrorCode status = U_ZERO_ERROR;
77
myCollation = ucol_open("fi_FI", &status);
78
if(U_FAILURE(status)){
79
log_err("ERROR: in creation of rule based collator: %s\n", myErrorName(status));
81
log_verbose("Testing Finnish Collation with Tertiary strength\n");
82
ucol_setStrength(myCollation, UCOL_TERTIARY);
83
for (i = 0; i < 4 ; i++)
85
doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
87
ucol_close(myCollation);
90
static void TestPrimary()
94
UErrorCode status = U_ZERO_ERROR;
95
myCollation = ucol_open("fi_FI", &status);
96
if(U_FAILURE(status)){
97
log_err("ERROR: in creation of rule based collator: %s\n", myErrorName(status));
99
log_verbose("Testing Finnish Collation with Tertiary strength\n");
100
ucol_setStrength(myCollation, UCOL_PRIMARY);
101
for (i = 4; i < 4; i++)
103
doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
105
ucol_close(myCollation);