1999-10-26 17:16:13 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2000-03-28 23:51:25 +00:00
|
|
|
* Copyright (C) 1999 Alan Liu and 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
|
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/utypes.h"
|
1999-10-20 22:08:09 +00:00
|
|
|
#include "intltest.h"
|
|
|
|
|
|
|
|
class UnicodeSet;
|
|
|
|
class UnicodeString;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* UnicodeSet test
|
|
|
|
*/
|
|
|
|
class UnicodeSetTest: public IntlTest {
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
void runIndexedTest(int32_t index, UBool exec, char* &name, char* par=NULL);
|
1999-10-20 22:08:09 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
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-03-28 23:51:25 +00:00
|
|
|
void TestCloneEqualHash(void);
|
|
|
|
|
2000-05-25 19:28:53 +00:00
|
|
|
/**
|
|
|
|
* Make sure minimal representation is maintained.
|
|
|
|
*/
|
|
|
|
void TestMinimalRep(void);
|
|
|
|
|
|
|
|
void TestAPI(void);
|
|
|
|
|
|
|
|
void TestExhaustive(void);
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
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.
|
|
|
|
*/
|
2000-05-25 20:57:30 +00:00
|
|
|
static void 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
|
|
|
|
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);
|
2000-05-25 19:28:53 +00:00
|
|
|
void doAssert(UBool, const char*);
|
|
|
|
public:
|
1999-10-20 22:08:09 +00:00
|
|
|
static UnicodeString escape(const UnicodeString& s);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|