]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/usettest.h
ICU-8.11.4.tar.gz
[apple/icu.git] / icuSources / test / intltest / usettest.h
1
2 /********************************************************************
3 * COPYRIGHT:
4 * Copyright (c) 1997-2006, International Business Machines Corporation and
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"
19 #include "intltest.h"
20
21 /**
22 * UnicodeSet test
23 */
24 class UnicodeSetTest: public IntlTest {
25
26 void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL);
27
28 private:
29
30 void Testj2268();
31
32 /**
33 * Test that toPattern() round trips with syntax characters and
34 * whitespace.
35 */
36 void TestToPattern();
37
38 void TestPatterns(void);
39 void TestCategories(void);
40 void TestAddRemove(void);
41 void TestCloneEqualHash(void);
42
43 /**
44 * Make sure minimal representation is maintained.
45 */
46 void TestMinimalRep(void);
47
48 void TestAPI(void);
49
50 void TestIteration(void);
51
52 void TestStrings(void);
53
54 void TestScriptSet(void);
55
56 /**
57 * Test the [:Latin:] syntax.
58 */
59 void TestPropertySet(void);
60
61 void TestClone(void);
62
63 void TestIndexOf(void);
64
65 void TestExhaustive(void);
66
67 void TestCloseOver(void);
68
69 void TestEscapePattern(void);
70
71 void TestInvalidCodePoint(void);
72
73 void TestSymbolTable(void);
74
75 void TestSurrogate();
76
77 void TestPosixClasses();
78
79 private:
80
81 UBool toPatternAux(UChar32 start, UChar32 end);
82
83 UBool checkPat(const UnicodeString& source,
84 const UnicodeSet& testSet);
85
86 UBool checkPat(const UnicodeString& source, const UnicodeSet& testSet, const UnicodeString& pat);
87
88 void _testComplement(int32_t a, UnicodeSet&, UnicodeSet&);
89
90 void _testAdd(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
91
92 void _testRetain(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
93
94 void _testRemove(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
95
96 void _testXor(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
97
98 /**
99 * Check that ranges are monotonically increasing and non-
100 * overlapping.
101 */
102 void checkCanonicalRep(const UnicodeSet& set, const UnicodeString& msg);
103
104 /**
105 * Convert a bitmask to a UnicodeSet.
106 */
107 static UnicodeSet& bitsToSet(int32_t a, UnicodeSet&);
108
109 /**
110 * Convert a UnicodeSet to a bitmask. Only the characters
111 * U+0000 to U+0020 are represented in the bitmask.
112 */
113 static int32_t setToBits(const UnicodeSet& x);
114
115 /**
116 * Return the representation of an inversion list based UnicodeSet
117 * as a pairs list. Ranges are listed in ascending Unicode order.
118 * For example, the set [a-zA-M3] is represented as "33AMaz".
119 */
120 static UnicodeString getPairs(const UnicodeSet& set);
121
122 /**
123 * Basic consistency check for a few items.
124 * That the iterator works, and that we can create a pattern and
125 * get the same thing back
126 */
127 void checkRoundTrip(const UnicodeSet& s);
128
129 void copyWithIterator(UnicodeSet& t, const UnicodeSet& s, UBool withRange);
130
131 UBool checkEqual(const UnicodeSet& s, const UnicodeSet& t, const char* message);
132
133 void expectContainment(const UnicodeString& pat,
134 const UnicodeString& charsIn,
135 const UnicodeString& charsOut);
136 void expectContainment(const UnicodeSet& set,
137 const UnicodeString& charsIn,
138 const UnicodeString& charsOut);
139 void expectContainment(const UnicodeSet& set,
140 const UnicodeString& setName,
141 const UnicodeString& charsIn,
142 const UnicodeString& charsOut);
143 void expectPattern(UnicodeSet& set,
144 const UnicodeString& pattern,
145 const UnicodeString& expectedPairs);
146 void expectPairs(const UnicodeSet& set,
147 const UnicodeString& expectedPairs);
148 void expectToPattern(const UnicodeSet& set,
149 const UnicodeString& expPat,
150 const char** expStrings);
151 void expectRange(const UnicodeString& label,
152 const UnicodeSet& set,
153 UChar32 start, UChar32 end);
154 void doAssert(UBool, const char*);
155 public:
156 static UnicodeString escape(const UnicodeString& s);
157 };
158
159 #endif