]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/usettest.h
2 /********************************************************************
4 * Copyright (c) 1997-2006, 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"
24 class UnicodeSetTest
: public IntlTest
{
26 void runIndexedTest(int32_t index
, UBool exec
, const char* &name
, char* par
=NULL
);
33 * Test that toPattern() round trips with syntax characters and
38 void TestPatterns(void);
39 void TestCategories(void);
40 void TestAddRemove(void);
41 void TestCloneEqualHash(void);
44 * Make sure minimal representation is maintained.
46 void TestMinimalRep(void);
50 void TestIteration(void);
52 void TestStrings(void);
54 void TestScriptSet(void);
57 * Test the [:Latin:] syntax.
59 void TestPropertySet(void);
63 void TestIndexOf(void);
65 void TestExhaustive(void);
67 void TestCloseOver(void);
69 void TestEscapePattern(void);
71 void TestInvalidCodePoint(void);
73 void TestSymbolTable(void);
77 void TestPosixClasses();
81 UBool
toPatternAux(UChar32 start
, UChar32 end
);
83 UBool
checkPat(const UnicodeString
& source
,
84 const UnicodeSet
& testSet
);
86 UBool
checkPat(const UnicodeString
& source
, const UnicodeSet
& testSet
, const UnicodeString
& pat
);
88 void _testComplement(int32_t a
, UnicodeSet
&, UnicodeSet
&);
90 void _testAdd(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
92 void _testRetain(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
94 void _testRemove(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
96 void _testXor(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
99 * Check that ranges are monotonically increasing and non-
102 void checkCanonicalRep(const UnicodeSet
& set
, const UnicodeString
& msg
);
105 * Convert a bitmask to a UnicodeSet.
107 static UnicodeSet
& bitsToSet(int32_t a
, UnicodeSet
&);
110 * Convert a UnicodeSet to a bitmask. Only the characters
111 * U+0000 to U+0020 are represented in the bitmask.
113 static int32_t setToBits(const UnicodeSet
& x
);
116 * Return the representation of an inversion list based UnicodeSet
117 * as a pairs list. Ranges are listed in ascending Unicode order.
118 * For example, the set [a-zA-M3] is represented as "33AMaz".
120 static UnicodeString
getPairs(const UnicodeSet
& set
);
123 * Basic consistency check for a few items.
124 * That the iterator works, and that we can create a pattern and
125 * get the same thing back
127 void checkRoundTrip(const UnicodeSet
& s
);
129 void copyWithIterator(UnicodeSet
& t
, const UnicodeSet
& s
, UBool withRange
);
131 UBool
checkEqual(const UnicodeSet
& s
, const UnicodeSet
& t
, const char* message
);
133 void expectContainment(const UnicodeString
& pat
,
134 const UnicodeString
& charsIn
,
135 const UnicodeString
& charsOut
);
136 void expectContainment(const UnicodeSet
& set
,
137 const UnicodeString
& charsIn
,
138 const UnicodeString
& charsOut
);
139 void expectContainment(const UnicodeSet
& set
,
140 const UnicodeString
& setName
,
141 const UnicodeString
& charsIn
,
142 const UnicodeString
& charsOut
);
143 void expectPattern(UnicodeSet
& set
,
144 const UnicodeString
& pattern
,
145 const UnicodeString
& expectedPairs
);
146 void expectPairs(const UnicodeSet
& set
,
147 const UnicodeString
& expectedPairs
);
148 void expectToPattern(const UnicodeSet
& set
,
149 const UnicodeString
& expPat
,
150 const char** expStrings
);
151 void expectRange(const UnicodeString
& label
,
152 const UnicodeSet
& set
,
153 UChar32 start
, UChar32 end
);
154 void doAssert(UBool
, const char*);
156 static UnicodeString
escape(const UnicodeString
& s
);