]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/intltest/ficoll.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / test / intltest / ficoll.cpp
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
b75a7d8f 3/********************************************************************
b331163b 4 * Copyright (c) 1997-2009,2014, International Business Machines
46f4442e 5 * Corporation and others. All Rights Reserved.
b75a7d8f
A
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
34CollationFinnishTest::CollationFinnishTest()
35: myCollation(0)
36{
37 UErrorCode status = U_ZERO_ERROR;
46f4442e 38 myCollation = Collator::createInstance(Locale("fi", "FI", "", "collation=standard"),status);
b75a7d8f
A
39}
40
41CollationFinnishTest::~CollationFinnishTest()
42{
43 delete myCollation;
44}
45
46const UChar CollationFinnishTest::testSourceCases[][CollationFinnishTest::MAX_TOKEN_LEN] = {
b331163b
A
47 {0x77, 0x61, 0x74, 0}, // "wat"
48 {0x76, 0x61, 0x74, 0}, // "vat"
b75a7d8f
A
49 {0x61, 0x00FC, 0x62, 0x65, 0x63, 0x6b, 0},
50 {0x4c, 0x00E5, 0x76, 0x69, 0},
b331163b 51 {0x77, 0x61, 0x74, 0} // "wat"
b75a7d8f
A
52};
53
54const UChar CollationFinnishTest::testTargetCases[][CollationFinnishTest::MAX_TOKEN_LEN] = {
b331163b 55 {0x76, 0x61, 0x74, 0}, // "vat"
b75a7d8f
A
56 {0x77, 0x61, 0x79, 0},
57 {0x61, 0x78, 0x62, 0x65, 0x63, 0x6b, 0},
58 {0x4c, 0x00E4, 0x77, 0x65, 0},
b331163b 59 {0x76, 0x61, 0x74, 0} // "vat"
b75a7d8f
A
60};
61
62const Collator::EComparisonResult CollationFinnishTest::results[] = {
63 Collator::GREATER,
64 Collator::LESS,
65 Collator::GREATER,
66 Collator::LESS,
67 // test primary > 4
b331163b 68 Collator::GREATER, // v < w per cldrbug 6615
b75a7d8f
A
69};
70
71void 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}
79void 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
88void CollationFinnishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
89{
90 if (exec) logln("TestSuite CollationFinnishTest: ");
91
92 if((!myCollation) && exec) {
729e4ab9 93 dataerrln(__FILE__ " cannot test - failed to create collator.");
73c04bcf 94 name = "some test";
b75a7d8f
A
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 */