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