]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | |
2 | /******************************************************************** | |
3 | * COPYRIGHT: | |
729e4ab9 | 4 | * Copyright (c) 1997-2009, International Business Machines Corporation and |
b75a7d8f A |
5 | * 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 _ESCOLL | |
29 | #include "escoll.h" | |
30 | #endif | |
31 | ||
32 | #include "sfwdchit.h" | |
33 | ||
34 | CollationSpanishTest::CollationSpanishTest() | |
35 | : myCollation(0) | |
36 | { | |
37 | UErrorCode status = U_ZERO_ERROR; | |
38 | myCollation = Collator::createInstance(Locale("es", "ES", ""),status); | |
39 | } | |
40 | ||
41 | CollationSpanishTest::~CollationSpanishTest() | |
42 | { | |
43 | delete myCollation; | |
44 | } | |
45 | ||
46 | const UChar CollationSpanishTest::testSourceCases[][CollationSpanishTest::MAX_TOKEN_LEN] = { | |
47 | {0x61, 0x6c, 0x69, 0x61, 0x73, 0}, | |
48 | {0x45, 0x6c, 0x6c, 0x69, 0x6f, 0x74, 0}, | |
49 | {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0}, | |
50 | {0x61, 0x63, 0x48, 0x63, 0}, | |
51 | {0x61, 0x63, 0x63, 0}, | |
52 | {0x61, 0x6c, 0x69, 0x61, 0x73, 0}, | |
53 | {0x61, 0x63, 0x48, 0x63, 0}, | |
54 | {0x61, 0x63, 0x63, 0}, | |
55 | {0x48, 0x65, 0x6c, 0x6c, 0x6f, 0}, | |
56 | }; | |
57 | ||
58 | const UChar CollationSpanishTest::testTargetCases[][CollationSpanishTest::MAX_TOKEN_LEN] = { | |
59 | {0x61, 0x6c, 0x6c, 0x69, 0x61, 0x73, 0}, | |
60 | {0x45, 0x6d, 0x69, 0x6f, 0x74, 0}, | |
61 | {0x68, 0x65, 0x6c, 0x6c, 0x4f, 0}, | |
62 | {0x61, 0x43, 0x48, 0x63, 0}, | |
63 | {0x61, 0x43, 0x48, 0x63, 0}, | |
64 | {0x61, 0x6c, 0x6c, 0x69, 0x61, 0x73, 0}, | |
65 | {0x61, 0x43, 0x48, 0x63, 0}, | |
66 | {0x61, 0x43, 0x48, 0x63, 0}, | |
67 | {0x68, 0x65, 0x6c, 0x6c, 0x4f, 0}, | |
68 | }; | |
69 | ||
70 | const Collator::EComparisonResult CollationSpanishTest::results[] = { | |
71 | Collator::LESS, | |
72 | Collator::LESS, | |
73 | Collator::GREATER, | |
74 | Collator::LESS, | |
75 | Collator::LESS, | |
76 | // test primary > 5 | |
77 | Collator::LESS, | |
78 | Collator::EQUAL, | |
79 | Collator::LESS, | |
80 | Collator::EQUAL | |
81 | }; | |
82 | ||
83 | void CollationSpanishTest::TestTertiary(/* char* par */) | |
84 | { | |
85 | int32_t i = 0; | |
86 | myCollation->setStrength(Collator::TERTIARY); | |
87 | for (i = 0; i < 5 ; i++) { | |
88 | doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]); | |
89 | } | |
90 | } | |
91 | void CollationSpanishTest::TestPrimary(/* char* par */) | |
92 | { | |
93 | int32_t i; | |
94 | myCollation->setStrength(Collator::PRIMARY); | |
95 | for (i = 5; i < 9; i++) { | |
96 | doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]); | |
97 | } | |
98 | } | |
99 | ||
100 | void CollationSpanishTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par */) | |
101 | { | |
102 | if (exec) logln("TestSuite CollationSpanishTest: "); | |
103 | ||
104 | if((!myCollation) && exec) { | |
729e4ab9 | 105 | dataerrln(__FILE__ " cannot test - failed to create collator."); |
73c04bcf | 106 | name = "some test"; |
b75a7d8f A |
107 | return; |
108 | } | |
109 | switch (index) { | |
110 | case 0: name = "TestPrimary"; if (exec) TestPrimary(/* par */); break; | |
111 | case 1: name = "TestTertiary"; if (exec) TestTertiary(/* par */); break; | |
112 | default: name = ""; break; | |
113 | } | |
114 | } | |
115 | ||
116 | #endif /* #if !UCONFIG_NO_COLLATION */ |