]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | |
2 | /******************************************************************** | |
3 | * COPYRIGHT: | |
4 | * Copyright (c) 1997-2003, 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 TestStringPatterns(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 | private: | |
74 | ||
75 | UBool toPatternAux(UChar32 start, UChar32 end); | |
76 | ||
77 | UBool checkPat(const UnicodeString& source, | |
78 | const UnicodeSet& testSet); | |
79 | ||
80 | UBool checkPat(const UnicodeString& source, const UnicodeSet& testSet, const UnicodeString& pat); | |
81 | ||
82 | void _testComplement(int32_t a, UnicodeSet&, UnicodeSet&); | |
83 | ||
84 | void _testAdd(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&); | |
85 | ||
86 | void _testRetain(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&); | |
87 | ||
88 | void _testRemove(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&); | |
89 | ||
90 | void _testXor(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&); | |
91 | ||
92 | /** | |
93 | * Check that ranges are monotonically increasing and non- | |
94 | * overlapping. | |
95 | */ | |
96 | void checkCanonicalRep(const UnicodeSet& set, const UnicodeString& msg); | |
97 | ||
98 | /** | |
99 | * Convert a bitmask to a UnicodeSet. | |
100 | */ | |
101 | static UnicodeSet& bitsToSet(int32_t a, UnicodeSet&); | |
102 | ||
103 | /** | |
104 | * Convert a UnicodeSet to a bitmask. Only the characters | |
105 | * U+0000 to U+0020 are represented in the bitmask. | |
106 | */ | |
107 | static int32_t setToBits(const UnicodeSet& x); | |
108 | ||
109 | /** | |
110 | * Return the representation of an inversion list based UnicodeSet | |
111 | * as a pairs list. Ranges are listed in ascending Unicode order. | |
112 | * For example, the set [a-zA-M3] is represented as "33AMaz". | |
113 | */ | |
114 | static UnicodeString getPairs(const UnicodeSet& set); | |
115 | ||
116 | /** | |
117 | * Basic consistency check for a few items. | |
118 | * That the iterator works, and that we can create a pattern and | |
119 | * get the same thing back | |
120 | */ | |
121 | void checkRoundTrip(const UnicodeSet& s); | |
122 | ||
123 | void copyWithIterator(UnicodeSet& t, const UnicodeSet& s, UBool withRange); | |
124 | ||
125 | UBool checkEqual(const UnicodeSet& s, const UnicodeSet& t, const char* message); | |
126 | ||
127 | void expectContainment(const UnicodeString& pat, | |
128 | const UnicodeString& charsIn, | |
129 | const UnicodeString& charsOut); | |
130 | void expectContainment(const UnicodeSet& set, | |
131 | const UnicodeString& charsIn, | |
132 | const UnicodeString& charsOut); | |
133 | void expectContainment(const UnicodeSet& set, | |
134 | const UnicodeString& setName, | |
135 | const UnicodeString& charsIn, | |
136 | const UnicodeString& charsOut); | |
137 | void expectPattern(UnicodeSet& set, | |
138 | const UnicodeString& pattern, | |
139 | const UnicodeString& expectedPairs); | |
140 | void expectPairs(const UnicodeSet& set, | |
141 | const UnicodeString& expectedPairs); | |
142 | void expectToPattern(const UnicodeSet& set, | |
143 | const UnicodeString& expPat, | |
144 | const char** expStrings); | |
145 | void expectRange(const UnicodeString& label, | |
146 | const UnicodeSet& set, | |
147 | UChar32 start, UChar32 end); | |
148 | void doAssert(UBool, const char*); | |
149 | public: | |
150 | static UnicodeString escape(const UnicodeString& s); | |
151 | }; | |
152 | ||
153 | #endif |