]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/usettest.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 /********************************************************************
6 * Copyright (c) 1997-2015, International Business Machines Corporation and
7 * others. All Rights Reserved.
8 ********************************************************************
9 **********************************************************************
10 * Date Name Description
11 * 10/20/99 alan Creation.
12 * 03/22/2000 Madhu Added additional tests
13 **********************************************************************
19 #include "unicode/unistr.h"
20 #include "unicode/uniset.h"
21 #include "unicode/ucnv_err.h"
25 class UnicodeSetWithStrings
;
30 class UnicodeSetTest
: public IntlTest
{
36 void runIndexedTest(int32_t index
, UBool exec
, const char* &name
, char* par
=NULL
);
41 * Test that toPattern() round trips with syntax characters and
46 void TestPatterns(void);
47 void TestCategories(void);
48 void TestAddRemove(void);
49 void TestCloneEqualHash(void);
52 * Make sure minimal representation is maintained.
54 void TestMinimalRep(void);
58 void TestIteration(void);
60 void TestStrings(void);
62 void TestScriptSet(void);
65 * Test the [:Latin:] syntax.
67 void TestPropertySet(void);
71 void TestIndexOf(void);
73 void TestExhaustive(void);
75 void TestCloseOver(void);
77 void TestEscapePattern(void);
79 void TestInvalidCodePoint(void);
81 void TestSymbolTable(void);
85 void TestPosixClasses();
91 void TestStringSpan();
93 void TestUCAUnsafeBackwards();
94 void TestIntOverflow();
96 void TestDeepPattern();
100 UBool
toPatternAux(UChar32 start
, UChar32 end
);
102 UBool
checkPat(const UnicodeString
& source
,
103 const UnicodeSet
& testSet
);
105 UBool
checkPat(const UnicodeString
& source
, const UnicodeSet
& testSet
, const UnicodeString
& pat
);
107 void _testComplement(int32_t a
, UnicodeSet
&, UnicodeSet
&);
109 void _testAdd(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
111 void _testRetain(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
113 void _testRemove(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
115 void _testXor(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
118 * Check that ranges are monotonically increasing and non-
121 void checkCanonicalRep(const UnicodeSet
& set
, const UnicodeString
& msg
);
124 * Convert a bitmask to a UnicodeSet.
126 static UnicodeSet
& bitsToSet(int32_t a
, UnicodeSet
&);
129 * Convert a UnicodeSet to a bitmask. Only the characters
130 * U+0000 to U+0020 are represented in the bitmask.
132 static int32_t setToBits(const UnicodeSet
& x
);
135 * Return the representation of an inversion list based UnicodeSet
136 * as a pairs list. Ranges are listed in ascending Unicode order.
137 * For example, the set [a-zA-M3] is represented as "33AMaz".
139 static UnicodeString
getPairs(const UnicodeSet
& set
);
142 * Basic consistency check for a few items.
143 * That the iterator works, and that we can create a pattern and
144 * get the same thing back
146 void checkRoundTrip(const UnicodeSet
& s
);
148 void checkSerializeRoundTrip(const UnicodeSet
& s
, UErrorCode
&ec
);
150 void copyWithIterator(UnicodeSet
& t
, const UnicodeSet
& s
, UBool withRange
);
152 UBool
checkEqual(const UnicodeSet
& s
, const UnicodeSet
& t
, const char* message
);
154 void expectContainment(const UnicodeString
& pat
,
155 const UnicodeString
& charsIn
,
156 const UnicodeString
& charsOut
);
157 void expectContainment(const UnicodeSet
& set
,
158 const UnicodeString
& charsIn
,
159 const UnicodeString
& charsOut
);
160 void expectContainment(const UnicodeSet
& set
,
161 const UnicodeString
& setName
,
162 const UnicodeString
& charsIn
,
163 const UnicodeString
& charsOut
);
164 void expectPattern(UnicodeSet
& set
,
165 const UnicodeString
& pattern
,
166 const UnicodeString
& expectedPairs
);
167 void expectPairs(const UnicodeSet
& set
,
168 const UnicodeString
& expectedPairs
);
169 void expectToPattern(const UnicodeSet
& set
,
170 const UnicodeString
& expPat
,
171 const char** expStrings
);
172 void expectRange(const UnicodeString
& label
,
173 const UnicodeSet
& set
,
174 UChar32 start
, UChar32 end
);
175 void doAssert(UBool
, const char*);
177 void testSpan(const UnicodeSetWithStrings
*sets
[4], const void *s
, int32_t length
, UBool isUTF16
,
179 int32_t expectLimits
[], int32_t &expectCount
,
180 const char *testName
, int32_t index
);
181 void testSpan(const UnicodeSetWithStrings
*sets
[4], const void *s
, int32_t length
, UBool isUTF16
,
183 const char *testName
, int32_t index
);
184 void testSpanBothUTFs(const UnicodeSetWithStrings
*sets
[4],
185 const UChar
*s16
, int32_t length16
,
187 const char *testName
, int32_t index
);
188 void testSpanContents(const UnicodeSetWithStrings
*sets
[4], uint32_t whichSpans
, const char *testName
);
189 void testSpanUTF16String(const UnicodeSetWithStrings
*sets
[4], uint32_t whichSpans
, const char *testName
);
190 void testSpanUTF8String(const UnicodeSetWithStrings
*sets
[4], uint32_t whichSpans
, const char *testName
);
192 UConverter
*openUTF8Converter();
196 MaybeStackArray
<uint16_t, 16> serializeBuffer
;
199 static UnicodeString
escape(const UnicodeString
& s
);