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