]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
b75a7d8f A |
3 | |
4 | /******************************************************************** | |
5 | * COPYRIGHT: | |
729e4ab9 | 6 | * Copyright (c) 1997-2009, International Business Machines Corporation and |
b75a7d8f A |
7 | * others. All Rights Reserved. |
8 | ********************************************************************/ | |
9 | ||
10 | #include "unicode/utypes.h" | |
11 | ||
12 | #if !UCONFIG_NO_COLLATION | |
13 | ||
14 | #ifndef _COLL | |
15 | #include "unicode/coll.h" | |
16 | #endif | |
17 | ||
18 | #ifndef _TBLCOLL | |
19 | #include "unicode/tblcoll.h" | |
20 | #endif | |
21 | ||
22 | #ifndef _UNISTR | |
23 | #include "unicode/unistr.h" | |
24 | #endif | |
25 | ||
26 | #ifndef _SORTKEY | |
27 | #include "unicode/sortkey.h" | |
28 | #endif | |
29 | ||
30 | #ifndef _ESCOLL | |
31 | #include "escoll.h" | |
32 | #endif | |
33 | ||
34 | #include "sfwdchit.h" | |
35 | ||
36 | CollationSpanishTest::CollationSpanishTest() | |
37 | : myCollation(0) | |
38 | { | |
39 | UErrorCode status = U_ZERO_ERROR; | |
40 | myCollation = Collator::createInstance(Locale("es", "ES", ""),status); | |
41 | } | |
42 | ||
43 | CollationSpanishTest::~CollationSpanishTest() | |
44 | { | |
45 | delete myCollation; | |
46 | } | |
47 | ||
48 | const UChar CollationSpanishTest::testSourceCases[][CollationSpanishTest::MAX_TOKEN_LEN] = { | |
49 | {0x61, 0x6c, 0x69, 0x61, 0x73, 0}, | |
50 | {0x45, 0x6c, 0x6c, 0x69, 0x6f, 0x74, 0}, | |
51 | {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0}, | |
52 | {0x61, 0x63, 0x48, 0x63, 0}, | |
53 | {0x61, 0x63, 0x63, 0}, | |
54 | {0x61, 0x6c, 0x69, 0x61, 0x73, 0}, | |
55 | {0x61, 0x63, 0x48, 0x63, 0}, | |
56 | {0x61, 0x63, 0x63, 0}, | |
57 | {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0}, | |
58 | }; | |
59 | ||
60 | const UChar CollationSpanishTest::testTargetCases[][CollationSpanishTest::MAX_TOKEN_LEN] = { | |
61 | {0x61, 0x6c, 0x6c, 0x69, 0x61, 0x73, 0}, | |
62 | {0x45, 0x6d, 0x69, 0x6f, 0x74, 0}, | |
63 | {0x68, 0x65, 0x6c, 0x6c, 0x4f, 0}, | |
64 | {0x61, 0x43, 0x48, 0x63, 0}, | |
65 | {0x61, 0x43, 0x48, 0x63, 0}, | |
66 | {0x61, 0x6c, 0x6c, 0x69, 0x61, 0x73, 0}, | |
67 | {0x61, 0x43, 0x48, 0x63, 0}, | |
68 | {0x61, 0x43, 0x48, 0x63, 0}, | |
69 | {0x68, 0x65, 0x6c, 0x6c, 0x4f, 0}, | |
70 | }; | |
71 | ||
72 | const Collator::EComparisonResult CollationSpanishTest::results[] = { | |
73 | Collator::LESS, | |
74 | Collator::LESS, | |
75 | Collator::GREATER, | |
76 | Collator::LESS, | |
77 | Collator::LESS, | |
78 | // test primary > 5 | |
79 | Collator::LESS, | |
80 | Collator::EQUAL, | |
81 | Collator::LESS, | |
82 | Collator::EQUAL | |
83 | }; | |
84 | ||
85 | void CollationSpanishTest::TestTertiary(/* char* par */) | |
86 | { | |
87 | int32_t i = 0; | |
88 | myCollation->setStrength(Collator::TERTIARY); | |
89 | for (i = 0; i < 5 ; i++) { | |
90 | doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]); | |
91 | } | |
92 | } | |
93 | void CollationSpanishTest::TestPrimary(/* char* par */) | |
94 | { | |
95 | int32_t i; | |
96 | myCollation->setStrength(Collator::PRIMARY); | |
97 | for (i = 5; i < 9; i++) { | |
98 | doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]); | |
99 | } | |
100 | } | |
101 | ||
102 | void CollationSpanishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par */) | |
103 | { | |
104 | if (exec) logln("TestSuite CollationSpanishTest: "); | |
105 | ||
106 | if((!myCollation) && exec) { | |
729e4ab9 | 107 | dataerrln(__FILE__ " cannot test - failed to create collator."); |
73c04bcf | 108 | name = "some test"; |
b75a7d8f A |
109 | return; |
110 | } | |
111 | switch (index) { | |
112 | case 0: name = "TestPrimary"; if (exec) TestPrimary(/* par */); break; | |
113 | case 1: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break; | |
114 | default: name = ""; break; | |
115 | } | |
116 | } | |
117 | ||
118 | #endif /* #if !UCONFIG_NO_COLLATION */ |