2001-03-21 20:09:56 +00:00
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
2003-06-03 20:58:22 +00:00
|
|
|
* Copyright (c) 1997-2003, International Business Machines Corporation and
|
2001-03-21 20:09:56 +00:00
|
|
|
* others. All Rights Reserved.
|
|
|
|
********************************************************************
|
1999-10-26 17:16:13 +00:00
|
|
|
**********************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 10/20/99 alan Creation.
|
2000-03-28 23:51:25 +00:00
|
|
|
* 03/22/2000 Madhu Added additional tests
|
1999-10-26 17:16:13 +00:00
|
|
|
**********************************************************************
|
|
|
|
*/
|
|
|
|
|
1999-10-20 22:08:09 +00:00
|
|
|
#ifndef _TESTUNISET
|
|
|
|
#define _TESTUNISET
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
#include "unicode/unistr.h"
|
|
|
|
#include "unicode/uniset.h"
|
1999-10-20 22:08:09 +00:00
|
|
|
#include "intltest.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UnicodeSet test
|
|
|
|
*/
|
|
|
|
class UnicodeSetTest: public IntlTest {
|
|
|
|
|
2000-08-14 21:42:36 +00:00
|
|
|
void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL);
|
1999-10-20 22:08:09 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
2002-08-29 23:23:45 +00:00
|
|
|
void Testj2268();
|
|
|
|
|
2001-12-01 01:33:41 +00:00
|
|
|
/**
|
|
|
|
* Test that toPattern() round trips with syntax characters and
|
|
|
|
* whitespace.
|
|
|
|
*/
|
|
|
|
void TestToPattern();
|
|
|
|
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestPatterns(void);
|
2000-01-12 18:04:21 +00:00
|
|
|
void TestCategories(void);
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestAddRemove(void);
|
2000-08-14 21:42:36 +00:00
|
|
|
void TestCloneEqualHash(void);
|
2000-03-28 23:51:25 +00:00
|
|
|
|
2000-05-25 19:28:53 +00:00
|
|
|
/**
|
|
|
|
* Make sure minimal representation is maintained.
|
|
|
|
*/
|
|
|
|
void TestMinimalRep(void);
|
|
|
|
|
|
|
|
void TestAPI(void);
|
|
|
|
|
2002-04-26 06:28:15 +00:00
|
|
|
void TestStrings(void);
|
|
|
|
|
|
|
|
void TestStringPatterns(void);
|
|
|
|
|
2001-10-10 21:36:26 +00:00
|
|
|
void TestScriptSet(void);
|
|
|
|
|
2001-10-17 19:21:12 +00:00
|
|
|
/**
|
|
|
|
* Test the [:Latin:] syntax.
|
|
|
|
*/
|
|
|
|
void TestPropertySet(void);
|
|
|
|
|
2001-11-12 20:57:06 +00:00
|
|
|
void TestClone(void);
|
|
|
|
|
2001-12-11 01:13:33 +00:00
|
|
|
void TestIndexOf(void);
|
|
|
|
|
2000-05-25 19:28:53 +00:00
|
|
|
void TestExhaustive(void);
|
|
|
|
|
2003-02-11 22:47:28 +00:00
|
|
|
void TestCloseOver(void);
|
|
|
|
|
2003-02-17 23:31:10 +00:00
|
|
|
void TestEscapePattern(void);
|
|
|
|
|
2003-05-14 22:30:21 +00:00
|
|
|
void TestInvalidCodePoint(void);
|
|
|
|
|
2000-05-25 19:28:53 +00:00
|
|
|
private:
|
|
|
|
|
2001-12-01 01:33:41 +00:00
|
|
|
UBool toPatternAux(UChar32 start, UChar32 end);
|
|
|
|
|
2001-12-01 21:46:53 +00:00
|
|
|
UBool checkPat(const UnicodeString& source,
|
|
|
|
const UnicodeSet& testSet);
|
|
|
|
|
2001-12-01 01:33:41 +00:00
|
|
|
UBool checkPat(const UnicodeString& source, const UnicodeSet& testSet, const UnicodeString& pat);
|
|
|
|
|
2000-05-25 20:57:30 +00:00
|
|
|
void _testComplement(int32_t a, UnicodeSet&, UnicodeSet&);
|
2000-05-25 19:28:53 +00:00
|
|
|
|
2000-05-25 20:57:30 +00:00
|
|
|
void _testAdd(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
|
2000-05-25 19:28:53 +00:00
|
|
|
|
2000-05-25 20:57:30 +00:00
|
|
|
void _testRetain(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
|
2000-05-25 19:28:53 +00:00
|
|
|
|
2000-05-25 20:57:30 +00:00
|
|
|
void _testRemove(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
|
2000-05-25 19:28:53 +00:00
|
|
|
|
2000-05-25 20:57:30 +00:00
|
|
|
void _testXor(int32_t a, int32_t b, UnicodeSet&, UnicodeSet&, UnicodeSet&);
|
2000-05-25 19:28:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Check that ranges are monotonically increasing and non-
|
|
|
|
* overlapping.
|
|
|
|
*/
|
|
|
|
void checkCanonicalRep(const UnicodeSet& set, const UnicodeString& msg);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a bitmask to a UnicodeSet.
|
|
|
|
*/
|
2002-04-26 06:28:15 +00:00
|
|
|
static UnicodeSet& bitsToSet(int32_t a, UnicodeSet&);
|
2000-05-25 19:28:53 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convert a UnicodeSet to a bitmask. Only the characters
|
|
|
|
* U+0000 to U+0020 are represented in the bitmask.
|
|
|
|
*/
|
|
|
|
static int32_t setToBits(const UnicodeSet& x);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the representation of an inversion list based UnicodeSet
|
|
|
|
* as a pairs list. Ranges are listed in ascending Unicode order.
|
|
|
|
* For example, the set [a-zA-M3] is represented as "33AMaz".
|
|
|
|
*/
|
|
|
|
static UnicodeString getPairs(const UnicodeSet& set);
|
1999-10-20 22:08:09 +00:00
|
|
|
|
2002-04-26 06:28:15 +00:00
|
|
|
/**
|
|
|
|
* Basic consistency check for a few items.
|
|
|
|
* That the iterator works, and that we can create a pattern and
|
|
|
|
* get the same thing back
|
|
|
|
*/
|
|
|
|
void checkRoundTrip(const UnicodeSet& s);
|
|
|
|
|
|
|
|
void copyWithIterator(UnicodeSet& t, const UnicodeSet& s, UBool withRange);
|
|
|
|
|
|
|
|
UBool checkEqual(const UnicodeSet& s, const UnicodeSet& t, const char* message);
|
|
|
|
|
2003-02-14 21:18:41 +00:00
|
|
|
void expectContainment(const UnicodeString& pat,
|
|
|
|
const UnicodeString& charsIn,
|
|
|
|
const UnicodeString& charsOut);
|
2001-10-17 19:21:12 +00:00
|
|
|
void expectContainment(const UnicodeSet& set,
|
|
|
|
const UnicodeString& charsIn,
|
|
|
|
const UnicodeString& charsOut);
|
2000-01-12 18:04:21 +00:00
|
|
|
void expectContainment(const UnicodeSet& set,
|
|
|
|
const UnicodeString& setName,
|
|
|
|
const UnicodeString& charsIn,
|
|
|
|
const UnicodeString& charsOut);
|
1999-10-26 17:16:13 +00:00
|
|
|
void expectPattern(UnicodeSet& set,
|
|
|
|
const UnicodeString& pattern,
|
|
|
|
const UnicodeString& expectedPairs);
|
|
|
|
void expectPairs(const UnicodeSet& set,
|
|
|
|
const UnicodeString& expectedPairs);
|
2002-04-26 06:28:15 +00:00
|
|
|
void expectToPattern(const UnicodeSet& set,
|
|
|
|
const UnicodeString& expPat,
|
2002-05-21 23:53:07 +00:00
|
|
|
const char** expStrings);
|
2003-05-14 22:30:21 +00:00
|
|
|
void expectRange(const UnicodeString& label,
|
|
|
|
const UnicodeSet& set,
|
|
|
|
UChar32 start, UChar32 end);
|
2000-08-14 21:42:36 +00:00
|
|
|
void doAssert(UBool, const char*);
|
2000-05-25 19:28:53 +00:00
|
|
|
public:
|
1999-10-20 22:08:09 +00:00
|
|
|
static UnicodeString escape(const UnicodeString& s);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|