1// Copyright (C) 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
24class CollationAPITest: public IntlTestCollator {
25public:
26    void runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par = NULL */);
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
39    /**
40    * This tests the RuleBasedCollator
41    * - constructor/destructor
42    * - getRules
43    */
44    void TestRuleBasedColl(/* char* par */);
45
46    /**
47    * This tests the RuleBasedCollator
48    * - getRules
49    */
50    void TestRules(/* char* par */);
51
52    /**
53    * Tests decomposition setting
54    */
55    void TestDecomposition();
56
57    /**
58    * SafeClone test
59    */
60    void TestSafeClone();
61
62    /**
63     * This tests the properties of a rule based collator object.
64     * - constructor/destructor
65     * - == and != operators
66     * - clone and copy
67     * - collation rules access
68     */
69    void TestOperators(/* char* par */);
70
71    /**
72     * This tests the duplication of a collator object.
73     */
74    void TestDuplicate(/* char* par */);
75
76    /**
77     * This tests the comparison convenience methods of a collator object.
78     * - greater than
79     * - greater than or equal to
80     * - equal to
81     */
82    void TestCompare(/* char* par */);
83
84    /**
85     * This tests the hashCode method of a collator object.
86     */
87    void TestHashCode(/* char* par */);
88
89    /**
90     * This tests the collation key related APIs.
91     * - constructor/destructor
92     * - Collator::getCollationKey
93     * - == and != operators
94     * - comparison between collation keys
95     * - creating collation key with a byte array and vice versa
96     */
97    void TestCollationKey(/* char* par */);
98
99    /**
100     * This tests the CollationElementIterator related APIs.
101     * - creation of a CollationElementIterator object
102     * - == and != operators
103     * - iterating forward
104     * - reseting the iterator index
105     * - requesting the order properties(primary, secondary or tertiary)
106     */
107    void TestElemIter(/* char* par */);
108
109    /**
110     * This tests the list the all available locales.
111     */
112    void TestGetAll(/* char* par */);
113
114    /**
115     * This tests the sort keys generated by collator
116     */
117    void TestSortKey();
118    void TestSortKeyOverflow();
119
120    /**
121     * This tests getMaxExpansion
122     */
123    void TestMaxExpansion();
124
125    /**
126    * Tests the retrieval of names given a locale
127    */
128    void TestDisplayName();
129
130    /**
131    * Tests the collator attributes
132    */
133    void TestAttribute();
134
135    /**
136    * Tests the setters and getters of variable top
137    */
138    void TestVariableTopSetting();
139    void TestMaxVariable();
140
141    /**
142    * Tests GetLocale for a Collator
143    */
144    void TestGetLocale();
145
146    /**
147    * Tests bounds API
148    */
149    void TestBounds();
150
151    /**
152    * Tests getTailoredSet API
153    */
154    void TestGetTailoredSet();
155
156    /**
157    * Tests the subclassability
158    */
159    void TestSubclass();
160
161    /**
162    * Tests the dynamic and static ids of collation classes
163    */
164    void TestUClassID();
165
166    /**
167    * Test NULL
168    */
169    void TestNULLCharTailoring();
170
171    void TestClone();
172    void TestCloneBinary();
173    void TestIterNumeric();
174    void TestBadKeywords();
175
176private:
177    // If this is too small for the test data, just increase it.
178    // Just don't make it too large, otherwise the executable will get too big
179    enum EToken_Len { MAX_TOKEN_LEN = 16 };
180
181    void dump(UnicodeString msg, RuleBasedCollator* c, UErrorCode& status);
182
183};
184
185#endif /* #if !UCONFIG_NO_COLLATION */
186
187#endif
188