]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/intltest/transtst.h
ICU-511.27.tar.gz
[apple/icu.git] / icuSources / test / intltest / transtst.h
1 /*
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 **********************************************************************
9 */
10 #ifndef TRANSTST_H
11 #define TRANSTST_H
12
13 #include "unicode/utypes.h"
14
15 #if !UCONFIG_NO_TRANSLITERATION
16
17 #include "unicode/translit.h"
18 #include "intltest.h"
19
20 /**
21 * @test
22 * @summary General test of Transliterator
23 */
24 class TransliteratorTest : public IntlTest {
25
26 public:
27 TransliteratorTest();
28 virtual ~TransliteratorTest();
29
30 private:
31 void runIndexedTest(int32_t index, UBool exec, const char* &name,
32 char* par=NULL);
33
34 void TestInstantiation(void);
35
36 void TestSimpleRules(void);
37
38 void TestInlineSet(void);
39
40 void TestAnchors(void);
41
42 void TestPatternQuoting(void);
43
44 /**
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.
51 */
52 void TestRuleBasedInverse(void);
53
54 /**
55 * Basic test of keyboard.
56 */
57 void TestKeyboard(void);
58
59 /**
60 * Basic test of keyboard with cursor.
61 */
62 void TestKeyboard2(void);
63
64 /**
65 * Test keyboard transliteration with back-replacement.
66 */
67 void TestKeyboard3(void);
68
69 void keyboardAux(const Transliterator& t,
70 const char* DATA[], int32_t DATA_length);
71
72 void TestArabic(void);
73
74 /**
75 * Compose the Kana transliterator forward and reverse and try
76 * some strings that should come out unchanged.
77 */
78 void TestCompoundKana(void);
79
80 /**
81 * Compose the hex transliterators forward and reverse.
82 */
83 void TestCompoundHex(void);
84
85 /**
86 * Do some basic tests of filtering.
87 */
88 void TestFiltering(void);
89
90 /**
91 * Regression test for bugs found in Greek transliteration.
92 */
93 void TestJ277(void);
94
95 /**
96 * Prefix, suffix support in hex transliterators.
97 */
98 void TestJ243(void);
99
100 /**
101 * Parsers need better syntax error messages.
102 */
103 void TestJ329(void);
104
105 /**
106 * Test segments and segment references.
107 */
108 void TestSegments(void);
109
110 /**
111 * Test cursor positioning outside of the key
112 */
113 void TestCursorOffset(void);
114
115 /**
116 * Test zero length and > 1 char length variable values. Test
117 * use of variable refs in UnicodeSets.
118 */
119 void TestArbitraryVariableValues(void);
120
121 /**
122 * Confirm that the contextStart, contextLimit, start, and limit
123 * behave correctly. J474.
124 */
125 void TestPositionHandling(void);
126
127 /**
128 * Test the Hiragana-Katakana transliterator.
129 */
130 void TestHiraganaKatakana(void);
131
132 /**
133 * Test cloning / copy constructor of RBT.
134 */
135 void TestCopyJ476(void);
136
137 /**
138 * Test inter-Indic transliterators. These are composed.
139 * ICU4C Jitterbug 483.
140 */
141 void TestInterIndic(void);
142
143 /**
144 * Test filter syntax in IDs. (J918)
145 */
146 void TestFilterIDs(void);
147
148 /**
149 * Test the case mapping transliterators.
150 */
151 void TestCaseMap(void);
152
153 /**
154 * Test the name mapping transliterators.
155 */
156 void TestNameMap(void);
157
158 /**
159 * Test liberalized ID syntax. 1006c
160 */
161 void TestLiberalizedID(void);
162 /**
163 * Test Jitterbug 912
164 */
165 void TestCreateInstance(void);
166
167 void TestNormalizationTransliterator(void);
168
169 void TestCompoundRBT(void);
170
171 void TestCompoundFilter(void);
172
173 void TestRemove(void);
174
175 void TestToRules(void);
176
177 void TestContext(void);
178
179 void TestSupplemental(void);
180
181 void TestQuantifier(void);
182
183 /**
184 * Test Source-Target/Variant.
185 */
186 void TestSTV(void);
187
188 void TestCompoundInverse(void);
189
190 void TestNFDChainRBT(void);
191
192 /**
193 * Inverse of "Null" should be "Null". (J21)
194 */
195 void TestNullInverse(void);
196
197 /**
198 * Check ID of inverse of alias. (J22)
199 */
200 void TestAliasInverseID(void);
201
202 /**
203 * Test IDs of inverses of compound transliterators. (J20)
204 */
205 void TestCompoundInverseID(void);
206
207 /**
208 * Test undefined variable.
209 */
210 void TestUndefinedVariable(void);
211
212 /**
213 * Test empty context.
214 */
215 void TestEmptyContext(void);
216
217 /**
218 * Test compound filter ID syntax
219 */
220 void TestCompoundFilterID(void);
221
222 /**
223 * Test new property set syntax
224 */
225 void TestPropertySet(void);
226
227 /**
228 * Test various failure points of the new 2.0 engine.
229 */
230 void TestNewEngine(void);
231
232 /**
233 * Test quantified segment behavior. We want:
234 * ([abc])+ > x $1 x; applied to "cba" produces "xax"
235 */
236 void TestQuantifiedSegment(void);
237
238 /* Devanagari-Latin rules Test */
239 void TestDevanagariLatinRT(void);
240
241 /* Telugu-Latin rules Test */
242 void TestTeluguLatinRT(void);
243
244 /* Gujarati-Latin rules Test */
245 void TestGujaratiLatinRT(void);
246
247 /* Sanskrit-Latin rules Test */
248 void TestSanskritLatinRT(void);
249
250 /* Test Compound Indic-Latin transliterators*/
251 void TestCompoundLatinRT(void);
252
253 /* Test bindi and tippi for Gurmukhi */
254 void TestGurmukhiDevanagari(void);
255 /**
256 * Test instantiation from a locale.
257 */
258 void TestLocaleInstantiation(void);
259
260 /**
261 * Test title case handling of accent (should ignore accents)
262 */
263 void TestTitleAccents(void);
264
265 /**
266 * Basic test of a locale resource based rule.
267 */
268 void TestLocaleResource(void);
269
270 /**
271 * Make sure parse errors reference the right line.
272 */
273 void TestParseError(void);
274
275 /**
276 * Make sure sets on output are disallowed.
277 */
278 void TestOutputSet(void);
279
280 /**
281 * Test the use variable range pragma, making sure that use of
282 * variable range characters is detected and flagged as an error.
283 */
284 void TestVariableRange(void);
285
286 /**
287 * Test invalid post context error handling
288 */
289 void TestInvalidPostContext(void);
290
291 /**
292 * Test ID form variants
293 */
294 void TestIDForms(void);
295
296 /**
297 * Mark's toRules test.
298 */
299 void TestToRulesMark(void);
300
301 /**
302 * Test Escape and Unescape transliterators.
303 */
304 void TestEscape(void);
305
306 void TestAnchorMasking(void);
307
308 /**
309 * Make sure display names of variants look reasonable.
310 */
311 void TestDisplayName(void);
312
313 /**
314 * Check to see if case mapping works correctly.
315 */
316 void TestSpecialCases(void);
317 /**
318 * Check to see that incremental gets at least part way through a reasonable string.
319 */
320 void TestIncrementalProgress(void);
321
322 /**
323 * Check that casing handles surrogates.
324 */
325 void TestSurrogateCasing (void);
326
327 void TestFunction(void);
328
329 void TestInvalidBackRef(void);
330
331 void TestMulticharStringSet(void);
332
333 void TestUserFunction(void);
334
335 void TestAnyX(void);
336
337 void TestAny(void);
338
339 void TestSourceTargetSet(void);
340
341 void TestPatternWhiteSpace(void);
342
343 void TestAllCodepoints(void);
344
345 void TestBoilerplate(void);
346
347 void TestAlternateSyntax(void);
348
349 void TestRuleStripping(void);
350
351 void TestHalfwidthFullwidth(void);
352
353 void TestThai(void);
354
355 /**
356 * Tests the multiple-pass syntax
357 */
358 void TestBeginEnd(void);
359
360 /**
361 * Tests that toRules() works right with the multiple-pass syntax
362 */
363 void TestBeginEndToRules(void);
364
365 /**
366 * Tests the registerAlias() function
367 */
368 void TestRegisterAlias(void);
369
370 //======================================================================
371 // Support methods
372 //======================================================================
373 protected:
374 void expectT(const UnicodeString& id,
375 const UnicodeString& source,
376 const UnicodeString& expectedResult);
377
378 void expect(const UnicodeString& rules,
379 const UnicodeString& source,
380 const UnicodeString& expectedResult,
381 UTransPosition *pos=0);
382
383 void expect(const UnicodeString& id,
384 const UnicodeString& rules,
385 const UnicodeString& source,
386 const UnicodeString& expectedResult,
387 UTransPosition *pos=0);
388
389 void expect(const Transliterator& t,
390 const UnicodeString& source,
391 const UnicodeString& expectedResult,
392 const Transliterator& reverseTransliterator);
393
394 void expect(const Transliterator& t,
395 const UnicodeString& source,
396 const UnicodeString& expectedResult,
397 UTransPosition *pos=0);
398
399 void expectAux(const UnicodeString& tag,
400 const UnicodeString& source,
401 const UnicodeString& result,
402 const UnicodeString& expectedResult);
403
404 virtual void expectAux(const UnicodeString& tag,
405 const UnicodeString& summary, UBool pass,
406 const UnicodeString& expectedResult);
407
408 static UnicodeString& formatInput(UnicodeString &appendTo,
409 const UnicodeString& input,
410 const UTransPosition& pos);
411
412 void checkRules(const UnicodeString& label, Transliterator& t2,
413 const UnicodeString& testRulesForward);
414 void CheckIncrementalAux(const Transliterator* t,
415 const UnicodeString& input);
416
417 void reportParseError(const UnicodeString& message, const UParseError& parseError, const UErrorCode& status);
418
419
420 const UnicodeString DESERET_DEE;
421 const UnicodeString DESERET_dee;
422
423 };
424
425 #endif /* #if !UCONFIG_NO_TRANSLITERATION */
426
427 #endif