]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/usettest.h
2 /********************************************************************
4 * Copyright (c) 1997-2015, 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"
23 class UnicodeSetWithStrings
;
28 class UnicodeSetTest
: public IntlTest
{
34 void runIndexedTest(int32_t index
, UBool exec
, const char* &name
, char* par
=NULL
);
39 * Test that toPattern() round trips with syntax characters and
44 void TestPatterns(void);
45 void TestCategories(void);
46 void TestAddRemove(void);
47 void TestCloneEqualHash(void);
50 * Make sure minimal representation is maintained.
52 void TestMinimalRep(void);
56 void TestIteration(void);
58 void TestStrings(void);
60 void TestScriptSet(void);
63 * Test the [:Latin:] syntax.
65 void TestPropertySet(void);
69 void TestIndexOf(void);
71 void TestExhaustive(void);
73 void TestCloseOver(void);
75 void TestEscapePattern(void);
77 void TestInvalidCodePoint(void);
79 void TestSymbolTable(void);
83 void TestPosixClasses();
89 void TestStringSpan();
91 void TestUCAUnsafeBackwards();
95 UBool
toPatternAux(UChar32 start
, UChar32 end
);
97 UBool
checkPat(const UnicodeString
& source
,
98 const UnicodeSet
& testSet
);
100 UBool
checkPat(const UnicodeString
& source
, const UnicodeSet
& testSet
, const UnicodeString
& pat
);
102 void _testComplement(int32_t a
, UnicodeSet
&, UnicodeSet
&);
104 void _testAdd(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
106 void _testRetain(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
108 void _testRemove(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
110 void _testXor(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
113 * Check that ranges are monotonically increasing and non-
116 void checkCanonicalRep(const UnicodeSet
& set
, const UnicodeString
& msg
);
119 * Convert a bitmask to a UnicodeSet.
121 static UnicodeSet
& bitsToSet(int32_t a
, UnicodeSet
&);
124 * Convert a UnicodeSet to a bitmask. Only the characters
125 * U+0000 to U+0020 are represented in the bitmask.
127 static int32_t setToBits(const UnicodeSet
& x
);
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".
134 static UnicodeString
getPairs(const UnicodeSet
& set
);
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
141 void checkRoundTrip(const UnicodeSet
& s
);
143 void checkSerializeRoundTrip(const UnicodeSet
& s
, UErrorCode
&ec
);
145 void copyWithIterator(UnicodeSet
& t
, const UnicodeSet
& s
, UBool withRange
);
147 UBool
checkEqual(const UnicodeSet
& s
, const UnicodeSet
& t
, const char* message
);
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*);
172 void testSpan(const UnicodeSetWithStrings
*sets
[4], const void *s
, int32_t length
, UBool isUTF16
,
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
,
178 const char *testName
, int32_t index
);
179 void testSpanBothUTFs(const UnicodeSetWithStrings
*sets
[4],
180 const UChar
*s16
, int32_t length16
,
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
);
187 UConverter
*openUTF8Converter();
191 MaybeStackArray
<uint16_t, 16> serializeBuffer
;
194 static UnicodeString
escape(const UnicodeString
& s
);