1999-11-20 01:29:05 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2005-06-09 17:30:48 +00:00
|
|
|
* Copyright (C) 1999-2005, International Business Machines
|
1999-11-20 01:29:05 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 11/10/99 aliu Creation.
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
|
|
|
#ifndef TRANSTST_H
|
|
|
|
#define TRANSTST_H
|
|
|
|
|
2002-09-21 00:43:14 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_TRANSLITERATION
|
|
|
|
|
2001-07-25 19:11:02 +00:00
|
|
|
#include "unicode/translit.h"
|
1999-11-20 01:29:05 +00:00
|
|
|
#include "intltest.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @summary General test of Transliterator
|
|
|
|
*/
|
|
|
|
class TransliteratorTest : public IntlTest {
|
|
|
|
|
2001-12-28 21:26:53 +00:00
|
|
|
public:
|
|
|
|
TransliteratorTest();
|
2003-08-29 15:57:38 +00:00
|
|
|
virtual ~TransliteratorTest();
|
2001-12-28 21:26:53 +00:00
|
|
|
|
|
|
|
private:
|
2000-08-14 21:42:36 +00:00
|
|
|
void runIndexedTest(int32_t index, UBool exec, const char* &name,
|
1999-11-20 01:29:05 +00:00
|
|
|
char* par=NULL);
|
|
|
|
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestInstantiation(void);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestSimpleRules(void);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
2000-01-13 07:29:20 +00:00
|
|
|
void TestInlineSet(void);
|
|
|
|
|
2000-08-30 20:43:25 +00:00
|
|
|
void TestAnchors(void);
|
|
|
|
|
2000-01-13 07:29:20 +00:00
|
|
|
void TestPatternQuoting(void);
|
|
|
|
|
1999-11-20 01:29:05 +00:00
|
|
|
/**
|
|
|
|
* Create some inverses and confirm that they work. We have to be
|
|
|
|
* careful how we do this, since the inverses will not be true
|
|
|
|
* inverses -- we can't throw any random string at the composition
|
|
|
|
* of the transliterators and expect the identity function. F x
|
|
|
|
* F' != I. However, if we are careful about the input, we will
|
|
|
|
* get the expected results.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestRuleBasedInverse(void);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Basic test of keyboard.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestKeyboard(void);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Basic test of keyboard with cursor.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestKeyboard2(void);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test keyboard transliteration with back-replacement.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestKeyboard3(void);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
|
|
|
void keyboardAux(const Transliterator& t,
|
|
|
|
const char* DATA[], int32_t DATA_length);
|
|
|
|
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestArabic(void);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compose the Kana transliterator forward and reverse and try
|
|
|
|
* some strings that should come out unchanged.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestCompoundKana(void);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Compose the hex transliterators forward and reverse.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestCompoundHex(void);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Do some basic tests of filtering.
|
|
|
|
*/
|
1999-12-22 22:57:04 +00:00
|
|
|
void TestFiltering(void);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
2000-02-12 01:23:13 +00:00
|
|
|
/**
|
|
|
|
* Regression test for bugs found in Greek transliteration.
|
|
|
|
*/
|
|
|
|
void TestJ277(void);
|
|
|
|
|
2000-03-08 19:26:17 +00:00
|
|
|
/**
|
|
|
|
* Prefix, suffix support in hex transliterators.
|
|
|
|
*/
|
|
|
|
void TestJ243(void);
|
|
|
|
|
2000-03-18 01:42:45 +00:00
|
|
|
/**
|
|
|
|
* Parsers need better syntax error messages.
|
|
|
|
*/
|
|
|
|
void TestJ329(void);
|
|
|
|
|
2000-05-20 04:40:29 +00:00
|
|
|
/**
|
|
|
|
* Test segments and segment references.
|
|
|
|
*/
|
2000-05-24 17:32:49 +00:00
|
|
|
void TestSegments(void);
|
2000-05-20 04:40:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test cursor positioning outside of the key
|
|
|
|
*/
|
2000-05-24 17:32:49 +00:00
|
|
|
void TestCursorOffset(void);
|
2000-05-20 04:40:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test zero length and > 1 char length variable values. Test
|
|
|
|
* use of variable refs in UnicodeSets.
|
|
|
|
*/
|
2000-05-24 17:32:49 +00:00
|
|
|
void TestArbitraryVariableValues(void);
|
2000-05-20 04:40:29 +00:00
|
|
|
|
2000-06-29 22:15:17 +00:00
|
|
|
/**
|
|
|
|
* Confirm that the contextStart, contextLimit, start, and limit
|
|
|
|
* behave correctly. J474.
|
|
|
|
*/
|
|
|
|
void TestPositionHandling(void);
|
|
|
|
|
2000-06-30 00:15:44 +00:00
|
|
|
/**
|
|
|
|
* Test the Hiragana-Katakana transliterator.
|
|
|
|
*/
|
|
|
|
void TestHiraganaKatakana(void);
|
|
|
|
|
2000-06-30 23:26:07 +00:00
|
|
|
/**
|
|
|
|
* Test cloning / copy constructor of RBT.
|
|
|
|
*/
|
|
|
|
void TestCopyJ476(void);
|
2000-06-30 00:15:44 +00:00
|
|
|
|
2001-03-03 00:49:45 +00:00
|
|
|
/**
|
|
|
|
* Test inter-Indic transliterators. These are composed.
|
|
|
|
* ICU4C Jitterbug 483.
|
|
|
|
*/
|
|
|
|
void TestInterIndic(void);
|
|
|
|
|
2001-03-31 01:21:38 +00:00
|
|
|
/**
|
|
|
|
* Test filter syntax in IDs. (J918)
|
|
|
|
*/
|
|
|
|
void TestFilterIDs(void);
|
|
|
|
|
2001-06-11 19:56:35 +00:00
|
|
|
/**
|
|
|
|
* Test the case mapping transliterators.
|
|
|
|
*/
|
|
|
|
void TestCaseMap(void);
|
|
|
|
|
2001-06-11 23:44:50 +00:00
|
|
|
/**
|
|
|
|
* Test the name mapping transliterators.
|
|
|
|
*/
|
|
|
|
void TestNameMap(void);
|
|
|
|
|
2001-06-20 22:38:21 +00:00
|
|
|
/**
|
|
|
|
* Test liberalized ID syntax. 1006c
|
|
|
|
*/
|
|
|
|
void TestLiberalizedID(void);
|
2001-06-22 17:13:33 +00:00
|
|
|
/**
|
|
|
|
* Test Jitterbug 912
|
|
|
|
*/
|
|
|
|
void TestCreateInstance(void);
|
2001-06-20 22:38:21 +00:00
|
|
|
|
2001-07-03 23:45:23 +00:00
|
|
|
void TestNormalizationTransliterator(void);
|
|
|
|
|
2001-07-13 21:09:41 +00:00
|
|
|
void TestCompoundRBT(void);
|
|
|
|
|
2001-07-17 00:16:02 +00:00
|
|
|
void TestCompoundFilter(void);
|
|
|
|
|
2001-07-17 23:37:45 +00:00
|
|
|
void TestRemove(void);
|
|
|
|
|
2001-07-18 04:17:05 +00:00
|
|
|
void TestToRules(void);
|
|
|
|
|
2001-07-25 19:11:02 +00:00
|
|
|
void TestContext(void);
|
|
|
|
|
|
|
|
void TestSupplemental(void);
|
|
|
|
|
2001-07-27 00:18:53 +00:00
|
|
|
void TestQuantifier(void);
|
|
|
|
|
2001-08-01 17:37:08 +00:00
|
|
|
/**
|
|
|
|
* Test Source-Target/Variant.
|
|
|
|
*/
|
|
|
|
void TestSTV(void);
|
|
|
|
|
2001-08-17 17:22:26 +00:00
|
|
|
void TestCompoundInverse(void);
|
|
|
|
|
2001-10-04 23:59:56 +00:00
|
|
|
void TestNFDChainRBT(void);
|
|
|
|
|
2001-10-05 22:27:44 +00:00
|
|
|
/**
|
|
|
|
* Inverse of "Null" should be "Null". (J21)
|
|
|
|
*/
|
|
|
|
void TestNullInverse(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check ID of inverse of alias. (J22)
|
|
|
|
*/
|
|
|
|
void TestAliasInverseID(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test IDs of inverses of compound transliterators. (J20)
|
|
|
|
*/
|
|
|
|
void TestCompoundInverseID(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test undefined variable.
|
|
|
|
*/
|
|
|
|
void TestUndefinedVariable(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test empty context.
|
|
|
|
*/
|
|
|
|
void TestEmptyContext(void);
|
|
|
|
|
2001-10-10 19:22:34 +00:00
|
|
|
/**
|
|
|
|
* Test compound filter ID syntax
|
|
|
|
*/
|
|
|
|
void TestCompoundFilterID(void);
|
|
|
|
|
2001-10-17 19:21:12 +00:00
|
|
|
/**
|
|
|
|
* Test new property set syntax
|
|
|
|
*/
|
|
|
|
void TestPropertySet(void);
|
|
|
|
|
2001-10-25 00:03:50 +00:00
|
|
|
/**
|
|
|
|
* Test various failure points of the new 2.0 engine.
|
|
|
|
*/
|
|
|
|
void TestNewEngine(void);
|
|
|
|
|
2001-10-30 18:14:57 +00:00
|
|
|
/**
|
|
|
|
* Test quantified segment behavior. We want:
|
|
|
|
* ([abc])+ > x $1 x; applied to "cba" produces "xax"
|
|
|
|
*/
|
|
|
|
void TestQuantifiedSegment(void);
|
2001-10-31 00:29:42 +00:00
|
|
|
|
2001-10-11 04:06:16 +00:00
|
|
|
/* Devanagari-Latin rules Test */
|
|
|
|
void TestDevanagariLatinRT(void);
|
|
|
|
|
|
|
|
/* Telugu-Latin rules Test */
|
|
|
|
void TestTeluguLatinRT(void);
|
|
|
|
|
|
|
|
/* Gujarati-Latin rules Test */
|
|
|
|
void TestGujaratiLatinRT(void);
|
|
|
|
|
|
|
|
/* Sanskrit-Latin rules Test */
|
|
|
|
void TestSanskritLatinRT(void);
|
|
|
|
|
|
|
|
/* Test Compound Indic-Latin transliterators*/
|
|
|
|
void TestCompoundLatinRT(void);
|
2001-10-31 00:29:42 +00:00
|
|
|
|
2002-07-29 22:56:05 +00:00
|
|
|
/* Test bindi and tippi for Gurmukhi */
|
|
|
|
void TestGurmukhiDevanagari(void);
|
2001-10-31 00:29:42 +00:00
|
|
|
/**
|
|
|
|
* Test instantiation from a locale.
|
|
|
|
*/
|
|
|
|
void TestLocaleInstantiation(void);
|
2001-10-11 04:06:16 +00:00
|
|
|
|
2001-11-01 04:37:27 +00:00
|
|
|
/**
|
|
|
|
* Test title case handling of accent (should ignore accents)
|
|
|
|
*/
|
|
|
|
void TestTitleAccents(void);
|
|
|
|
|
2001-11-03 02:04:37 +00:00
|
|
|
/**
|
|
|
|
* Basic test of a locale resource based rule.
|
|
|
|
*/
|
|
|
|
void TestLocaleResource(void);
|
|
|
|
|
2001-11-09 00:12:59 +00:00
|
|
|
/**
|
|
|
|
* Make sure parse errors reference the right line.
|
|
|
|
*/
|
2001-11-30 23:53:55 +00:00
|
|
|
void TestParseError(void);
|
2001-11-09 00:12:59 +00:00
|
|
|
|
2001-11-09 01:22:33 +00:00
|
|
|
/**
|
|
|
|
* Make sure sets on output are disallowed.
|
|
|
|
*/
|
2001-11-30 23:53:55 +00:00
|
|
|
void TestOutputSet(void);
|
2001-11-09 01:22:33 +00:00
|
|
|
|
2001-11-12 19:12:08 +00:00
|
|
|
/**
|
|
|
|
* Test the use variable range pragma, making sure that use of
|
|
|
|
* variable range characters is detected and flagged as an error.
|
|
|
|
*/
|
2001-11-30 23:53:55 +00:00
|
|
|
void TestVariableRange(void);
|
2001-11-12 19:12:08 +00:00
|
|
|
|
2001-11-14 19:26:56 +00:00
|
|
|
/**
|
|
|
|
* Test invalid post context error handling
|
|
|
|
*/
|
2001-11-30 23:53:55 +00:00
|
|
|
void TestInvalidPostContext(void);
|
2001-11-14 19:26:56 +00:00
|
|
|
|
2001-11-15 23:40:02 +00:00
|
|
|
/**
|
|
|
|
* Test ID form variants
|
|
|
|
*/
|
2001-11-30 23:53:55 +00:00
|
|
|
void TestIDForms(void);
|
2001-11-15 23:40:02 +00:00
|
|
|
|
2001-11-17 06:44:50 +00:00
|
|
|
/**
|
|
|
|
* Mark's toRules test.
|
|
|
|
*/
|
2001-11-30 23:53:55 +00:00
|
|
|
void TestToRulesMark(void);
|
2001-11-17 06:44:50 +00:00
|
|
|
|
2001-11-21 07:08:13 +00:00
|
|
|
/**
|
|
|
|
* Test Escape and Unescape transliterators.
|
|
|
|
*/
|
2001-11-30 23:53:55 +00:00
|
|
|
void TestEscape(void);
|
2001-11-21 07:08:13 +00:00
|
|
|
|
2001-11-30 23:53:55 +00:00
|
|
|
void TestAnchorMasking(void);
|
2001-11-29 23:49:44 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Make sure display names of variants look reasonable.
|
|
|
|
*/
|
2001-11-30 23:53:55 +00:00
|
|
|
void TestDisplayName(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check to see if case mapping works correctly.
|
|
|
|
*/
|
|
|
|
void TestSpecialCases(void);
|
|
|
|
/**
|
|
|
|
* Check to see that incremental gets at least part way through a reasonable string.
|
|
|
|
*/
|
|
|
|
void TestIncrementalProgress(void);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Check that casing handles surrogates.
|
|
|
|
*/
|
|
|
|
void TestSurrogateCasing (void);
|
2001-11-29 23:49:44 +00:00
|
|
|
|
2002-02-07 01:07:55 +00:00
|
|
|
void TestFunction(void);
|
|
|
|
|
2002-03-29 18:23:03 +00:00
|
|
|
void TestInvalidBackRef(void);
|
|
|
|
|
2002-04-26 21:31:55 +00:00
|
|
|
void TestMulticharStringSet(void);
|
|
|
|
|
2002-04-17 16:38:18 +00:00
|
|
|
void TestUserFunction(void);
|
|
|
|
|
2002-06-07 20:25:56 +00:00
|
|
|
void TestAnyX(void);
|
|
|
|
|
2002-06-28 21:13:54 +00:00
|
|
|
void TestSourceTargetSet(void);
|
|
|
|
|
2002-08-02 21:33:02 +00:00
|
|
|
void TestRuleWhitespace(void);
|
|
|
|
|
2002-10-03 22:47:10 +00:00
|
|
|
void TestAllCodepoints(void);
|
2002-11-27 00:28:20 +00:00
|
|
|
|
|
|
|
void TestBoilerplate(void);
|
|
|
|
|
2003-04-23 00:20:16 +00:00
|
|
|
void TestAlternateSyntax(void);
|
|
|
|
|
2005-06-09 17:30:48 +00:00
|
|
|
void TestBeginEnd(void);
|
|
|
|
|
|
|
|
void TestBeginEndToRules(void);
|
|
|
|
|
1999-11-20 01:29:05 +00:00
|
|
|
//======================================================================
|
|
|
|
// Support methods
|
|
|
|
//======================================================================
|
2001-02-28 19:49:07 +00:00
|
|
|
protected:
|
2001-12-03 23:09:07 +00:00
|
|
|
void expectT(const UnicodeString& id,
|
|
|
|
const UnicodeString& source,
|
|
|
|
const UnicodeString& expectedResult);
|
|
|
|
|
1999-11-20 01:29:05 +00:00
|
|
|
void expect(const UnicodeString& rules,
|
|
|
|
const UnicodeString& source,
|
2001-07-25 19:11:02 +00:00
|
|
|
const UnicodeString& expectedResult,
|
|
|
|
UTransPosition *pos=0);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
2005-06-09 17:30:48 +00:00
|
|
|
void expect(const UnicodeString& id,
|
|
|
|
const UnicodeString& rules,
|
|
|
|
const UnicodeString& source,
|
|
|
|
const UnicodeString& expectedResult,
|
|
|
|
UTransPosition *pos=0);
|
|
|
|
|
1999-11-20 01:29:05 +00:00
|
|
|
void expect(const Transliterator& t,
|
|
|
|
const UnicodeString& source,
|
|
|
|
const UnicodeString& expectedResult,
|
|
|
|
const Transliterator& reverseTransliterator);
|
|
|
|
|
|
|
|
void expect(const Transliterator& t,
|
|
|
|
const UnicodeString& source,
|
2001-07-25 19:11:02 +00:00
|
|
|
const UnicodeString& expectedResult,
|
|
|
|
UTransPosition *pos=0);
|
1999-11-20 01:29:05 +00:00
|
|
|
|
|
|
|
void expectAux(const UnicodeString& tag,
|
|
|
|
const UnicodeString& source,
|
|
|
|
const UnicodeString& result,
|
|
|
|
const UnicodeString& expectedResult);
|
|
|
|
|
2001-02-28 19:49:07 +00:00
|
|
|
virtual void expectAux(const UnicodeString& tag,
|
2000-05-18 22:08:39 +00:00
|
|
|
const UnicodeString& summary, UBool pass,
|
1999-11-20 01:29:05 +00:00
|
|
|
const UnicodeString& expectedResult);
|
2001-07-25 19:11:02 +00:00
|
|
|
|
|
|
|
static UnicodeString& formatInput(UnicodeString &appendTo,
|
|
|
|
const UnicodeString& input,
|
|
|
|
const UTransPosition& pos);
|
2001-11-17 06:44:50 +00:00
|
|
|
|
|
|
|
void checkRules(const UnicodeString& label, Transliterator& t2,
|
|
|
|
const UnicodeString& testRulesForward);
|
2001-12-03 20:50:50 +00:00
|
|
|
void CheckIncrementalAux(const Transliterator* t,
|
2001-11-30 23:53:55 +00:00
|
|
|
const UnicodeString& input);
|
|
|
|
|
2005-06-09 17:30:48 +00:00
|
|
|
void reportParseError(const UnicodeString& message, const UParseError& parseError, const UErrorCode& status);
|
|
|
|
|
2001-12-28 21:26:53 +00:00
|
|
|
|
|
|
|
const UnicodeString DESERET_DEE;
|
|
|
|
const UnicodeString DESERET_dee;
|
|
|
|
|
1999-11-20 01:29:05 +00:00
|
|
|
};
|
|
|
|
|
2002-09-21 00:43:14 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_TRANSLITERATION */
|
|
|
|
|
1999-11-20 01:29:05 +00:00
|
|
|
#endif
|