]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/usettest.h
2 /********************************************************************
4 * Copyright (c) 1997-2007, 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 **********************************************************************
17 #include "unicode/unistr.h"
18 #include "unicode/uniset.h"
19 #include "unicode/ucnv_err.h"
22 class UnicodeSetWithStrings
;
27 class UnicodeSetTest
: public IntlTest
{
33 void runIndexedTest(int32_t index
, UBool exec
, const char* &name
, char* par
=NULL
);
38 * Test that toPattern() round trips with syntax characters and
43 void TestPatterns(void);
44 void TestCategories(void);
45 void TestAddRemove(void);
46 void TestCloneEqualHash(void);
49 * Make sure minimal representation is maintained.
51 void TestMinimalRep(void);
55 void TestIteration(void);
57 void TestStrings(void);
59 void TestScriptSet(void);
62 * Test the [:Latin:] syntax.
64 void TestPropertySet(void);
68 void TestIndexOf(void);
70 void TestExhaustive(void);
72 void TestCloseOver(void);
74 void TestEscapePattern(void);
76 void TestInvalidCodePoint(void);
78 void TestSymbolTable(void);
82 void TestPosixClasses();
88 void TestStringSpan();
92 UBool
toPatternAux(UChar32 start
, UChar32 end
);
94 UBool
checkPat(const UnicodeString
& source
,
95 const UnicodeSet
& testSet
);
97 UBool
checkPat(const UnicodeString
& source
, const UnicodeSet
& testSet
, const UnicodeString
& pat
);
99 void _testComplement(int32_t a
, UnicodeSet
&, UnicodeSet
&);
101 void _testAdd(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
103 void _testRetain(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
105 void _testRemove(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
107 void _testXor(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
110 * Check that ranges are monotonically increasing and non-
113 void checkCanonicalRep(const UnicodeSet
& set
, const UnicodeString
& msg
);
116 * Convert a bitmask to a UnicodeSet.
118 static UnicodeSet
& bitsToSet(int32_t a
, UnicodeSet
&);
121 * Convert a UnicodeSet to a bitmask. Only the characters
122 * U+0000 to U+0020 are represented in the bitmask.
124 static int32_t setToBits(const UnicodeSet
& x
);
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".
131 static UnicodeString
getPairs(const UnicodeSet
& set
);
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
138 void checkRoundTrip(const UnicodeSet
& s
);
140 void copyWithIterator(UnicodeSet
& t
, const UnicodeSet
& s
, UBool withRange
);
142 UBool
checkEqual(const UnicodeSet
& s
, const UnicodeSet
& t
, const char* message
);
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*);
167 void testSpan(const UnicodeSetWithStrings
*sets
[4], const void *s
, int32_t length
, UBool isUTF16
,
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
,
173 const char *testName
, int32_t index
);
174 void testSpanBothUTFs(const UnicodeSetWithStrings
*sets
[4],
175 const UChar
*s16
, int32_t length16
,
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
);
182 UConverter
*openUTF8Converter();
187 static UnicodeString
escape(const UnicodeString
& s
);