]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/ficoll.cpp
ICU-64243.0.1.tar.gz
[apple/icu.git] / icuSources / test / intltest / ficoll.cpp
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 ********************************************************************/
7
8 #include "unicode/utypes.h"
9
10 #if !UCONFIG_NO_COLLATION
11
12 #ifndef _COLL
13 #include "unicode/coll.h"
14 #endif
15
16 #ifndef _TBLCOLL
17 #include "unicode/tblcoll.h"
18 #endif
19
20 #ifndef _UNISTR
21 #include "unicode/unistr.h"
22 #endif
23
24 #ifndef _SORTKEY
25 #include "unicode/sortkey.h"
26 #endif
27
28 #ifndef _FICOLL
29 #include "ficoll.h"
30 #endif
31
32 #include "sfwdchit.h"
33
34 CollationFinnishTest::CollationFinnishTest()
35 : myCollation(0)
36 {
37 UErrorCode status = U_ZERO_ERROR;
38 myCollation = Collator::createInstance(Locale("fi", "FI", "", "collation=standard"),status);
39 }
40
41 CollationFinnishTest::~CollationFinnishTest()
42 {
43 delete myCollation;
44 }
45
46 const UChar CollationFinnishTest::testSourceCases[][CollationFinnishTest::MAX_TOKEN_LEN] = {
47 {0x77, 0x61, 0x74, 0}, // "wat"
48 {0x76, 0x61, 0x74, 0}, // "vat"
49 {0x61, 0x00FC, 0x62, 0x65, 0x63, 0x6b, 0},
50 {0x4c, 0x00E5, 0x76, 0x69, 0},
51 {0x77, 0x61, 0x74, 0} // "wat"
52 };
53
54 const UChar CollationFinnishTest::testTargetCases[][CollationFinnishTest::MAX_TOKEN_LEN] = {
55 {0x76, 0x61, 0x74, 0}, // "vat"
56 {0x77, 0x61, 0x79, 0},
57 {0x61, 0x78, 0x62, 0x65, 0x63, 0x6b, 0},
58 {0x4c, 0x00E4, 0x77, 0x65, 0},
59 {0x76, 0x61, 0x74, 0} // "vat"
60 };
61
62 const Collator::EComparisonResult CollationFinnishTest::results[] = {
63 Collator::GREATER,
64 Collator::LESS,
65 Collator::GREATER,
66 Collator::LESS,
67 // test primary > 4
68 Collator::GREATER, // v < w per cldrbug 6615
69 };
70
71 void CollationFinnishTest::TestTertiary(/* char* par */)
72 {
73 int32_t i = 0;
74 myCollation->setStrength(Collator::TERTIARY);
75 for (i = 0; i < 4 ; i++) {
76 doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
77 }
78 }
79 void CollationFinnishTest::TestPrimary(/* char* par */)
80 {
81 int32_t i;
82 myCollation->setStrength(Collator::PRIMARY);
83 for (i = 4; i < 5; i++) {
84 doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
85 }
86 }
87
88 void CollationFinnishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
89 {
90 if (exec) logln("TestSuite CollationFinnishTest: ");
91
92 if((!myCollation) && exec) {
93 dataerrln(__FILE__ " cannot test - failed to create collator.");
94 name = "some test";
95 return;
96 }
97 switch (index) {
98 case 0: name = "TestPrimary"; if (exec) TestPrimary(/* par */); break;
99 case 1: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break;
100 default: name = ""; break;
101 }
102 }
103
104 #endif /* #if !UCONFIG_NO_COLLATION */