• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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-2001, International Business Machines Corporation and
6  * others. All Rights Reserved.
7  ********************************************************************/
8 
9 /**
10  * Collation Iterator tests.
11  * (Let me reiterate my position...)
12  */
13 
14 #ifndef _ITERCOLL
15 #define _ITERCOLL
16 
17 #include "unicode/utypes.h"
18 
19 #if !UCONFIG_NO_COLLATION
20 
21 #include "unicode/tblcoll.h"
22 #include "unicode/coleitr.h"
23 #include "tscoll.h"
24 
25 class CollationIteratorTest: public IntlTestCollator
26 {
27 public:
28 
29     // If this is too small for the test data, just increase it.
30     // Just don't make it too large, otherwise the executable will get too big
31     enum EToken_Len { MAX_TOKEN_LEN = 16 };
32 
33     CollationIteratorTest();
34     virtual ~CollationIteratorTest();
35 
36     void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par = NULL);
37 
38     /**
39     * Test that results from CollationElementIterator.next is equivalent to
40     * the reversed results from CollationElementIterator.previous, for the set
41     * of BMP characters.
42     */
43     void TestUnicodeChar();
44 
45     /**
46      * Test for CollationElementIterator.previous()
47      *
48      * @bug 4108758 - Make sure it works with contracting characters
49      *
50      */
51     void TestPrevious(/* char* par */);
52 
53     /**
54      * Test for getOffset() and setOffset()
55      */
56     void TestOffset(/* char* par */);
57 
58     /**
59      * Test for setText()
60      */
61     void TestSetText(/* char* par */);
62 
63     /** @bug 4108762
64      * Test for getMaxExpansion()
65      */
66     void TestMaxExpansion(/* char* par */);
67 
68     /*
69      * @bug 4157299
70      */
71     void TestClearBuffers(/* char* par */);
72 
73     /**
74      * Testing the assignment operator
75      */
76     void TestAssignment();
77 
78     /**
79      * Testing the constructors
80      */
81     void TestConstructors();
82 
83     /**
84     * Testing the strength order functionality
85     */
86     void TestStrengthOrder();
87 
88     //------------------------------------------------------------------------
89     // Internal utilities
90     //
91 
92 private:
93 
94     struct ExpansionRecord
95     {
96         UChar character;
97         int32_t count;
98     };
99 
100     /**
101      * Verify that getMaxExpansion works on a given set of collation rules
102      */
103     void verifyExpansion(UnicodeString rules, ExpansionRecord tests[], int32_t testCount);
104 
105     /**
106      * Return a string containing all of the collation orders
107      * returned by calls to next on the specified iterator
108      */
109     UnicodeString &orderString(CollationElementIterator &iter, UnicodeString &target);
110 
111     void assertEqual(CollationElementIterator &i1, CollationElementIterator &i2);
112 
113     RuleBasedCollator *en_us;
114     const UnicodeString test1;
115     const UnicodeString test2;
116 
117 };
118 
119 #endif /* #if !UCONFIG_NO_COLLATION */
120 
121 #endif
122