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