]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/usettest.h
2 /********************************************************************
4 * Copyright (c) 1997-2004, 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 TestStrings(void);
52 void TestScriptSet(void);
55 * Test the [:Latin:] syntax.
57 void TestPropertySet(void);
61 void TestIndexOf(void);
63 void TestExhaustive(void);
65 void TestCloseOver(void);
67 void TestEscapePattern(void);
69 void TestInvalidCodePoint(void);
71 void TestSymbolTable(void);
77 UBool
toPatternAux(UChar32 start
, UChar32 end
);
79 UBool
checkPat(const UnicodeString
& source
,
80 const UnicodeSet
& testSet
);
82 UBool
checkPat(const UnicodeString
& source
, const UnicodeSet
& testSet
, const UnicodeString
& pat
);
84 void _testComplement(int32_t a
, UnicodeSet
&, UnicodeSet
&);
86 void _testAdd(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
88 void _testRetain(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
90 void _testRemove(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
92 void _testXor(int32_t a
, int32_t b
, UnicodeSet
&, UnicodeSet
&, UnicodeSet
&);
95 * Check that ranges are monotonically increasing and non-
98 void checkCanonicalRep(const UnicodeSet
& set
, const UnicodeString
& msg
);
101 * Convert a bitmask to a UnicodeSet.
103 static UnicodeSet
& bitsToSet(int32_t a
, UnicodeSet
&);
106 * Convert a UnicodeSet to a bitmask. Only the characters
107 * U+0000 to U+0020 are represented in the bitmask.
109 static int32_t setToBits(const UnicodeSet
& x
);
112 * Return the representation of an inversion list based UnicodeSet
113 * as a pairs list. Ranges are listed in ascending Unicode order.
114 * For example, the set [a-zA-M3] is represented as "33AMaz".
116 static UnicodeString
getPairs(const UnicodeSet
& set
);
119 * Basic consistency check for a few items.
120 * That the iterator works, and that we can create a pattern and
121 * get the same thing back
123 void checkRoundTrip(const UnicodeSet
& s
);
125 void copyWithIterator(UnicodeSet
& t
, const UnicodeSet
& s
, UBool withRange
);
127 UBool
checkEqual(const UnicodeSet
& s
, const UnicodeSet
& t
, const char* message
);
129 void expectContainment(const UnicodeString
& pat
,
130 const UnicodeString
& charsIn
,
131 const UnicodeString
& charsOut
);
132 void expectContainment(const UnicodeSet
& set
,
133 const UnicodeString
& charsIn
,
134 const UnicodeString
& charsOut
);
135 void expectContainment(const UnicodeSet
& set
,
136 const UnicodeString
& setName
,
137 const UnicodeString
& charsIn
,
138 const UnicodeString
& charsOut
);
139 void expectPattern(UnicodeSet
& set
,
140 const UnicodeString
& pattern
,
141 const UnicodeString
& expectedPairs
);
142 void expectPairs(const UnicodeSet
& set
,
143 const UnicodeString
& expectedPairs
);
144 void expectToPattern(const UnicodeSet
& set
,
145 const UnicodeString
& expPat
,
146 const char** expStrings
);
147 void expectRange(const UnicodeString
& label
,
148 const UnicodeSet
& set
,
149 UChar32 start
, UChar32 end
);
150 void doAssert(UBool
, const char*);
152 static UnicodeString
escape(const UnicodeString
& s
);