ICU-3517 remove UnicodeFilterLogic

X-SVN-Rev: 14586
This commit is contained in:
Alan Liu 2004-02-25 20:06:34 +00:00
parent b84b8a15a9
commit 103b71eed3
5 changed files with 0 additions and 627 deletions

View File

@ -13,7 +13,6 @@
#if !UCONFIG_NO_TRANSLITERATION
#include "unicode/unifilt.h"
#include "unicode/unifltlg.h"
#include "unicode/uniset.h"
#include "cpdtrans.h"
#include "uvector.h"

View File

@ -1,111 +0,0 @@
/*
**********************************************************************
* Copyright (C) 1999-2003, International Business Machines Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
* 11/17/99 aliu Creation.
**********************************************************************
*/
//////////////////////////////////////////////////////////////
//
// NOTICE - Do not use
//
// This entire file has been marked obsolete as of ICU 2.4.
// This will be removed as of ICU 2.8. Use UnicodeSet methods instead.
//
//////////////////////////////////////////////////////////////
#ifndef UNIFLTLG_H
#define UNIFLTLG_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_TRANSLITERATION && defined(U_USE_UNICODE_FILTER_LOGIC_OBSOLETE_2_8)
#include "unicode/uobject.h"
U_NAMESPACE_BEGIN
class UnicodeFilter;
/**
* <code>UnicodeFilterLogic</code> provides logical operators on
* {@link UnicodeFilter} objects. This class cannot be instantiated;
* it consists only of static methods. The static methods return
* filter objects that perform logical inversion (<tt>not</tt>),
* intersection (<tt>and</tt>), or union (<tt>or</tt>) of the given
* filter objects.
*
* If a UnicodeFilter* f is passed in, where f == NULL, then that
* is treated as a filter that contains all Unicode characters.
* Therefore, createNot(NULL) returns a filter that contains no
* Unicode characters. Likewise, createAnd(g, NULL) returns g->clone(),
* and createAnd(NULL, NULL) returns NULL.
*
* @obsolete ICU 2.8. Use UnicodeSet methods instead since this class will be removed in that release.
*/
class U_I18N_API UnicodeFilterLogic /* not : public UObject because all methods are static */ {
public:
/**
* Returns a <tt>UnicodeFilter</tt> that implements the inverse of
* the given filter.
* @param f may be NULL
* @result always non-NULL
* @obsolete ICU 2.8. Use UnicodeSet methods instead since this class will be removed in that release.
*/
static UnicodeFilter* createNot(const UnicodeFilter* f);
/**
* Returns a <tt>UnicodeFilter</tt> that implements a short
* circuit AND of the result of the two given filters. That is,
* if <tt>f.contains()</tt> is <tt>false</tt>, then <tt>g.contains()</tt>
* is not called, and <tt>contains()</tt> returns <tt>false</tt>.
* @param f may be NULL
* @param g may be NULL
* @result will be NULL if and only if f == g == NULL
* @obsolete ICU 2.8. Use UnicodeSet methods instead since this class will be removed in that release.
*/
static UnicodeFilter* createAnd(const UnicodeFilter* f,
const UnicodeFilter* g);
/**
* Returns a <tt>UnicodeFilter</tt> that implements a short
* circuit AND of the result of the two given filters. That is,
* if <tt>f.contains()</tt> is <tt>false</tt>, then <tt>g.contains()</tt>
* is not called, and <tt>contains()</tt> returns <tt>false</tt>.
* @param adoptedF may be NULL; this argument is adopted
* @param adoptedG may be NULL; this argument is adopted
* @result will be NULL if and only if f == g == NULL
* @obsolete ICU 2.8. Use UnicodeSet methods instead since this class will be removed in that release.
*/
static UnicodeFilter* createAdoptingAnd(UnicodeFilter* adoptedF,
UnicodeFilter* adoptedG);
/**
* Returns a <tt>UnicodeFilter</tt> that implements a short
* circuit OR of the result of the two given filters. That is, if
* <tt>f.contains()</tt> is <tt>true</tt>, then <tt>g.contains()</tt> is
* not called, and <tt>contains()</tt> returns <tt>true</tt>.
* @param f may be NULL
* @param g may be NULL
* @result will be NULL if and only if f == g == NULL
* @obsolete ICU 2.8. Use UnicodeSet methods instead since this class will be removed in that release.
*/
static UnicodeFilter* createOr(const UnicodeFilter* f,
const UnicodeFilter* g);
private:
// Disallow instantiation
UnicodeFilterLogic();
};
inline UnicodeFilterLogic::UnicodeFilterLogic() {}
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_TRANSLITERATION */
#endif

View File

@ -1,200 +0,0 @@
/*
**********************************************************************
* Copyright (C) 1999-2003, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Date Name Description
* 11/17/99 aliu Creation.
**********************************************************************
*/
//////////////////////////////////////////////////////////////
//
// NOTICE - Do not use
//
// This entire file has been deprecated as of ICU 2.4.
//
//////////////////////////////////////////////////////////////
#include "unicode/utypes.h"
#if !UCONFIG_NO_TRANSLITERATION && defined(U_USE_UNICODE_FILTER_LOGIC_OBSOLETE_2_8)
#include "unicode/unifltlg.h"
#include "unicode/unifilt.h"
U_NAMESPACE_BEGIN
/**
* This class stubs out UnicodeMatcher API that we don't implement.
*/
class _UF: public UnicodeFilter {
// Stubs
virtual UnicodeString& toPattern(UnicodeString& result,
UBool escapeUnprintable) const {
return result;
}
virtual UBool matchesIndexValue(uint8_t v) const {
return FALSE;
}
virtual void addMatchSetTo(UnicodeSet& toUnionTo) const {}
};
/**
* A NullFilter always returns a fixed value, either TRUE or FALSE.
* A filter value of 0 (that is, a UnicodeFilter* f, where f == 0)
* is equivalent to a NullFilter(TRUE).
*/
static const char gNullFilterClassID = 0;
class NullFilter : public _UF {
UBool result;
public:
virtual UClassID getDynamicClassID() const { return getStaticClassID(); }
static inline UClassID getStaticClassID() { return (UClassID)&gNullFilterClassID; }
NullFilter(UBool r) { result = r; }
NullFilter(const NullFilter& f) : _UF(f) { result = f.result; }
virtual ~NullFilter() {}
virtual UBool contains(UChar32 /*c*/) const { return result; }
virtual UnicodeFunctor* clone() const { return new NullFilter(*this); }
};
static const char gUnicodeNotFilterClassID = 0;
class UnicodeNotFilter : public _UF {
UnicodeFilter* filt;
public:
virtual UClassID getDynamicClassID() const { return getStaticClassID(); }
static inline UClassID getStaticClassID() { return (UClassID)&gUnicodeNotFilterClassID; }
UnicodeNotFilter(UnicodeFilter* adopted);
UnicodeNotFilter(const UnicodeNotFilter&);
virtual ~UnicodeNotFilter();
virtual UBool contains(UChar32 c) const;
virtual UnicodeFunctor* clone() const;
};
UnicodeNotFilter::UnicodeNotFilter(UnicodeFilter* adopted) : filt(adopted) {}
UnicodeNotFilter::UnicodeNotFilter(const UnicodeNotFilter& f)
: _UF(f), filt((UnicodeFilter*) f.filt->clone()) {}
UnicodeNotFilter::~UnicodeNotFilter() { delete filt; }
UBool UnicodeNotFilter::contains(UChar32 c) const { return !filt->contains(c); }
UnicodeFunctor* UnicodeNotFilter::clone() const { return new UnicodeNotFilter(*this); }
/**
* Returns a <tt>UnicodeFilter</tt> that implements the inverse of
* the given filter.
*/
UnicodeFilter* UnicodeFilterLogic::createNot(const UnicodeFilter* f) {
if (f == 0) {
return new NullFilter(FALSE);
} else {
return new UnicodeNotFilter((UnicodeFilter*)f->clone());
}
}
static const char gUnicodeAndFilterClassID = 0;
class UnicodeAndFilter : public _UF {
UnicodeFilter* filt1;
UnicodeFilter* filt2;
public:
virtual UClassID getDynamicClassID() const { return getStaticClassID(); }
static inline UClassID getStaticClassID() { return (UClassID)&gUnicodeAndFilterClassID; }
UnicodeAndFilter(UnicodeFilter* adopted1, UnicodeFilter* adopted2);
UnicodeAndFilter(const UnicodeAndFilter&);
virtual ~UnicodeAndFilter();
virtual UBool contains(UChar32 c) const;
virtual UnicodeFunctor* clone() const;
};
UnicodeAndFilter::UnicodeAndFilter(UnicodeFilter* f1, UnicodeFilter* f2) : filt1(f1), filt2(f2) {}
UnicodeAndFilter::UnicodeAndFilter(const UnicodeAndFilter& f)
: _UF(f), filt1((UnicodeFilter*)f.filt1->clone()), filt2((UnicodeFilter*)f.filt2->clone()) {}
UnicodeAndFilter::~UnicodeAndFilter() { delete filt1; delete filt2; }
UBool UnicodeAndFilter::contains(UChar32 c) const { return filt1->contains(c) && filt2->contains(c); }
UnicodeFunctor* UnicodeAndFilter::clone() const { return new UnicodeAndFilter(*this); }
/**
* Returns a <tt>UnicodeFilter</tt> that implements a short
* circuit AND of the result of the two given filters. That is,
* if <tt>f.contains()</tt> is <tt>false</tt>, then <tt>g.contains()</tt>
* is not called, and <tt>contains()</tt> returns <tt>false</tt>.
*/
UnicodeFilter* UnicodeFilterLogic::createAnd(const UnicodeFilter* f,
const UnicodeFilter* g) {
if (f == 0) {
if (g == 0) {
return NULL;
}
return (UnicodeFilter*)g->clone();
}
if (g == 0) {
return (UnicodeFilter*)f->clone();
}
return new UnicodeAndFilter((UnicodeFilter*)f->clone(), (UnicodeFilter*)g->clone());
}
/**
* Returns a <tt>UnicodeFilter</tt> that implements a short
* circuit AND of the result of the two given filters. That is,
* if <tt>f.contains()</tt> is <tt>false</tt>, then <tt>g.contains()</tt>
* is not called, and <tt>contains()</tt> returns <tt>false</tt>.
*
* ADOPTS both arguments.
*/
UnicodeFilter* UnicodeFilterLogic::createAdoptingAnd(UnicodeFilter* f,
UnicodeFilter* g) {
if (f == 0) {
if (g == 0) {
return NULL;
}
return g;
}
if (g == 0) {
return f;
}
return new UnicodeAndFilter(f, g);
}
static const char gUnicodeOrFilterClassID = 0;
class UnicodeOrFilter : public _UF {
UnicodeFilter* filt1;
UnicodeFilter* filt2;
public:
virtual UClassID getDynamicClassID() const { return getStaticClassID(); }
static inline UClassID getStaticClassID() { return (UClassID)&gUnicodeOrFilterClassID; }
UnicodeOrFilter(UnicodeFilter* adopted1, UnicodeFilter* adopted2);
UnicodeOrFilter(const UnicodeOrFilter&);
virtual ~UnicodeOrFilter();
virtual UBool contains(UChar32 c) const;
virtual UnicodeFunctor* clone() const;
};
UnicodeOrFilter::UnicodeOrFilter(UnicodeFilter* f1, UnicodeFilter* f2) : filt1(f1), filt2(f2) {}
UnicodeOrFilter::UnicodeOrFilter(const UnicodeOrFilter& f)
: _UF(f), filt1((UnicodeFilter*)f.filt1->clone()), filt2((UnicodeFilter*)f.filt2->clone()) {}
UnicodeOrFilter::~UnicodeOrFilter() { delete filt1; delete filt2; }
UBool UnicodeOrFilter::contains(UChar32 c) const { return filt1->contains(c) || filt2->contains(c); }
UnicodeFunctor* UnicodeOrFilter::clone() const { return new UnicodeOrFilter(*this); }
/**
* Returns a <tt>UnicodeFilter</tt> that implements a short
* circuit OR of the result of the two given filters. That is, if
* <tt>f.contains()</tt> is <tt>true</tt>, then <tt>g.contains()</tt> is
* not called, and <tt>contains()</tt> returns <tt>true</tt>.
*/
UnicodeFilter* UnicodeFilterLogic::createOr(const UnicodeFilter* f,
const UnicodeFilter* g) {
if (f == 0) {
if (g == 0) {
return NULL;
}
return (UnicodeFilter*)g->clone();
}
if (g == 0) {
return (UnicodeFilter*)f->clone();
}
return new UnicodeOrFilter((UnicodeFilter*)f->clone(), (UnicodeFilter*)g->clone());
}
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_TRANSLITERATION */

View File

@ -1,247 +0,0 @@
/***************************************************************************
*
* Copyright (C) 2000-2003, International Business Machines
* Corporation and others. All Rights Reserved.
*
***************************************************************************************************************************************************
* Date Name Description
* 03/22/2000 Madhu Creation.
************************************************************************/
#include "unicode/utypes.h"
#if !UCONFIG_NO_TRANSLITERATION && defined(U_USE_UNICODE_FILTER_LOGIC_OBSOLETE_2_8)
#include "unicode/translit.h"
#include "unicode/unifilt.h"
#include "unicode/unifltlg.h"
#include "intltest.h"
#include "ittrans.h"
#include "ufltlgts.h"
//---------------------------------------------
// runIndexedTest
//---------------------------------------------
void UnicodeFilterLogicTest::runIndexedTest( int32_t index, UBool exec, const char* &name, char* /*par*/ )
{
if (exec) logln((UnicodeString)"TestSuite UnicodeFilterLogic API ");
switch (index) {
case 0: name = "TestAll"; if (exec) TestAll(); break;
default: name = ""; break; /*needed to end loop*/
}
}
int32_t gFilter1ClassID;
class Filter1: public UnicodeFilter{
virtual UClassID getDynamicClassID() const { return (UClassID)&gFilter1ClassID; }
virtual UnicodeFunctor* clone() const{
return new Filter1(*this);
}
virtual UBool contains(UChar32 c) const {
if(c == 0x0061 || c == 0x0041 || c == 0x0063 || c == 0x0043)
return FALSE;
else
return TRUE;
}
// Stubs
virtual UnicodeString& toPattern(UnicodeString& result,
UBool /*escapeUnprintable*/) const {
return result;
}
virtual UBool matchesIndexValue(uint8_t /*v*/) const {
return FALSE;
}
virtual void addMatchSetTo(UnicodeSet& /*toUnionTo*/) const {}
};
uint32_t gFilter2ClassID = 0;
class Filter2: public UnicodeFilter{
virtual UClassID getDynamicClassID() const { return (UClassID)&gFilter2ClassID; }
virtual UnicodeFunctor* clone() const{
return new Filter2(*this);
}
virtual UBool contains(UChar32 c) const {
if(c == 0x0079 || c == 0x0059 || c == 0x007a || c == 0x005a || c == 0x0061 || c == 0x0063)
return FALSE;
else
return TRUE;
}
// Stubs
virtual UnicodeString& toPattern(UnicodeString& result,
UBool /*escapeUnprintable*/) const {
return result;
}
virtual UBool matchesIndexValue(uint8_t /*v*/) const {
return FALSE;
}
virtual void addMatchSetTo(UnicodeSet& /*toUnionTo*/) const {}
};
void UnicodeFilterLogicTest::TestAll(){
UParseError parseError;
UErrorCode status = U_ZERO_ERROR;
Transliterator *t1=Transliterator::createInstance("Any-Hex", UTRANS_FORWARD, parseError, status);
if(t1 == 0){
errln("FAIL: Error in instantiation.");
return;
}
UnicodeString source("abcdABCDyzYZ");
Filter1 filter1;
Filter2 filter2;
//sanity testing wihtout any filter
expect(*t1, "without any Filter", source, UnicodeString("\\u0061\\u0062\\u0063\\u0064\\u0041\\u0042\\u0043\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
//sanity testing using the Filter1(acAC) and Filter2(acyzYZ)
t1->adoptFilter(new Filter1);
expect(*t1, "with Filter(acAC)", source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
t1->adoptFilter(new Filter2);
expect(*t1, "with Filter2(acyzYZ)", source, UnicodeString("a\\u0062c\\u0064\\u0041\\u0042\\u0043\\u0044yzYZ", ""));
UnicodeFilter *filterNOT=UnicodeFilterLogic::createNot(&filter1);
UnicodeFilter *filterAND=UnicodeFilterLogic::createAnd(&filter1, &filter2);
UnicodeFilter *filterOR=UnicodeFilterLogic::createOr(&filter1, &filter2);
TestNOT(*t1, &filter1, "Filter(acAC)",
source, UnicodeString("\\u0061b\\u0063d\\u0041B\\u0043DyzYZ", ""));
TestNOT(*t1, &filter2, "Filter(acyzYZ)",
source, UnicodeString("\\u0061b\\u0063dABCD\\u0079\\u007A\\u0059\\u005A", ""));
TestNOT(*t1, NULL, "NULL",
source, UnicodeString("abcdABCDyzYZ", ""));
TestNOT(*t1, filterNOT, "FilterNOT(Fitler1(acAC))",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestNOT(*t1, filterAND, "FilterAND(Fitler1(acAC), Filter2(acyzYZ))",
source, UnicodeString("\\u0061b\\u0063d\\u0041B\\u0043D\\u0079\\u007A\\u0059\\u005A", ""));
TestNOT(*t1, filterOR, "FilterOR(Fitler1(acAC), Filter2(acyzYZ))",
source, UnicodeString("\\u0061b\\u0063dABCDyzYZ", ""));
TestAND(*t1, &filter1, &filter2, "Filter1(a,c,A,C), Filter2(acyzYZ)",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044yzYZ", ""));
TestAND(*t1, &filter2, &filter1, "Filter2(acyzYZ), Filter1(a,c,A,C), ",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044yzYZ", ""));
TestAND(*t1, &filter1, NULL, "Filter1(a,c,A,C), NULL",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestAND(*t1, NULL, &filter2, "NULL, Filter2(acyzYZ)",
source, UnicodeString("a\\u0062c\\u0064\\u0041\\u0042\\u0043\\u0044yzYZ", ""));
TestAND(*t1, NULL, NULL, "NULL, NULL",
source, UnicodeString("\\u0061\\u0062\\u0063\\u0064\\u0041\\u0042\\u0043\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestAND(*t1, filterAND, NULL, "FilterAND(Fitler1(acAC), Filter2(acyzYZ)), NULL",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044yzYZ", ""));
TestAND(*t1, filterAND, &filter1, "FilterAND(Fitler1(acAC), Filter2(acyzYZ)), Filter1(acAC)",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044yzYZ", ""));
TestAND(*t1, filterAND, &filter2, "FilterAND(Fitler1(acAC), Filter2(acyzYZ)), Filter2(acyzYZ)",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044yzYZ", ""));
TestAND(*t1, &filter1, filterAND, "Filter1(acAC), FilterAND(Filter1(acAC), Fitler1(acAC))",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044yzYZ", ""));
TestAND(*t1, &filter2, filterAND, "Filter2(acyzYZ), FilterAND(Filter1(acAC), Fitler1(acAC))",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044yzYZ", ""));
TestAND(*t1, filterOR, NULL, "FilterOR(Fitler1(acAC), Filter2(acyzYZ)), NULL",
source, UnicodeString("a\\u0062c\\u0064\\u0041\\u0042\\u0043\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestAND(*t1, filterOR, &filter1, "FilterOR(Fitler1(acAC), Filter2(acyzYZ)), Fitler1(acAC)",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestAND(*t1, filterOR, &filter2, "FilterOR(Fitler1(acAC), Filter2(acyzYZ)), Fitler2(acyzYZ)",
source, UnicodeString("a\\u0062c\\u0064\\u0041\\u0042\\u0043\\u0044yzYZ", ""));
TestAND(*t1, filterNOT, &filter1, "FilterNOT(Fitler1(acAC)), Fitler1(acAC)",
source, UnicodeString("abcdABCDyzYZ", ""));
TestAND(*t1, &filter1, filterNOT, "Fitler1(acAC), FilterNOT(Fitler1(acAC))",
source, UnicodeString("abcdABCDyzYZ", ""));
TestAND(*t1, filterNOT, &filter2, "FilterNOT(Fitler1(acAC)), Fitler2(acyzYZ)",
source, UnicodeString("abcd\\u0041B\\u0043DyzYZ", ""));
TestAND(*t1, &filter2, filterNOT, "Fitler2(acyzYZ), FilterNOT(Fitler1(acAC))",
source, UnicodeString("abcd\\u0041B\\u0043DyzYZ", ""));
TestOR(*t1, &filter1, &filter2, "Filter1(a,c,A,C), Filter2(acyzYZ)",
source, UnicodeString("a\\u0062c\\u0064\\u0041\\u0042\\u0043\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestOR(*t1, &filter2, &filter1, "Filter2(acyzYZ), Filter1(a,c,A,C)",
source, UnicodeString("a\\u0062c\\u0064\\u0041\\u0042\\u0043\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestOR(*t1, &filter1, NULL, "Filter1(a,c,A,C), NULL",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestOR(*t1, NULL, &filter2, "NULL, Filter2(acyzYZ)",
source, UnicodeString("a\\u0062c\\u0064\\u0041\\u0042\\u0043\\u0044yzYZ", ""));
TestOR(*t1, NULL, NULL, "NULL, NULL",
source, UnicodeString("\\u0061\\u0062\\u0063\\u0064\\u0041\\u0042\\u0043\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestOR(*t1, filterAND, NULL, "FilterAND(Fitler1(acAC), Filter2(acyzYZ)), NULL",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044yzYZ", ""));
TestOR(*t1, filterAND, &filter1, "FilterAND(Fitler1(acAC), Filter2(acyzYZ)), Filter1(acAC)",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestOR(*t1, filterAND, &filter2, "FilterAND(Fitler1(acAC), Filter2(acyzYZ)), Filter2(acyzYZ)",
source, UnicodeString("a\\u0062c\\u0064\\u0041\\u0042\\u0043\\u0044yzYZ", ""));
TestOR(*t1, &filter1, filterAND, "Filter1(acAC), FilterAND(Filter1(acAC), Fitler1(acAC))",
source, UnicodeString("a\\u0062c\\u0064A\\u0042C\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestOR(*t1, &filter2, filterAND, "Filter2(acyzYZ), FilterAND(Filter1(acAC), Fitler1(acAC))",
source, UnicodeString("a\\u0062c\\u0064\\u0041\\u0042\\u0043\\u0044yzYZ", ""));
TestOR(*t1, filterNOT, &filter1, "FilterNOT(Fitler1(acAC)), Fitler1(acAC)",
source, UnicodeString("\\u0061\\u0062\\u0063\\u0064\\u0041\\u0042\\u0043\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestOR(*t1, &filter1, filterNOT, "Fitler1(acAC), FilterNOT(Fitler1(acAC))",
source, UnicodeString("\\u0061\\u0062\\u0063\\u0064\\u0041\\u0042\\u0043\\u0044\\u0079\\u007A\\u0059\\u005A", ""));
TestOR(*t1, filterNOT, &filter2, "FilterNOT(Fitler1(acAC)), Fitler1(acyzYZ)",
source, UnicodeString("\\u0061\\u0062\\u0063\\u0064\\u0041\\u0042\\u0043\\u0044yzYZ", ""));
TestOR(*t1, &filter2, filterNOT, "Fitler2(acyzYZ), FilterNOT(Fitler1(acAC))",
source, UnicodeString("\\u0061\\u0062\\u0063\\u0064\\u0041\\u0042\\u0043\\u0044yzYZ", ""));
delete filterNOT;
delete filterAND;
delete filterOR;
delete t1;
}
void UnicodeFilterLogicTest::TestNOT(Transliterator& t,
const UnicodeFilter* f1,
const UnicodeString& message,
const UnicodeString& source,
const UnicodeString& expected){
UnicodeFilter *filter=UnicodeFilterLogic::createNot(f1);
t.adoptFilter(filter);
expect(t, "with FilterNOT(" + message + ")", source, expected);
}
void UnicodeFilterLogicTest::TestAND(Transliterator& t,
const UnicodeFilter* f1,
const UnicodeFilter* f2,
const UnicodeString& message,
const UnicodeString& source,
const UnicodeString& expected){
UnicodeFilter *filter=UnicodeFilterLogic::createAnd(f1, f2);
t.adoptFilter(filter);
expect(t, "with FilterAND(" + message + ")", source, expected);
}
void UnicodeFilterLogicTest::TestOR(Transliterator& t,
const UnicodeFilter* f1,
const UnicodeFilter* f2,
const UnicodeString& message,
const UnicodeString& source,
const UnicodeString& expected){
UnicodeFilter *filter=UnicodeFilterLogic::createOr(f1, f2);
t.adoptFilter(filter);
expect(t, "with FilterOR(" + message + ")", source, expected);
}
void UnicodeFilterLogicTest::expect(const Transliterator& t,
const UnicodeString& message,
const UnicodeString& source,
const UnicodeString& expectedResult) {
UnicodeString rsource(source);
t.transliterate(rsource);
expectAux(t.getID() + ":Replaceable " + message, source + "->" + rsource, rsource==expectedResult, expectedResult);
}
void UnicodeFilterLogicTest::expectAux(const UnicodeString& tag,
const UnicodeString& summary, UBool pass,
const UnicodeString& expectedResult) {
if (pass) {
logln(UnicodeString("(")+tag+") " + prettify(summary));
} else {
errln(UnicodeString("FAIL: (")+tag+") "
+ prettify(summary)
+ ", expected " + prettify(expectedResult));
}
}
#endif /* #if !UCONFIG_NO_TRANSLITERATION */

View File

@ -1,68 +0,0 @@
/********************************************************************
* COPYRIGHT:
* Copyright (c) 1997-2001, International Business Machines Corporation and
* others. All Rights Reserved.
********************************************************************
************************************************************************
* Date Name Description
* 03/22/2000 Madhu Creation.
************************************************************************/
#ifndef UNIFLTLOGICTST_H
#define UNIFLTLOGICTST_H
#include "unicode/utypes.h"
#if !UCONFIG_NO_TRANSLITERATION
#include "unicode/translit.h"
#include "unicode/unifltlg.h"
#include "intltest.h"
/**
* @test
* @summary General test of UnicodeFilterLogic API
*/
class UnicodeFilterLogicTest : public IntlTest {
public:
void runIndexedTest(int32_t index, UBool exec, const char* &name, char* par=NULL);
/*Tests all the NOT, OR and AND filters */
void TestAll(void);
void TestNOT(Transliterator& t,
const UnicodeFilter* f1,
const UnicodeString& message,
const UnicodeString& source,
const UnicodeString& expected);
void TestAND(Transliterator& t,
const UnicodeFilter* f1,
const UnicodeFilter* f2,
const UnicodeString& message,
const UnicodeString& source,
const UnicodeString& expected);
void TestOR(Transliterator& t,
const UnicodeFilter* f1,
const UnicodeFilter* f2,
const UnicodeString& message,
const UnicodeString& source,
const UnicodeString& expected);
//support functions
void expect(const Transliterator& t,
const UnicodeString& message,
const UnicodeString& source,
const UnicodeString& expectedResult);
void expectAux(const UnicodeString& tag,
const UnicodeString& summary, UBool pass,
const UnicodeString& expectedResult);
};
#endif /* #if !UCONFIG_NO_TRANSLITERATION */
#endif