• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /***********************************************************************
4  * COPYRIGHT:
5  * Copyright (c) 1997-2014, International Business Machines Corporation
6  * and others. All Rights Reserved.
7  ***********************************************************************/
8 
9 /**
10  * CollationAPITest is a third level test class. This test performs API
11  * related tests for the Collation framework.
12  */
13 
14 #ifndef _APICOLL
15 #define _APICOLL
16 
17 #include "unicode/utypes.h"
18 
19 #if !UCONFIG_NO_COLLATION
20 
21 #include "unicode/tblcoll.h"
22 #include "tscoll.h"
23 
24 class CollationAPITest: public IntlTestCollator {
25 public:
26     void runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par = NULL */) override;
27     void doAssert(UBool condition, const char *message);
28 
29     /**
30      * This tests the properties of a collator object.
31      * - constructor/destructor
32      * - factory method createInstance
33      * - compare and getCollationKey
34      * - get/set decomposition mode and comparison level
35      * - displayable name in the desired locale
36      */
37     void TestProperty(/* char* par */);
38     void TestKeywordValues();
39 
40     /**
41     * This tests the RuleBasedCollator
42     * - constructor/destructor
43     * - getRules
44     */
45     void TestRuleBasedColl(/* char* par */);
46 
47     /**
48     * This tests the RuleBasedCollator
49     * - getRules
50     */
51     void TestRules(/* char* par */);
52 
53     /**
54     * Tests decomposition setting
55     */
56     void TestDecomposition();
57 
58     /**
59     * SafeClone test
60     */
61     void TestSafeClone();
62 
63     /**
64      * This tests the properties of a rule based collator object.
65      * - constructor/destructor
66      * - == and != operators
67      * - clone and copy
68      * - collation rules access
69      */
70     void TestOperators(/* char* par */);
71 
72     /**
73      * This tests the duplication of a collator object.
74      */
75     void TestDuplicate(/* char* par */);
76 
77     /**
78      * This tests the comparison convenience methods of a collator object.
79      * - greater than
80      * - greater than or equal to
81      * - equal to
82      */
83     void TestCompare(/* char* par */);
84 
85     /**
86      * This tests the hashCode method of a collator object.
87      */
88     void TestHashCode(/* char* par */);
89 
90     /**
91      * This tests the collation key related APIs.
92      * - constructor/destructor
93      * - Collator::getCollationKey
94      * - == and != operators
95      * - comparison between collation keys
96      * - creating collation key with a byte array and vice versa
97      */
98     void TestCollationKey(/* char* par */);
99 
100     /**
101      * This tests the CollationElementIterator related APIs.
102      * - creation of a CollationElementIterator object
103      * - == and != operators
104      * - iterating forward
105      * - resetting the iterator index
106      * - requesting the order properties(primary, secondary or tertiary)
107      */
108     void TestElemIter(/* char* par */);
109 
110     /**
111      * This tests the list the all available locales.
112      */
113     void TestGetAll(/* char* par */);
114 
115     /**
116      * This tests the sort keys generated by collator
117      */
118     void TestSortKey();
119     void TestSortKeyOverflow();
120 
121     /**
122      * This tests getMaxExpansion
123      */
124     void TestMaxExpansion();
125 
126     /**
127     * Tests the retrieval of names given a locale
128     */
129     void TestDisplayName();
130 
131     /**
132     * Tests the collator attributes
133     */
134     void TestAttribute();
135 
136     /**
137     * Tests the setters and getters of variable top
138     */
139     void TestVariableTopSetting();
140     void TestMaxVariable();
141 
142     /**
143     * Tests GetLocale for a Collator
144     */
145     void TestGetLocale();
146 
147     /**
148     * Tests bounds API
149     */
150     void TestBounds();
151 
152     /**
153     * Tests getTailoredSet API
154     */
155     void TestGetTailoredSet();
156 
157     /**
158     * Tests the subclassability
159     */
160     void TestSubclass();
161 
162     /**
163     * Tests the dynamic and static ids of collation classes
164     */
165     void TestUClassID();
166 
167     /**
168     * Test NULL
169     */
170     void TestNULLCharTailoring();
171 
172     void TestClone();
173     void TestCloneBinary();
174     void TestIterNumeric();
175     void TestBadKeywords();
176     void TestGapTooSmall();
177 
178 private:
179     // If this is too small for the test data, just increase it.
180     // Just don't make it too large, otherwise the executable will get too big
181     enum EToken_Len { MAX_TOKEN_LEN = 16 };
182 
183     void dump(UnicodeString msg, RuleBasedCollator* c, UErrorCode& status);
184 
185 };
186 
187 #endif /* #if !UCONFIG_NO_COLLATION */
188 
189 #endif
190