]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | |
2 | /******************************************************************** | |
3 | * COPYRIGHT: | |
46f4442e | 4 | * Copyright (c) 1997-2007, International Business Machines Corporation and |
b75a7d8f A |
5 | * others. All Rights Reserved. |
6 | ******************************************************************** | |
7 | ********************************************************************** | |
8 | * Date Name Description | |
9 | * 10/20/99 alan Creation. | |
10 | * 03/22/2000 Madhu Added additional tests | |
11 | ********************************************************************** | |
12 | */ | |
13 | ||
14 | #ifndef _TESTUNISET | |
15 | #define _TESTUNISET | |
16 | ||
17 | #include "unicode/unistr.h" | |
18 | #include "unicode/uniset.h" | |
46f4442e | 19 | #include "unicode/ucnv_err.h" |
b75a7d8f A |
20 | #include "intltest.h" |
21 | ||
46f4442e A |
22 | class UnicodeSetWithStrings; |
23 | ||
b75a7d8f A |
24 | /** |
25 | * UnicodeSet test | |
26 | */ | |
27 | class UnicodeSetTest: public IntlTest { | |
46f4442e A |
28 | public: |
29 | UnicodeSetTest(); | |
30 | ~UnicodeSetTest(); | |
b75a7d8f | 31 | |
b75a7d8f | 32 | private: |
46f4442e | 33 | void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL); |
b75a7d8f A |
34 | |
35 | void Testj2268(); | |
36 | ||
37 | /** | |
38 | * Test that toPattern() round trips with syntax characters and | |
39 | * whitespace. | |
40 | */ | |
41 | void TestToPattern(); | |
42 | ||
43 | void TestPatterns(void); | |
44 | void TestCategories(void); | |
45 | void TestAddRemove(void); | |
46 | void TestCloneEqualHash(void); | |
47 | ||
48 | /** | |
49 | * Make sure minimal representation is maintained. | |
50 | */ | |
51 | void TestMinimalRep(void); | |
52 | ||
53 | void TestAPI(void); | |
54 | ||
73c04bcf A |
55 | void TestIteration(void); |
56 | ||
b75a7d8f A |
57 | void TestStrings(void); |
58 | ||
b75a7d8f A |
59 | void TestScriptSet(void); |
60 | ||
61 | /** | |
62 | * Test the [:Latin:] syntax. | |
63 | */ | |
64 | void TestPropertySet(void); | |
65 | ||
66 | void TestClone(void); | |
67 | ||
68 | void TestIndexOf(void); | |
69 | ||
70 | void TestExhaustive(void); | |
71 | ||
72 | void TestCloseOver(void); | |
73 | ||
74 | void TestEscapePattern(void); | |
75 | ||
76 | void TestInvalidCodePoint(void); | |
77 | ||
374ca955 A |
78 | void TestSymbolTable(void); |
79 | ||
80 | void TestSurrogate(); | |
81 | ||
73c04bcf A |
82 | void TestPosixClasses(); |
83 | ||
46f4442e A |
84 | void TestFreezable(); |
85 | ||
86 | void TestSpan(); | |
87 | ||
88 | void TestStringSpan(); | |
89 | ||
b75a7d8f A |
90 | private: |
91 | ||
92 | UBool toPatternAux(UChar32 start, UChar32 end); | |
93 | ||
94 | UBool checkPat(const UnicodeString& source, | |
95 | const UnicodeSet& testSet); | |
96 | ||
97 | UBool checkPat(const UnicodeString& source, const UnicodeSet& testSet, const UnicodeString& pat); | |
98 | ||
99 | void _testComplement(int32_t a, UnicodeSet&, UnicodeSet&); | |
100 | ||
101 | void _testAdd(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&); | |
102 | ||
103 | void _testRetain(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&); | |
104 | ||
105 | void _testRemove(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&); | |
106 | ||
107 | void _testXor(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&); | |
108 | ||
109 | /** | |
110 | * Check that ranges are monotonically increasing and non- | |
111 | * overlapping. | |
112 | */ | |
113 | void checkCanonicalRep(const UnicodeSet& set, const UnicodeString& msg); | |
114 | ||
115 | /** | |
116 | * Convert a bitmask to a UnicodeSet. | |
117 | */ | |
118 | static UnicodeSet& bitsToSet(int32_t a, UnicodeSet&); | |
119 | ||
120 | /** | |
121 | * Convert a UnicodeSet to a bitmask. Only the characters | |
122 | * U+0000 to U+0020 are represented in the bitmask. | |
123 | */ | |
124 | static int32_t setToBits(const UnicodeSet& x); | |
125 | ||
126 | /** | |
127 | * Return the representation of an inversion list based UnicodeSet | |
128 | * as a pairs list. Ranges are listed in ascending Unicode order. | |
129 | * For example, the set [a-zA-M3] is represented as "33AMaz". | |
130 | */ | |
131 | static UnicodeString getPairs(const UnicodeSet& set); | |
132 | ||
133 | /** | |
134 | * Basic consistency check for a few items. | |
135 | * That the iterator works, and that we can create a pattern and | |
136 | * get the same thing back | |
137 | */ | |
138 | void checkRoundTrip(const UnicodeSet& s); | |
139 | ||
140 | void copyWithIterator(UnicodeSet& t, const UnicodeSet& s, UBool withRange); | |
141 | ||
142 | UBool checkEqual(const UnicodeSet& s, const UnicodeSet& t, const char* message); | |
143 | ||
144 | void expectContainment(const UnicodeString& pat, | |
145 | const UnicodeString& charsIn, | |
146 | const UnicodeString& charsOut); | |
147 | void expectContainment(const UnicodeSet& set, | |
148 | const UnicodeString& charsIn, | |
149 | const UnicodeString& charsOut); | |
150 | void expectContainment(const UnicodeSet& set, | |
151 | const UnicodeString& setName, | |
152 | const UnicodeString& charsIn, | |
153 | const UnicodeString& charsOut); | |
154 | void expectPattern(UnicodeSet& set, | |
155 | const UnicodeString& pattern, | |
156 | const UnicodeString& expectedPairs); | |
157 | void expectPairs(const UnicodeSet& set, | |
158 | const UnicodeString& expectedPairs); | |
159 | void expectToPattern(const UnicodeSet& set, | |
160 | const UnicodeString& expPat, | |
161 | const char** expStrings); | |
162 | void expectRange(const UnicodeString& label, | |
163 | const UnicodeSet& set, | |
164 | UChar32 start, UChar32 end); | |
165 | void doAssert(UBool, const char*); | |
46f4442e A |
166 | |
167 | void testSpan(const UnicodeSetWithStrings *sets[4], const void *s, int32_t length, UBool isUTF16, | |
168 | uint32_t whichSpans, | |
169 | int32_t expectLimits[], int32_t &expectCount, | |
170 | const char *testName, int32_t index); | |
171 | void testSpan(const UnicodeSetWithStrings *sets[4], const void *s, int32_t length, UBool isUTF16, | |
172 | uint32_t whichSpans, | |
173 | const char *testName, int32_t index); | |
174 | void testSpanBothUTFs(const UnicodeSetWithStrings *sets[4], | |
175 | const UChar *s16, int32_t length16, | |
176 | uint32_t whichSpans, | |
177 | const char *testName, int32_t index); | |
178 | void testSpanContents(const UnicodeSetWithStrings *sets[4], uint32_t whichSpans, const char *testName); | |
179 | void testSpanUTF16String(const UnicodeSetWithStrings *sets[4], uint32_t whichSpans, const char *testName); | |
180 | void testSpanUTF8String(const UnicodeSetWithStrings *sets[4], uint32_t whichSpans, const char *testName); | |
181 | ||
182 | UConverter *openUTF8Converter(); | |
183 | ||
184 | UConverter *utf8Cnv; | |
185 | ||
b75a7d8f A |
186 | public: |
187 | static UnicodeString escape(const UnicodeString& s); | |
188 | }; | |
189 | ||
190 | #endif |