2 **********************************************************************
3 * Copyright (C) 1999-2011, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 11/10/99 aliu Creation.
8 **********************************************************************
13 #include "unicode/utypes.h"
15 #if !UCONFIG_NO_TRANSLITERATION
17 #include "unicode/translit.h"
22 * @summary General test of Transliterator
24 class TransliteratorTest
: public IntlTest
{
28 virtual ~TransliteratorTest();
31 void runIndexedTest(int32_t index
, UBool exec
, const char* &name
,
34 void TestInstantiation(void);
36 void TestSimpleRules(void);
38 void TestInlineSet(void);
40 void TestAnchors(void);
42 void TestPatternQuoting(void);
45 * Create some inverses and confirm that they work. We have to be
46 * careful how we do this, since the inverses will not be true
47 * inverses -- we can't throw any random string at the composition
48 * of the transliterators and expect the identity function. F x
49 * F' != I. However, if we are careful about the input, we will
50 * get the expected results.
52 void TestRuleBasedInverse(void);
55 * Basic test of keyboard.
57 void TestKeyboard(void);
60 * Basic test of keyboard with cursor.
62 void TestKeyboard2(void);
65 * Test keyboard transliteration with back-replacement.
67 void TestKeyboard3(void);
69 void keyboardAux(const Transliterator
& t
,
70 const char* DATA
[], int32_t DATA_length
);
72 void TestArabic(void);
75 * Compose the Kana transliterator forward and reverse and try
76 * some strings that should come out unchanged.
78 void TestCompoundKana(void);
81 * Compose the hex transliterators forward and reverse.
83 void TestCompoundHex(void);
86 * Do some basic tests of filtering.
88 void TestFiltering(void);
91 * Regression test for bugs found in Greek transliteration.
96 * Prefix, suffix support in hex transliterators.
101 * Parsers need better syntax error messages.
106 * Test segments and segment references.
108 void TestSegments(void);
111 * Test cursor positioning outside of the key
113 void TestCursorOffset(void);
116 * Test zero length and > 1 char length variable values. Test
117 * use of variable refs in UnicodeSets.
119 void TestArbitraryVariableValues(void);
122 * Confirm that the contextStart, contextLimit, start, and limit
123 * behave correctly. J474.
125 void TestPositionHandling(void);
128 * Test the Hiragana-Katakana transliterator.
130 void TestHiraganaKatakana(void);
133 * Test cloning / copy constructor of RBT.
135 void TestCopyJ476(void);
138 * Test inter-Indic transliterators. These are composed.
139 * ICU4C Jitterbug 483.
141 void TestInterIndic(void);
144 * Test filter syntax in IDs. (J918)
146 void TestFilterIDs(void);
149 * Test the case mapping transliterators.
151 void TestCaseMap(void);
154 * Test the name mapping transliterators.
156 void TestNameMap(void);
159 * Test liberalized ID syntax. 1006c
161 void TestLiberalizedID(void);
165 void TestCreateInstance(void);
167 void TestNormalizationTransliterator(void);
169 void TestCompoundRBT(void);
171 void TestCompoundFilter(void);
173 void TestRemove(void);
175 void TestToRules(void);
177 void TestContext(void);
179 void TestSupplemental(void);
181 void TestQuantifier(void);
184 * Test Source-Target/Variant.
188 void TestCompoundInverse(void);
190 void TestNFDChainRBT(void);
193 * Inverse of "Null" should be "Null". (J21)
195 void TestNullInverse(void);
198 * Check ID of inverse of alias. (J22)
200 void TestAliasInverseID(void);
203 * Test IDs of inverses of compound transliterators. (J20)
205 void TestCompoundInverseID(void);
208 * Test undefined variable.
210 void TestUndefinedVariable(void);
213 * Test empty context.
215 void TestEmptyContext(void);
218 * Test compound filter ID syntax
220 void TestCompoundFilterID(void);
223 * Test new property set syntax
225 void TestPropertySet(void);
228 * Test various failure points of the new 2.0 engine.
230 void TestNewEngine(void);
233 * Test quantified segment behavior. We want:
234 * ([abc])+ > x $1 x; applied to "cba" produces "xax"
236 void TestQuantifiedSegment(void);
238 /* Devanagari-Latin rules Test */
239 void TestDevanagariLatinRT(void);
241 /* Telugu-Latin rules Test */
242 void TestTeluguLatinRT(void);
244 /* Gujarati-Latin rules Test */
245 void TestGujaratiLatinRT(void);
247 /* Sanskrit-Latin rules Test */
248 void TestSanskritLatinRT(void);
250 /* Test Compound Indic-Latin transliterators*/
251 void TestCompoundLatinRT(void);
253 /* Test bindi and tippi for Gurmukhi */
254 void TestGurmukhiDevanagari(void);
256 * Test instantiation from a locale.
258 void TestLocaleInstantiation(void);
261 * Test title case handling of accent (should ignore accents)
263 void TestTitleAccents(void);
266 * Basic test of a locale resource based rule.
268 void TestLocaleResource(void);
271 * Make sure parse errors reference the right line.
273 void TestParseError(void);
276 * Make sure sets on output are disallowed.
278 void TestOutputSet(void);
281 * Test the use variable range pragma, making sure that use of
282 * variable range characters is detected and flagged as an error.
284 void TestVariableRange(void);
287 * Test invalid post context error handling
289 void TestInvalidPostContext(void);
292 * Test ID form variants
294 void TestIDForms(void);
297 * Mark's toRules test.
299 void TestToRulesMark(void);
302 * Test Escape and Unescape transliterators.
304 void TestEscape(void);
306 void TestAnchorMasking(void);
309 * Make sure display names of variants look reasonable.
311 void TestDisplayName(void);
314 * Check to see if case mapping works correctly.
316 void TestSpecialCases(void);
318 * Check to see that incremental gets at least part way through a reasonable string.
320 void TestIncrementalProgress(void);
323 * Check that casing handles surrogates.
325 void TestSurrogateCasing (void);
327 void TestFunction(void);
329 void TestInvalidBackRef(void);
331 void TestMulticharStringSet(void);
333 void TestUserFunction(void);
339 void TestSourceTargetSet(void);
341 void TestPatternWhiteSpace(void);
343 void TestAllCodepoints(void);
345 void TestBoilerplate(void);
347 void TestAlternateSyntax(void);
349 void TestRuleStripping(void);
351 void TestHalfwidthFullwidth(void);
356 * Tests the multiple-pass syntax
358 void TestBeginEnd(void);
361 * Tests that toRules() works right with the multiple-pass syntax
363 void TestBeginEndToRules(void);
366 * Tests the registerAlias() function
368 void TestRegisterAlias(void);
370 //======================================================================
372 //======================================================================
374 void expectT(const UnicodeString
& id
,
375 const UnicodeString
& source
,
376 const UnicodeString
& expectedResult
);
378 void expect(const UnicodeString
& rules
,
379 const UnicodeString
& source
,
380 const UnicodeString
& expectedResult
,
381 UTransPosition
*pos
=0);
383 void expect(const UnicodeString
& id
,
384 const UnicodeString
& rules
,
385 const UnicodeString
& source
,
386 const UnicodeString
& expectedResult
,
387 UTransPosition
*pos
=0);
389 void expect(const Transliterator
& t
,
390 const UnicodeString
& source
,
391 const UnicodeString
& expectedResult
,
392 const Transliterator
& reverseTransliterator
);
394 void expect(const Transliterator
& t
,
395 const UnicodeString
& source
,
396 const UnicodeString
& expectedResult
,
397 UTransPosition
*pos
=0);
399 void expectAux(const UnicodeString
& tag
,
400 const UnicodeString
& source
,
401 const UnicodeString
& result
,
402 const UnicodeString
& expectedResult
);
404 virtual void expectAux(const UnicodeString
& tag
,
405 const UnicodeString
& summary
, UBool pass
,
406 const UnicodeString
& expectedResult
);
408 static UnicodeString
& formatInput(UnicodeString
&appendTo
,
409 const UnicodeString
& input
,
410 const UTransPosition
& pos
);
412 void checkRules(const UnicodeString
& label
, Transliterator
& t2
,
413 const UnicodeString
& testRulesForward
);
414 void CheckIncrementalAux(const Transliterator
* t
,
415 const UnicodeString
& input
);
417 void reportParseError(const UnicodeString
& message
, const UParseError
& parseError
, const UErrorCode
& status
);
420 const UnicodeString DESERET_DEE
;
421 const UnicodeString DESERET_dee
;
425 #endif /* #if !UCONFIG_NO_TRANSLITERATION */