1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 **********************************************************************
5 * Copyright (C) 1999-2011, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 **********************************************************************
8 * Date Name Description
9 * 11/10/99 aliu Creation.
10 **********************************************************************
15 #include "unicode/utypes.h"
17 #if !UCONFIG_NO_TRANSLITERATION
19 #include "unicode/translit.h"
24 * @summary General test of Transliterator
26 class TransliteratorTest
: public IntlTest
{
30 virtual ~TransliteratorTest();
33 void runIndexedTest(int32_t index
, UBool exec
, const char* &name
,
36 void TestInstantiation(void);
38 void TestSimpleRules(void);
40 void TestInlineSet(void);
42 void TestAnchors(void);
44 void TestPatternQuoting(void);
47 * Create some inverses and confirm that they work. We have to be
48 * careful how we do this, since the inverses will not be true
49 * inverses -- we can't throw any random string at the composition
50 * of the transliterators and expect the identity function. F x
51 * F' != I. However, if we are careful about the input, we will
52 * get the expected results.
54 void TestRuleBasedInverse(void);
57 * Basic test of keyboard.
59 void TestKeyboard(void);
62 * Basic test of keyboard with cursor.
64 void TestKeyboard2(void);
67 * Test keyboard transliteration with back-replacement.
69 void TestKeyboard3(void);
71 void keyboardAux(const Transliterator
& t
,
72 const char* DATA
[], int32_t DATA_length
);
74 void TestArabic(void);
77 * Compose the Kana transliterator forward and reverse and try
78 * some strings that should come out unchanged.
80 void TestCompoundKana(void);
83 * Compose the hex transliterators forward and reverse.
85 void TestCompoundHex(void);
88 * Do some basic tests of filtering.
90 void TestFiltering(void);
93 * Regression test for bugs found in Greek transliteration.
98 * Prefix, suffix support in hex transliterators.
103 * Parsers need better syntax error messages.
108 * Test segments and segment references.
110 void TestSegments(void);
113 * Test cursor positioning outside of the key
115 void TestCursorOffset(void);
118 * Test zero length and > 1 char length variable values. Test
119 * use of variable refs in UnicodeSets.
121 void TestArbitraryVariableValues(void);
124 * Confirm that the contextStart, contextLimit, start, and limit
125 * behave correctly. J474.
127 void TestPositionHandling(void);
130 * Test the Hiragana-Katakana transliterator.
132 void TestHiraganaKatakana(void);
135 * Test cloning / copy constructor of RBT.
137 void TestCopyJ476(void);
140 * Test inter-Indic transliterators. These are composed.
141 * ICU4C Jitterbug 483.
143 void TestInterIndic(void);
146 * Test filter syntax in IDs. (J918)
148 void TestFilterIDs(void);
151 * Test the case mapping transliterators.
153 void TestCaseMap(void);
156 * Test the name mapping transliterators.
158 void TestNameMap(void);
161 * Test liberalized ID syntax. 1006c
163 void TestLiberalizedID(void);
167 void TestCreateInstance(void);
169 void TestNormalizationTransliterator(void);
171 void TestCompoundRBT(void);
173 void TestCompoundFilter(void);
175 void TestRemove(void);
177 void TestToRules(void);
179 void TestContext(void);
181 void TestSupplemental(void);
183 void TestQuantifier(void);
186 * Test Source-Target/Variant.
190 void TestCompoundInverse(void);
192 void TestNFDChainRBT(void);
195 * Inverse of "Null" should be "Null". (J21)
197 void TestNullInverse(void);
200 * Check ID of inverse of alias. (J22)
202 void TestAliasInverseID(void);
205 * Test IDs of inverses of compound transliterators. (J20)
207 void TestCompoundInverseID(void);
210 * Test undefined variable.
212 void TestUndefinedVariable(void);
215 * Test empty context.
217 void TestEmptyContext(void);
220 * Test compound filter ID syntax
222 void TestCompoundFilterID(void);
225 * Test new property set syntax
227 void TestPropertySet(void);
230 * Test various failure points of the new 2.0 engine.
232 void TestNewEngine(void);
235 * Test quantified segment behavior. We want:
236 * ([abc])+ > x $1 x; applied to "cba" produces "xax"
238 void TestQuantifiedSegment(void);
240 /* Devanagari-Latin rules Test */
241 void TestDevanagariLatinRT(void);
243 /* Telugu-Latin rules Test */
244 void TestTeluguLatinRT(void);
246 /* Gujarati-Latin rules Test */
247 void TestGujaratiLatinRT(void);
249 /* Sanskrit-Latin rules Test */
250 void TestSanskritLatinRT(void);
252 /* Test Compound Indic-Latin transliterators*/
253 void TestCompoundLatinRT(void);
255 /* Test bindi and tippi for Gurmukhi */
256 void TestGurmukhiDevanagari(void);
258 * Test instantiation from a locale.
260 void TestLocaleInstantiation(void);
263 * Test title case handling of accent (should ignore accents)
265 void TestTitleAccents(void);
268 * Basic test of a locale resource based rule.
270 void TestLocaleResource(void);
273 * Make sure parse errors reference the right line.
275 void TestParseError(void);
278 * Make sure sets on output are disallowed.
280 void TestOutputSet(void);
283 * Test the use variable range pragma, making sure that use of
284 * variable range characters is detected and flagged as an error.
286 void TestVariableRange(void);
289 * Test invalid post context error handling
291 void TestInvalidPostContext(void);
294 * Test ID form variants
296 void TestIDForms(void);
299 * Mark's toRules test.
301 void TestToRulesMark(void);
304 * Test Escape and Unescape transliterators.
306 void TestEscape(void);
308 void TestAnchorMasking(void);
311 * Make sure display names of variants look reasonable.
313 void TestDisplayName(void);
316 * Check to see if case mapping works correctly.
318 void TestSpecialCases(void);
320 * Check to see that incremental gets at least part way through a reasonable string.
322 void TestIncrementalProgress(void);
325 * Check that casing handles surrogates.
327 void TestSurrogateCasing (void);
329 void TestFunction(void);
331 void TestInvalidBackRef(void);
333 void TestMulticharStringSet(void);
335 void TestUserFunction(void);
341 void TestSourceTargetSet(void);
343 void TestPatternWhiteSpace(void);
345 void TestAllCodepoints(void);
347 void TestBoilerplate(void);
349 void TestAlternateSyntax(void);
351 void TestRuleStripping(void);
353 void TestHalfwidthFullwidth(void);
358 * Tests the multiple-pass syntax
360 void TestBeginEnd(void);
363 * Tests that toRules() works right with the multiple-pass syntax
365 void TestBeginEndToRules(void);
368 * Tests the registerAlias() function
370 void TestRegisterAlias(void);
372 //======================================================================
374 //======================================================================
376 void expectT(const UnicodeString
& id
,
377 const UnicodeString
& source
,
378 const UnicodeString
& expectedResult
);
380 void expect(const UnicodeString
& rules
,
381 const UnicodeString
& source
,
382 const UnicodeString
& expectedResult
,
383 UTransPosition
*pos
=0);
385 void expect(const UnicodeString
& id
,
386 const UnicodeString
& rules
,
387 const UnicodeString
& source
,
388 const UnicodeString
& expectedResult
,
389 UTransPosition
*pos
=0);
391 void expect(const Transliterator
& t
,
392 const UnicodeString
& source
,
393 const UnicodeString
& expectedResult
,
394 const Transliterator
& reverseTransliterator
);
396 void expect(const Transliterator
& t
,
397 const UnicodeString
& source
,
398 const UnicodeString
& expectedResult
,
399 UTransPosition
*pos
=0);
401 void expectAux(const UnicodeString
& tag
,
402 const UnicodeString
& source
,
403 const UnicodeString
& result
,
404 const UnicodeString
& expectedResult
);
406 virtual void expectAux(const UnicodeString
& tag
,
407 const UnicodeString
& summary
, UBool pass
,
408 const UnicodeString
& expectedResult
);
410 static UnicodeString
& formatInput(UnicodeString
&appendTo
,
411 const UnicodeString
& input
,
412 const UTransPosition
& pos
);
414 void checkRules(const UnicodeString
& label
, Transliterator
& t2
,
415 const UnicodeString
& testRulesForward
);
416 void CheckIncrementalAux(const Transliterator
* t
,
417 const UnicodeString
& input
);
419 void reportParseError(const UnicodeString
& message
, const UParseError
& parseError
, const UErrorCode
& status
);
422 const UnicodeString DESERET_DEE
;
423 const UnicodeString DESERET_dee
;
427 #endif /* #if !UCONFIG_NO_TRANSLITERATION */