]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/usettest.h
ICU-6.2.22.tar.gz
[apple/icu.git] / icuSources / test / intltest / usettest.h
1
2 /********************************************************************
3 * COPYRIGHT:
4 * Copyright (c) 1997-2004, 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 TestStrings(void);
51
52 void TestScriptSet(void);
53
54 /**
55 * Test the [:Latin:] syntax.
56 */
57 void TestPropertySet(void);
58
59 void TestClone(void);
60
61 void TestIndexOf(void);
62
63 void TestExhaustive(void);
64
65 void TestCloseOver(void);
66
67 void TestEscapePattern(void);
68
69 void TestInvalidCodePoint(void);
70
71 void TestSymbolTable(void);
72
73 void TestSurrogate();
74
75 private:
76
77 UBool toPatternAux(UChar32 start, UChar32 end);
78
79 UBool checkPat(const UnicodeString& source,
80 const UnicodeSet& testSet);
81
82 UBool checkPat(const UnicodeString& source, const UnicodeSet& testSet, const UnicodeString& pat);
83
84 void _testComplement(int32_t a, UnicodeSet&, UnicodeSet&);
85
86 void _testAdd(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
87
88 void _testRetain(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
89
90 void _testRemove(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
91
92 void _testXor(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
93
94 /**
95 * Check that ranges are monotonically increasing and non-
96 * overlapping.
97 */
98 void checkCanonicalRep(const UnicodeSet& set, const UnicodeString& msg);
99
100 /**
101 * Convert a bitmask to a UnicodeSet.
102 */
103 static UnicodeSet& bitsToSet(int32_t a, UnicodeSet&);
104
105 /**
106 * Convert a UnicodeSet to a bitmask. Only the characters
107 * U+0000 to U+0020 are represented in the bitmask.
108 */
109 static int32_t setToBits(const UnicodeSet& x);
110
111 /**
112 * Return the representation of an inversion list based UnicodeSet
113 * as a pairs list. Ranges are listed in ascending Unicode order.
114 * For example, the set [a-zA-M3] is represented as "33AMaz".
115 */
116 static UnicodeString getPairs(const UnicodeSet& set);
117
118 /**
119 * Basic consistency check for a few items.
120 * That the iterator works, and that we can create a pattern and
121 * get the same thing back
122 */
123 void checkRoundTrip(const UnicodeSet& s);
124
125 void copyWithIterator(UnicodeSet& t, const UnicodeSet& s, UBool withRange);
126
127 UBool checkEqual(const UnicodeSet& s, const UnicodeSet& t, const char* message);
128
129 void expectContainment(const UnicodeString& pat,
130 const UnicodeString& charsIn,
131 const UnicodeString& charsOut);
132 void expectContainment(const UnicodeSet& set,
133 const UnicodeString& charsIn,
134 const UnicodeString& charsOut);
135 void expectContainment(const UnicodeSet& set,
136 const UnicodeString& setName,
137 const UnicodeString& charsIn,
138 const UnicodeString& charsOut);
139 void expectPattern(UnicodeSet& set,
140 const UnicodeString& pattern,
141 const UnicodeString& expectedPairs);
142 void expectPairs(const UnicodeSet& set,
143 const UnicodeString& expectedPairs);
144 void expectToPattern(const UnicodeSet& set,
145 const UnicodeString& expPat,
146 const char** expStrings);
147 void expectRange(const UnicodeString& label,
148 const UnicodeSet& set,
149 UChar32 start, UChar32 end);
150 void doAssert(UBool, const char*);
151 public:
152 static UnicodeString escape(const UnicodeString& s);
153 };
154
155 #endif