]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | ********************************************************************** | |
46f4442e | 3 | * Copyright (C) 2000-2008, International Business Machines |
b75a7d8f A |
4 | * Corporation and others. All Rights Reserved. |
5 | ********************************************************************** | |
6 | * Date Name Description | |
7 | * 05/23/00 aliu Creation. | |
8 | ********************************************************************** | |
9 | */ | |
10 | ||
11 | #include "unicode/utypes.h" | |
12 | ||
13 | #if !UCONFIG_NO_TRANSLITERATION | |
14 | ||
15 | #include "unicode/translit.h" | |
16 | #include "rbt.h" | |
374ca955 | 17 | #include "unicode/calendar.h" |
b75a7d8f A |
18 | #include "unicode/uniset.h" |
19 | #include "unicode/uchar.h" | |
20 | #include "unicode/normlzr.h" | |
21 | #include "unicode/uchar.h" | |
22 | #include "unicode/parseerr.h" | |
23 | #include "unicode/usetiter.h" | |
24 | #include "unicode/putil.h" | |
25 | #include "unicode/uversion.h" | |
374ca955 A |
26 | #include "unicode/locid.h" |
27 | #include "unicode/ulocdata.h" | |
28 | #include "unicode/utf8.h" | |
29 | #include "putilimp.h" | |
b75a7d8f A |
30 | #include "cmemory.h" |
31 | #include "transrt.h" | |
32 | #include "testutil.h" | |
33 | #include <string.h> | |
374ca955 | 34 | #include <stdio.h> |
b75a7d8f A |
35 | |
36 | #define CASE(id,test) case id: \ | |
37 | name = #test; \ | |
38 | if (exec) { \ | |
39 | logln(#test "---"); \ | |
40 | logln((UnicodeString)""); \ | |
374ca955 | 41 | UDate t = uprv_getUTCtime(); \ |
b75a7d8f A |
42 | test(); \ |
43 | t = uprv_getUTCtime() - t; \ | |
374ca955 | 44 | logln((UnicodeString)#test " took " + t/U_MILLIS_PER_DAY + " seconds"); \ |
b75a7d8f A |
45 | } \ |
46 | break | |
47 | ||
48 | #define EXHAUSTIVE(id,test) case id: \ | |
49 | if(quick==FALSE){ \ | |
50 | name = #test; \ | |
51 | if (exec){ \ | |
52 | logln(#test "---"); \ | |
53 | logln((UnicodeString)""); \ | |
54 | test(); \ | |
55 | } \ | |
56 | }else{ \ | |
57 | name=""; \ | |
58 | } \ | |
59 | break | |
60 | void | |
61 | TransliteratorRoundTripTest::runIndexedTest(int32_t index, UBool exec, | |
62 | const char* &name, char* /*par*/) { | |
63 | switch (index) { | |
64 | CASE(0, TestCyrillic); | |
65 | // CASE(0,TestKana); | |
66 | CASE(1,TestHiragana); | |
67 | CASE(2,TestKatakana); | |
68 | CASE(3,TestJamo); | |
69 | CASE(4,TestHangul); | |
70 | CASE(5,TestGreek); | |
71 | CASE(6,TestGreekUNGEGN); | |
72 | CASE(7,Testel); | |
73 | CASE(8,TestDevanagariLatin); | |
74 | CASE(9,TestInterIndic); | |
374ca955 A |
75 | CASE(10, TestHebrew); |
76 | CASE(11, TestArabic); | |
77 | CASE(12, TestHan); | |
b75a7d8f A |
78 | default: name = ""; break; |
79 | } | |
80 | } | |
81 | ||
82 | //-------------------------------------------------------------------- | |
83 | // Time bomb - allows temporary behavior that expires at a given | |
84 | // release | |
85 | //-------------------------------------------------------------------- | |
46f4442e | 86 | static const UVersionInfo ICU_39 = {4,0,0,1}; |
b75a7d8f | 87 | |
b75a7d8f A |
88 | |
89 | //-------------------------------------------------------------------- | |
90 | // TransliteratorPointer | |
91 | //-------------------------------------------------------------------- | |
92 | ||
93 | /** | |
94 | * A transliterator pointer wrapper that deletes the contained | |
95 | * pointer automatically when the wrapper goes out of scope. | |
96 | * Sometimes called a "janitor" or "smart pointer". | |
97 | */ | |
98 | class TransliteratorPointer { | |
99 | Transliterator* t; | |
100 | // disallowed: | |
101 | TransliteratorPointer(const TransliteratorPointer& rhs); | |
102 | TransliteratorPointer& operator=(const TransliteratorPointer& rhs); | |
103 | public: | |
104 | TransliteratorPointer(Transliterator* adopted) { | |
105 | t = adopted; | |
106 | } | |
107 | ~TransliteratorPointer() { | |
108 | delete t; | |
109 | } | |
110 | inline Transliterator* operator->() { return t; } | |
111 | inline operator const Transliterator*() const { return t; } | |
112 | inline operator Transliterator*() { return t; } | |
113 | }; | |
114 | ||
115 | //-------------------------------------------------------------------- | |
116 | // Legal | |
117 | //-------------------------------------------------------------------- | |
118 | ||
119 | class Legal { | |
120 | public: | |
121 | Legal() {} | |
122 | virtual ~Legal() {} | |
123 | virtual UBool is(const UnicodeString& /*sourceString*/) const {return TRUE;} | |
124 | }; | |
125 | ||
126 | class LegalJamo : public Legal { | |
127 | // any initial must be followed by a medial (or initial) | |
128 | // any medial must follow an initial (or medial) | |
129 | // any final must follow a medial (or final) | |
130 | public: | |
131 | LegalJamo() {} | |
132 | virtual ~LegalJamo() {} | |
133 | virtual UBool is(const UnicodeString& sourceString) const; | |
134 | int getType(UChar c) const; | |
135 | }; | |
136 | ||
137 | UBool LegalJamo::is(const UnicodeString& sourceString) const { | |
138 | int t; | |
139 | UnicodeString decomp; | |
140 | UErrorCode ec = U_ZERO_ERROR; | |
141 | Normalizer::decompose(sourceString, FALSE, 0, decomp, ec); | |
142 | if (U_FAILURE(ec)) { | |
143 | return FALSE; | |
144 | } | |
145 | for (int i = 0; i < decomp.length(); ++i) { // don't worry about surrogates | |
146 | switch (getType(decomp.charAt(i))) { | |
147 | case 0: t = getType(decomp.charAt(i+1)); | |
148 | if (t != 0 && t != 1) { return FALSE; } | |
149 | break; | |
150 | case 1: t = getType(decomp.charAt(i-1)); | |
151 | if (t != 0 && t != 1) { return FALSE; } | |
152 | break; | |
153 | case 2: t = getType(decomp.charAt(i-1)); | |
154 | if (t != 1 && t != 2) { return FALSE; } | |
155 | break; | |
156 | } | |
157 | } | |
158 | return TRUE; | |
159 | } | |
160 | ||
161 | int LegalJamo::getType(UChar c) const { | |
162 | if (0x1100 <= c && c <= 0x1112) | |
163 | return 0; | |
164 | else if (0x1161 <= c && c <= 0x1175) | |
165 | return 1; | |
166 | else if (0x11A8 <= c && c <= 0x11C2) | |
167 | return 2; | |
168 | return -1; // other | |
169 | } | |
170 | ||
171 | class LegalGreek : public Legal { | |
172 | UBool full; | |
173 | public: | |
174 | LegalGreek(UBool _full) { full = _full; } | |
175 | virtual ~LegalGreek() {} | |
176 | ||
177 | virtual UBool is(const UnicodeString& sourceString) const; | |
178 | ||
179 | static UBool isVowel(UChar c); | |
180 | ||
181 | static UBool isRho(UChar c); | |
182 | }; | |
183 | ||
184 | UBool LegalGreek::is(const UnicodeString& sourceString) const { | |
185 | UnicodeString decomp; | |
186 | UErrorCode ec = U_ZERO_ERROR; | |
187 | Normalizer::decompose(sourceString, FALSE, 0, decomp, ec); | |
188 | ||
189 | // modern is simpler: don't care about anything but a grave | |
190 | if (full == FALSE) { | |
191 | // A special case which is legal but should be | |
192 | // excluded from round trip | |
193 | // if (sourceString == UnicodeString("\\u039C\\u03C0", "")) { | |
194 | // return FALSE; | |
195 | // } | |
196 | for (int32_t i = 0; i < decomp.length(); ++i) { | |
197 | UChar c = decomp.charAt(i); | |
198 | // exclude all the accents | |
199 | if (c == 0x0313 || c == 0x0314 || c == 0x0300 || c == 0x0302 | |
200 | || c == 0x0342 || c == 0x0345 | |
201 | ) return FALSE; | |
202 | } | |
203 | return TRUE; | |
204 | } | |
205 | ||
206 | // Legal greek has breathing marks IFF there is a vowel or RHO at the start | |
207 | // IF it has them, it has exactly one. | |
208 | // IF it starts with a RHO, then the breathing mark must come before the second letter. | |
209 | // Since there are no surrogates in greek, don't worry about them | |
210 | UBool firstIsVowel = FALSE; | |
211 | UBool firstIsRho = FALSE; | |
212 | UBool noLetterYet = TRUE; | |
213 | int32_t breathingCount = 0; | |
214 | int32_t letterCount = 0; | |
215 | for (int32_t i = 0; i < decomp.length(); ++i) { | |
216 | UChar c = decomp.charAt(i); | |
217 | if (u_isalpha(c)) { | |
218 | ++letterCount; | |
219 | if (noLetterYet) { | |
220 | noLetterYet = FALSE; | |
221 | firstIsVowel = isVowel(c); | |
222 | firstIsRho = isRho(c); | |
223 | } | |
224 | if (firstIsRho && letterCount == 2 && breathingCount == 0) { | |
225 | return FALSE; | |
226 | } | |
227 | } | |
228 | if (c == 0x0313 || c == 0x0314) { | |
229 | ++breathingCount; | |
230 | } | |
231 | } | |
232 | ||
233 | if (firstIsVowel || firstIsRho) return breathingCount == 1; | |
234 | return breathingCount == 0; | |
235 | } | |
236 | ||
237 | UBool LegalGreek::isVowel(UChar c) { | |
238 | switch (c) { | |
239 | case 0x03B1: | |
240 | case 0x03B5: | |
241 | case 0x03B7: | |
242 | case 0x03B9: | |
243 | case 0x03BF: | |
244 | case 0x03C5: | |
245 | case 0x03C9: | |
246 | case 0x0391: | |
247 | case 0x0395: | |
248 | case 0x0397: | |
249 | case 0x0399: | |
250 | case 0x039F: | |
251 | case 0x03A5: | |
252 | case 0x03A9: | |
253 | return TRUE; | |
254 | } | |
255 | return FALSE; | |
256 | } | |
257 | ||
258 | UBool LegalGreek::isRho(UChar c) { | |
259 | switch (c) { | |
260 | case 0x03C1: | |
261 | case 0x03A1: | |
262 | return TRUE; | |
263 | } | |
264 | return FALSE; | |
265 | } | |
266 | ||
267 | // AbbreviatedUnicodeSetIterator Interface --------------------------------------------- | |
73c04bcf A |
268 | // |
269 | // Iterate over a UnicodeSet, only returning a sampling of the contained code points. | |
270 | // density is the approximate total number of code points to returned for the entire set. | |
271 | // | |
b75a7d8f A |
272 | |
273 | class AbbreviatedUnicodeSetIterator : public UnicodeSetIterator { | |
274 | public : | |
275 | ||
276 | AbbreviatedUnicodeSetIterator(); | |
277 | virtual ~AbbreviatedUnicodeSetIterator(); | |
278 | void reset(UnicodeSet& set, UBool abb = FALSE, int32_t density = 100); | |
279 | ||
280 | /** | |
73c04bcf | 281 | * ICU "poor man's RTTI", returns a UClassID for this class. |
b75a7d8f | 282 | */ |
73c04bcf | 283 | static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } |
b75a7d8f A |
284 | |
285 | /** | |
73c04bcf | 286 | * ICU "poor man's RTTI", returns a UClassID for the actual class. |
b75a7d8f | 287 | */ |
73c04bcf | 288 | virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } |
b75a7d8f A |
289 | |
290 | private : | |
291 | UBool abbreviated; | |
73c04bcf | 292 | int32_t perRange; // The maximum number of code points to be returned from each range |
b75a7d8f A |
293 | virtual void loadRange(int32_t range); |
294 | ||
295 | /** | |
296 | * The address of this static class variable serves as this class's ID | |
297 | * for ICU "poor man's RTTI". | |
298 | */ | |
299 | static const char fgClassID; | |
300 | }; | |
301 | ||
302 | // AbbreviatedUnicodeSetIterator Implementation --------------------------------------- | |
303 | ||
304 | const char AbbreviatedUnicodeSetIterator::fgClassID=0; | |
305 | ||
306 | AbbreviatedUnicodeSetIterator::AbbreviatedUnicodeSetIterator() : | |
307 | UnicodeSetIterator(), abbreviated(FALSE) { | |
308 | } | |
309 | ||
310 | AbbreviatedUnicodeSetIterator::~AbbreviatedUnicodeSetIterator() { | |
311 | } | |
312 | ||
313 | void AbbreviatedUnicodeSetIterator::reset(UnicodeSet& newSet, UBool abb, int32_t density) { | |
314 | UnicodeSetIterator::reset(newSet); | |
315 | abbreviated = abb; | |
316 | perRange = newSet.getRangeCount(); | |
317 | if (perRange != 0) { | |
318 | perRange = density / perRange; | |
319 | } | |
320 | } | |
321 | ||
322 | void AbbreviatedUnicodeSetIterator::loadRange(int32_t myRange) { | |
323 | UnicodeSetIterator::loadRange(myRange); | |
324 | if (abbreviated && (endElement > nextElement + perRange)) { | |
325 | endElement = nextElement + perRange; | |
326 | } | |
327 | } | |
328 | ||
329 | //-------------------------------------------------------------------- | |
330 | // RTTest Interface | |
331 | //-------------------------------------------------------------------- | |
332 | ||
333 | class RTTest : public IntlTest { | |
334 | ||
335 | // PrintWriter out; | |
336 | ||
337 | UnicodeString transliteratorID; | |
338 | int32_t errorLimit; | |
339 | int32_t errorCount; | |
340 | int32_t pairLimit; | |
341 | UnicodeSet sourceRange; | |
342 | UnicodeSet targetRange; | |
343 | UnicodeSet toSource; | |
344 | UnicodeSet toTarget; | |
345 | UnicodeSet roundtripExclusionsSet; | |
346 | IntlTest* parent; | |
347 | Legal* legalSource; // NOT owned | |
348 | UnicodeSet badCharacters; | |
349 | ||
350 | public: | |
351 | ||
352 | /* | |
353 | * create a test for the given script transliterator. | |
354 | */ | |
355 | RTTest(const UnicodeString& transliteratorIDStr); | |
356 | ||
357 | virtual ~RTTest(); | |
358 | ||
359 | void setErrorLimit(int32_t limit); | |
360 | ||
361 | void setPairLimit(int32_t limit); | |
362 | ||
363 | void test(const UnicodeString& sourceRange, | |
364 | const UnicodeString& targetRange, | |
365 | const char* roundtripExclusions, | |
366 | IntlTest* parent, | |
367 | UBool quick, | |
368 | Legal* adoptedLegal, | |
369 | int32_t density = 100); | |
370 | ||
371 | private: | |
372 | ||
373 | // Added to do better equality check. | |
374 | ||
375 | static UBool isSame(const UnicodeString& a, const UnicodeString& b); | |
376 | ||
377 | static UBool isCamel(const UnicodeString& a); | |
378 | ||
379 | UBool checkIrrelevants(Transliterator *t, const UnicodeString& irrelevants); | |
380 | ||
381 | void test2(UBool quick, int32_t density); | |
382 | ||
383 | void logWrongScript(const UnicodeString& label, | |
384 | const UnicodeString& from, | |
385 | const UnicodeString& to); | |
386 | ||
387 | void logNotCanonical(const UnicodeString& label, | |
388 | const UnicodeString& from, | |
389 | const UnicodeString& to, | |
390 | const UnicodeString& fromCan, | |
391 | const UnicodeString& toCan); | |
392 | ||
393 | void logFails(const UnicodeString& label); | |
394 | ||
395 | void logToRulesFails(const UnicodeString& label, | |
396 | const UnicodeString& from, | |
397 | const UnicodeString& to, | |
398 | const UnicodeString& toCan); | |
399 | ||
400 | void logRoundTripFailure(const UnicodeString& from, | |
401 | const UnicodeString& toID, | |
402 | const UnicodeString& to, | |
403 | const UnicodeString& backID, | |
404 | const UnicodeString& back); | |
405 | }; | |
406 | ||
407 | //-------------------------------------------------------------------- | |
408 | // RTTest Implementation | |
409 | //-------------------------------------------------------------------- | |
410 | ||
411 | /* | |
412 | * create a test for the given script transliterator. | |
413 | */ | |
414 | RTTest::RTTest(const UnicodeString& transliteratorIDStr) { | |
415 | transliteratorID = transliteratorIDStr; | |
416 | errorLimit = 500; | |
417 | errorCount = 0; | |
418 | pairLimit = 0x10000; | |
419 | } | |
420 | ||
421 | RTTest::~RTTest() { | |
422 | } | |
423 | ||
424 | void RTTest::setErrorLimit(int32_t limit) { | |
425 | errorLimit = limit; | |
426 | } | |
427 | ||
428 | void RTTest::setPairLimit(int32_t limit) { | |
429 | pairLimit = limit; | |
430 | } | |
431 | ||
432 | UBool RTTest::isSame(const UnicodeString& a, const UnicodeString& b) { | |
433 | if (a == b) return TRUE; | |
434 | if (a.caseCompare(b, U_FOLD_CASE_DEFAULT)==0 && isCamel(a)) return TRUE; | |
435 | UnicodeString aa, bb; | |
436 | UErrorCode ec = U_ZERO_ERROR; | |
437 | Normalizer::decompose(a, FALSE, 0, aa, ec); | |
438 | Normalizer::decompose(b, FALSE, 0, bb, ec); | |
439 | if (aa == bb) return TRUE; | |
440 | if (aa.caseCompare(bb, U_FOLD_CASE_DEFAULT)==0 && isCamel(aa)) return TRUE; | |
441 | return FALSE; | |
442 | } | |
443 | ||
444 | UBool RTTest::isCamel(const UnicodeString& a) { | |
445 | // see if string is of the form aB; e.g. lower, then upper or title | |
446 | UChar32 cp; | |
447 | UBool haveLower = FALSE; | |
448 | for (int32_t i = 0; i < a.length(); i += UTF_CHAR_LENGTH(cp)) { | |
449 | cp = a.char32At(i); | |
450 | int8_t t = u_charType(cp); | |
451 | switch (t) { | |
452 | case U_UPPERCASE_LETTER: | |
453 | if (haveLower) return TRUE; | |
454 | break; | |
455 | case U_TITLECASE_LETTER: | |
456 | if (haveLower) return TRUE; | |
457 | // drop through, since second letter is lower. | |
458 | case U_LOWERCASE_LETTER: | |
459 | haveLower = TRUE; | |
460 | break; | |
461 | } | |
462 | } | |
463 | return FALSE; | |
464 | } | |
465 | ||
466 | void RTTest::test(const UnicodeString& sourceRangeVal, | |
467 | const UnicodeString& targetRangeVal, | |
468 | const char* roundtripExclusions, | |
469 | IntlTest* logVal, UBool quickRt, | |
470 | Legal* adoptedLegal, | |
471 | int32_t density) | |
472 | { | |
473 | ||
474 | UErrorCode status = U_ZERO_ERROR; | |
475 | ||
476 | this->parent = logVal; | |
477 | this->legalSource = adoptedLegal; | |
478 | ||
479 | UnicodeSet neverOk("[:Other:]", status); | |
480 | UnicodeSet okAnyway("[^[:Letter:]]", status); | |
481 | ||
482 | if (U_FAILURE(status)) { | |
483 | parent->errln("FAIL: Initializing UnicodeSet with [:Other:] or [^[:Letter:]]"); | |
484 | return; | |
485 | } | |
486 | ||
487 | this->sourceRange.clear(); | |
488 | this->sourceRange.applyPattern(sourceRangeVal, status); | |
489 | if (U_FAILURE(status)) { | |
490 | parent->errln("FAIL: UnicodeSet::applyPattern(" + | |
491 | sourceRangeVal + ")"); | |
492 | return; | |
493 | } | |
494 | this->sourceRange.removeAll(neverOk); | |
495 | ||
496 | this->targetRange.clear(); | |
497 | this->targetRange.applyPattern(targetRangeVal, status); | |
498 | if (U_FAILURE(status)) { | |
499 | parent->errln("FAIL: UnicodeSet::applyPattern(" + | |
500 | targetRangeVal + ")"); | |
501 | return; | |
502 | } | |
503 | this->targetRange.removeAll(neverOk); | |
504 | ||
505 | this->toSource.clear(); | |
506 | this->toSource.applyPattern(sourceRangeVal, status); | |
507 | if (U_FAILURE(status)) { | |
508 | parent->errln("FAIL: UnicodeSet::applyPattern(" + | |
509 | sourceRangeVal + ")"); | |
510 | return; | |
511 | } | |
512 | this->toSource.addAll(okAnyway); | |
513 | ||
514 | this->toTarget.clear(); | |
515 | this->toTarget.applyPattern(targetRangeVal, status); | |
516 | if (U_FAILURE(status)) { | |
517 | parent->errln("FAIL: UnicodeSet::applyPattern(" + | |
518 | targetRangeVal + ")"); | |
519 | return; | |
520 | } | |
521 | this->toTarget.addAll(okAnyway); | |
522 | ||
523 | this->roundtripExclusionsSet.clear(); | |
524 | if (roundtripExclusions != NULL && strlen(roundtripExclusions) > 0) { | |
46f4442e | 525 | this->roundtripExclusionsSet.applyPattern(UnicodeString(roundtripExclusions, -1, US_INV), status); |
b75a7d8f A |
526 | if (U_FAILURE(status)) { |
527 | parent->errln("FAIL: UnicodeSet::applyPattern(%s)", roundtripExclusions); | |
528 | return; | |
529 | } | |
530 | } | |
531 | ||
532 | badCharacters.clear(); | |
533 | badCharacters.applyPattern("[:Other:]", status); | |
534 | if (U_FAILURE(status)) { | |
535 | parent->errln("FAIL: UnicodeSet::applyPattern([:Other:])"); | |
536 | return; | |
537 | } | |
538 | ||
539 | test2(quickRt, density); | |
540 | ||
541 | if (errorCount > 0) { | |
542 | char str[100]; | |
543 | int32_t length = transliteratorID.extract(str, 100, NULL, status); | |
544 | str[length] = 0; | |
545 | parent->errln("FAIL: %s errors: %d %s", str, errorCount, (errorCount > errorLimit ? " (at least!)" : " ")); // + ", see " + logFileName); | |
546 | } else { | |
547 | char str[100]; | |
548 | int32_t length = transliteratorID.extract(str, 100, NULL, status); | |
549 | str[length] = 0; | |
550 | parent->logln("%s ok", str); | |
551 | } | |
552 | } | |
553 | ||
554 | UBool RTTest::checkIrrelevants(Transliterator *t, | |
555 | const UnicodeString& irrelevants) { | |
556 | for (int i = 0; i < irrelevants.length(); ++i) { | |
557 | UChar c = irrelevants.charAt(i); | |
558 | UnicodeString srcStr(c); | |
559 | UnicodeString targ = srcStr; | |
560 | t->transliterate(targ); | |
561 | if (srcStr == targ) return TRUE; | |
562 | } | |
563 | return FALSE; | |
564 | } | |
565 | ||
566 | void RTTest::test2(UBool quickRt, int32_t density) { | |
567 | ||
568 | UnicodeString srcStr, targ, reverse; | |
569 | UErrorCode status = U_ZERO_ERROR; | |
570 | UParseError parseError ; | |
571 | TransliteratorPointer sourceToTarget( | |
572 | Transliterator::createInstance(transliteratorID, UTRANS_FORWARD, parseError, | |
573 | status)); | |
374ca955 | 574 | if ((Transliterator *)sourceToTarget == NULL) { |
b75a7d8f A |
575 | parent->errln("FAIL: createInstance(" + transliteratorID + |
576 | ") returned NULL. Error: " + u_errorName(status) | |
577 | + "\n\tpreContext : " + prettify(parseError.preContext) | |
578 | + "\n\tpostContext : " + prettify(parseError.postContext)); | |
579 | ||
580 | return; | |
581 | } | |
582 | TransliteratorPointer targetToSource(sourceToTarget->createInverse(status)); | |
374ca955 | 583 | if ((Transliterator *)targetToSource == NULL) { |
b75a7d8f A |
584 | parent->errln("FAIL: " + transliteratorID + |
585 | ".createInverse() returned NULL. Error:" + u_errorName(status) | |
586 | + "\n\tpreContext : " + prettify(parseError.preContext) | |
587 | + "\n\tpostContext : " + prettify(parseError.postContext)); | |
588 | return; | |
589 | } | |
590 | ||
591 | AbbreviatedUnicodeSetIterator usi; | |
592 | AbbreviatedUnicodeSetIterator usi2; | |
593 | ||
594 | parent->logln("Checking that at least one irrelevant character is not NFC'ed"); | |
595 | // string is from NFC_NO in the UCD | |
596 | UnicodeString irrelevants = CharsToUnicodeString("\\u2000\\u2001\\u2126\\u212A\\u212B\\u2329"); | |
597 | ||
598 | if (checkIrrelevants(sourceToTarget, irrelevants) == FALSE) { | |
599 | logFails("Source-Target, irrelevants"); | |
600 | } | |
601 | if (checkIrrelevants(targetToSource, irrelevants) == FALSE) { | |
602 | logFails("Target-Source, irrelevants"); | |
603 | } | |
604 | ||
605 | if (!quickRt){ | |
606 | parent->logln("Checking that toRules works"); | |
607 | UnicodeString rules = ""; | |
608 | ||
609 | UParseError parseError; | |
610 | rules = sourceToTarget->toRules(rules, TRUE); | |
611 | // parent->logln((UnicodeString)"toRules => " + rules); | |
612 | TransliteratorPointer sourceToTarget2(Transliterator::createFromRules( | |
613 | "s2t2", rules, | |
614 | UTRANS_FORWARD, | |
615 | parseError, status)); | |
616 | if (U_FAILURE(status)) { | |
617 | parent->errln("FAIL: createFromRules %s\n", u_errorName(status)); | |
618 | return; | |
619 | } | |
620 | ||
621 | rules = targetToSource->toRules(rules, FALSE); | |
622 | TransliteratorPointer targetToSource2(Transliterator::createFromRules( | |
623 | "t2s2", rules, | |
624 | UTRANS_FORWARD, | |
625 | parseError, status)); | |
626 | if (U_FAILURE(status)) { | |
627 | parent->errln("FAIL: createFromRules %s\n", u_errorName(status)); | |
628 | return; | |
629 | } | |
630 | ||
631 | usi.reset(sourceRange); | |
632 | for (;;) { | |
633 | if (!usi.next() || usi.isString()) break; | |
634 | UChar32 c = usi.getCodepoint(); | |
635 | ||
636 | UnicodeString srcStr((UChar32)c); | |
637 | UnicodeString targ = srcStr; | |
638 | sourceToTarget->transliterate(targ); | |
639 | UnicodeString targ2 = srcStr; | |
640 | sourceToTarget2->transliterate(targ2); | |
641 | if (targ != targ2) { | |
642 | logToRulesFails("Source-Target, toRules", srcStr, targ, targ2); | |
643 | } | |
644 | } | |
645 | ||
646 | usi.reset(targetRange); | |
647 | for (;;) { | |
648 | if (!usi.next() || usi.isString()) break; | |
649 | UChar32 c = usi.getCodepoint(); | |
650 | ||
651 | UnicodeString srcStr((UChar32)c); | |
652 | UnicodeString targ = srcStr; | |
653 | targetToSource->transliterate(targ); | |
654 | UnicodeString targ2 = srcStr; | |
655 | targetToSource2->transliterate(targ2); | |
656 | if (targ != targ2) { | |
657 | logToRulesFails("Target-Source, toRules", srcStr, targ, targ2); | |
658 | } | |
659 | } | |
660 | } | |
661 | ||
662 | parent->logln("Checking that all source characters convert to target - Singles"); | |
663 | ||
664 | UnicodeSet failSourceTarg; | |
665 | usi.reset(sourceRange); | |
666 | for (;;) { | |
667 | if (!usi.next() || usi.isString()) break; | |
668 | UChar32 c = usi.getCodepoint(); | |
669 | ||
670 | UnicodeString srcStr((UChar32)c); | |
671 | UnicodeString targ = srcStr; | |
672 | sourceToTarget->transliterate(targ); | |
673 | if (toTarget.containsAll(targ) == FALSE | |
674 | || badCharacters.containsSome(targ) == TRUE) { | |
675 | UnicodeString targD; | |
676 | Normalizer::decompose(targ, FALSE, 0, targD, status); | |
677 | if (U_FAILURE(status)) { | |
678 | parent->errln("FAIL: Internal error during decomposition %s\n", u_errorName(status)); | |
679 | return; | |
680 | } | |
681 | if (toTarget.containsAll(targD) == FALSE || | |
682 | badCharacters.containsSome(targD) == TRUE) { | |
683 | logWrongScript("Source-Target", srcStr, targ); | |
684 | failSourceTarg.add(c); | |
685 | continue; | |
686 | } | |
687 | } | |
688 | ||
689 | UnicodeString cs2; | |
690 | Normalizer::decompose(srcStr, FALSE, 0, cs2, status); | |
691 | if (U_FAILURE(status)) { | |
692 | parent->errln("FAIL: Internal error during decomposition %s\n", u_errorName(status)); | |
693 | return; | |
694 | } | |
695 | UnicodeString targ2 = cs2; | |
696 | sourceToTarget->transliterate(targ2); | |
697 | if (targ != targ2) { | |
698 | logNotCanonical("Source-Target", srcStr, targ,cs2, targ2); | |
699 | } | |
700 | } | |
701 | ||
702 | parent->logln("Checking that all source characters convert to target - Doubles"); | |
703 | ||
704 | UnicodeSet sourceRangeMinusFailures(sourceRange); | |
705 | sourceRangeMinusFailures.removeAll(failSourceTarg); | |
706 | ||
707 | usi.reset(sourceRangeMinusFailures, quickRt, density); | |
708 | for (;;) { | |
709 | if (!usi.next() || usi.isString()) break; | |
710 | UChar32 c = usi.getCodepoint(); | |
711 | ||
712 | usi2.reset(sourceRangeMinusFailures, quickRt, density); | |
713 | for (;;) { | |
714 | if (!usi2.next() || usi2.isString()) break; | |
715 | UChar32 d = usi2.getCodepoint(); | |
716 | ||
717 | UnicodeString srcStr; | |
718 | srcStr += (UChar32)c; | |
719 | srcStr += (UChar32)d; | |
720 | UnicodeString targ = srcStr; | |
721 | sourceToTarget->transliterate(targ); | |
722 | if (toTarget.containsAll(targ) == FALSE || | |
723 | badCharacters.containsSome(targ) == TRUE) | |
724 | { | |
725 | UnicodeString targD; | |
726 | Normalizer::decompose(targ, FALSE, 0, targD, status); | |
727 | if (U_FAILURE(status)) { | |
728 | parent->errln("FAIL: Internal error during decomposition %s\n", u_errorName(status)); | |
729 | return; | |
730 | } | |
731 | if (toTarget.containsAll(targD) == FALSE || | |
732 | badCharacters.containsSome(targD) == TRUE) { | |
733 | logWrongScript("Source-Target", srcStr, targ); | |
734 | continue; | |
735 | } | |
736 | } | |
737 | UnicodeString cs2; | |
738 | Normalizer::decompose(srcStr, FALSE, 0, cs2, status); | |
739 | if (U_FAILURE(status)) { | |
740 | parent->errln("FAIL: Internal error during decomposition %s\n", u_errorName(status)); | |
741 | return; | |
742 | } | |
743 | UnicodeString targ2 = cs2; | |
744 | sourceToTarget->transliterate(targ2); | |
745 | if (targ != targ2) { | |
746 | logNotCanonical("Source-Target", srcStr, targ, cs2,targ2); | |
747 | } | |
748 | } | |
749 | } | |
750 | ||
751 | parent->logln("Checking that target characters convert to source and back - Singles"); | |
752 | ||
753 | UnicodeSet failTargSource; | |
754 | UnicodeSet failRound; | |
755 | ||
756 | usi.reset(targetRange); | |
757 | for (;;) { | |
758 | if (!usi.next()) break; | |
759 | ||
760 | if(usi.isString()){ | |
761 | srcStr = usi.getString(); | |
762 | }else{ | |
763 | srcStr = (UnicodeString)usi.getCodepoint(); | |
764 | } | |
765 | ||
766 | UChar32 c = srcStr.char32At(0); | |
767 | ||
768 | targ = srcStr; | |
769 | targetToSource->transliterate(targ); | |
770 | reverse = targ; | |
771 | sourceToTarget->transliterate(reverse); | |
772 | ||
773 | if (toSource.containsAll(targ) == FALSE || | |
774 | badCharacters.containsSome(targ) == TRUE) { | |
775 | UnicodeString targD; | |
776 | Normalizer::decompose(targ, FALSE, 0, targD, status); | |
777 | if (U_FAILURE(status)) { | |
778 | parent->errln("FAIL: Internal error during decomposition%s\n", u_errorName(status)); | |
779 | return; | |
780 | } | |
374ca955 | 781 | if (toSource.containsAll(targD) == FALSE) { |
b75a7d8f A |
782 | logWrongScript("Target-Source", srcStr, targ); |
783 | failTargSource.add(c); | |
784 | continue; | |
785 | } | |
374ca955 A |
786 | if (badCharacters.containsSome(targD) == TRUE) { |
787 | logWrongScript("Target-Source*", srcStr, targ); | |
788 | failTargSource.add(c); | |
789 | continue; | |
790 | } | |
b75a7d8f A |
791 | } |
792 | if (isSame(srcStr, reverse) == FALSE && | |
793 | roundtripExclusionsSet.contains(c) == FALSE | |
794 | && roundtripExclusionsSet.contains(srcStr)==FALSE) { | |
795 | logRoundTripFailure(srcStr,targetToSource->getID(), targ,sourceToTarget->getID(), reverse); | |
796 | failRound.add(c); | |
797 | continue; | |
798 | } | |
799 | ||
800 | UnicodeString targ2; | |
801 | Normalizer::decompose(targ, FALSE, 0, targ2, status); | |
802 | if (U_FAILURE(status)) { | |
803 | parent->errln("FAIL: Internal error during decomposition%s\n", u_errorName(status)); | |
804 | return; | |
805 | } | |
806 | UnicodeString reverse2 = targ2; | |
807 | sourceToTarget->transliterate(reverse2); | |
808 | if (reverse != reverse2) { | |
809 | logNotCanonical("Target-Source", targ, reverse, targ2, reverse2); | |
810 | } | |
811 | } | |
812 | ||
813 | parent->logln("Checking that target characters convert to source and back - Doubles"); | |
814 | int32_t count = 0; | |
815 | ||
816 | UnicodeSet targetRangeMinusFailures(targetRange); | |
817 | targetRangeMinusFailures.removeAll(failTargSource); | |
818 | targetRangeMinusFailures.removeAll(failRound); | |
819 | ||
820 | usi.reset(targetRangeMinusFailures, quickRt, density); | |
821 | UnicodeString targ2; | |
822 | UnicodeString reverse2; | |
823 | UnicodeString targD; | |
824 | for (;;) { | |
825 | if (!usi.next() || usi.isString()) break; | |
826 | UChar32 c = usi.getCodepoint(); | |
827 | if (++count > pairLimit) { | |
828 | //throw new TestTruncated("Test truncated at " + pairLimit + " x 64k pairs"); | |
829 | parent->logln(""); | |
830 | parent->logln((UnicodeString)"Test truncated at " + pairLimit + " x 64k pairs"); | |
831 | return; | |
832 | } | |
833 | ||
834 | usi2.reset(targetRangeMinusFailures, quickRt, density); | |
835 | for (;;) { | |
836 | if (!usi2.next() || usi2.isString()) | |
837 | break; | |
838 | UChar32 d = usi2.getCodepoint(); | |
839 | srcStr.truncate(0); // empty the variable without construction/destruction | |
840 | srcStr += c; | |
841 | srcStr += d; | |
842 | ||
843 | targ = srcStr; | |
844 | targetToSource->transliterate(targ); | |
845 | reverse = targ; | |
846 | sourceToTarget->transliterate(reverse); | |
847 | ||
848 | if (toSource.containsAll(targ) == FALSE || | |
849 | badCharacters.containsSome(targ) == TRUE) | |
850 | { | |
851 | targD.truncate(0); // empty the variable without construction/destruction | |
852 | Normalizer::decompose(targ, FALSE, 0, targD, status); | |
853 | if (U_FAILURE(status)) { | |
854 | parent->errln("FAIL: Internal error during decomposition%s\n", | |
855 | u_errorName(status)); | |
856 | return; | |
857 | } | |
858 | if (toSource.containsAll(targD) == FALSE | |
859 | || badCharacters.containsSome(targD) == TRUE) | |
860 | { | |
861 | logWrongScript("Target-Source", srcStr, targ); | |
862 | continue; | |
863 | } | |
864 | } | |
865 | if (isSame(srcStr, reverse) == FALSE && | |
866 | roundtripExclusionsSet.contains(c) == FALSE&& | |
867 | roundtripExclusionsSet.contains(d) == FALSE && | |
868 | roundtripExclusionsSet.contains(srcStr)== FALSE) | |
869 | { | |
870 | logRoundTripFailure(srcStr,targetToSource->getID(), targ, sourceToTarget->getID(),reverse); | |
871 | continue; | |
872 | } | |
873 | ||
874 | targ2.truncate(0); // empty the variable without construction/destruction | |
875 | Normalizer::decompose(targ, FALSE, 0, targ2, status); | |
876 | if (U_FAILURE(status)) { | |
877 | parent->errln("FAIL: Internal error during decomposition%s\n", u_errorName(status)); | |
878 | return; | |
879 | } | |
880 | reverse2 = targ2; | |
881 | sourceToTarget->transliterate(reverse2); | |
882 | if (reverse != reverse2) { | |
883 | logNotCanonical("Target-Source", targ,reverse, targ2, reverse2); | |
884 | } | |
885 | } | |
886 | } | |
887 | parent->logln(""); | |
888 | } | |
889 | ||
890 | void RTTest::logWrongScript(const UnicodeString& label, | |
891 | const UnicodeString& from, | |
892 | const UnicodeString& to) { | |
893 | parent->errln((UnicodeString)"FAIL " + | |
894 | label + ": " + | |
895 | from + "(" + TestUtility::hex(from) + ") => " + | |
896 | to + "(" + TestUtility::hex(to) + ")"); | |
897 | ++errorCount; | |
898 | } | |
899 | ||
900 | void RTTest::logNotCanonical(const UnicodeString& label, | |
901 | const UnicodeString& from, | |
902 | const UnicodeString& to, | |
903 | const UnicodeString& fromCan, | |
904 | const UnicodeString& toCan) { | |
905 | parent->errln((UnicodeString)"FAIL (can.equiv)" + | |
906 | label + ": " + | |
907 | from + "(" + TestUtility::hex(from) + ") => " + | |
908 | to + "(" + TestUtility::hex(to) + ")" + | |
909 | fromCan + "(" + TestUtility::hex(fromCan) + ") => " + | |
910 | toCan + " (" + | |
911 | TestUtility::hex(toCan) + ")" | |
912 | ); | |
913 | ++errorCount; | |
914 | } | |
915 | ||
916 | void RTTest::logFails(const UnicodeString& label) { | |
917 | parent->errln((UnicodeString)"<br>FAIL " + label); | |
918 | ++errorCount; | |
919 | } | |
920 | ||
921 | void RTTest::logToRulesFails(const UnicodeString& label, | |
922 | const UnicodeString& from, | |
923 | const UnicodeString& to, | |
924 | const UnicodeString& otherTo) | |
925 | { | |
926 | parent->errln((UnicodeString)"FAIL: " + | |
927 | label + ": " + | |
928 | from + "(" + TestUtility::hex(from) + ") => " + | |
929 | to + "(" + TestUtility::hex(to) + ")" + | |
930 | "!=" + | |
931 | otherTo + " (" + | |
932 | TestUtility::hex(otherTo) + ")" | |
933 | ); | |
934 | ++errorCount; | |
935 | } | |
936 | ||
937 | ||
938 | void RTTest::logRoundTripFailure(const UnicodeString& from, | |
939 | const UnicodeString& toID, | |
940 | const UnicodeString& to, | |
941 | const UnicodeString& backID, | |
942 | const UnicodeString& back) { | |
943 | if (legalSource->is(from) == FALSE) return; // skip illegals | |
944 | ||
945 | parent->errln((UnicodeString)"FAIL Roundtrip: " + | |
946 | from + "(" + TestUtility::hex(from) + ") => " + | |
947 | to + "(" + TestUtility::hex(to) + ") "+toID+" => " + | |
948 | back + "(" + TestUtility::hex(back) + ") "+backID+" => "); | |
949 | ++errorCount; | |
950 | } | |
951 | ||
952 | //-------------------------------------------------------------------- | |
953 | // Specific Tests | |
954 | //-------------------------------------------------------------------- | |
955 | ||
956 | /* | |
957 | Note: Unicode 3.2 added new Hiragana/Katakana characters: | |
958 | ||
959 | 3095..3096 ; 3.2 # [2] HIRAGANA LETTER SMALL KA..HIRAGANA LETTER SMALL KE | |
960 | 309F..30A0 ; 3.2 # [2] HIRAGANA DIGRAPH YORI..KATAKANA-HIRAGANA DOUBLE HYPHEN | |
961 | 30FF ; 3.2 # KATAKANA DIGRAPH KOTO | |
962 | 31F0..31FF ; 3.2 # [16] KATAKANA LETTER SMALL KU..KATAKANA LETTER SMALL RO | |
963 | ||
964 | We will not add them to the rules until they are more supported (e.g. in fonts on Windows) | |
965 | A bug has been filed to remind us to do this: #1979. | |
966 | */ | |
967 | ||
968 | static const char KATAKANA[] = "[[[:katakana:][\\u30A1-\\u30FA\\u30FC]]-[\\u30FF\\u31F0-\\u31FF]]"; | |
969 | static const char HIRAGANA[] = "[[[:hiragana:][\\u3040-\\u3094]]-[\\u3095-\\u3096\\u309F-\\u30A0]]"; | |
970 | static const char LENGTH[] = "[\\u30FC]"; | |
971 | static const char HALFWIDTH_KATAKANA[] = "[\\uFF65-\\uFF9D]"; | |
972 | static const char KATAKANA_ITERATION[] = "[\\u30FD\\u30FE]"; | |
973 | static const char HIRAGANA_ITERATION[] = "[\\u309D\\u309E]"; | |
974 | static const int32_t TEMP_MAX=256; | |
975 | ||
976 | void TransliteratorRoundTripTest::TestKana() { | |
977 | RTTest test("Katakana-Hiragana"); | |
978 | Legal *legal = new Legal(); | |
979 | char temp[TEMP_MAX]; | |
980 | strcpy(temp, "["); | |
981 | strcat(temp, HALFWIDTH_KATAKANA); | |
982 | strcat(temp, LENGTH); | |
983 | strcat(temp, "]"); | |
374ca955 | 984 | test.test(KATAKANA, UnicodeString("[") + HIRAGANA + LENGTH + UnicodeString("]"), |
b75a7d8f A |
985 | temp, |
986 | this, quick, legal); | |
987 | delete legal; | |
988 | } | |
989 | ||
990 | void TransliteratorRoundTripTest::TestHiragana() { | |
991 | RTTest test("Latin-Hiragana"); | |
992 | Legal *legal = new Legal(); | |
993 | test.test(UnicodeString("[a-zA-Z]", ""), | |
46f4442e | 994 | UnicodeString(HIRAGANA, -1, US_INV), |
b75a7d8f A |
995 | HIRAGANA_ITERATION, this, quick, legal); |
996 | delete legal; | |
997 | } | |
998 | ||
999 | void TransliteratorRoundTripTest::TestKatakana() { | |
1000 | RTTest test("Latin-Katakana"); | |
1001 | Legal *legal = new Legal(); | |
1002 | char temp[TEMP_MAX]; | |
1003 | strcpy(temp, "["); | |
1004 | strcat(temp, KATAKANA_ITERATION); | |
1005 | strcat(temp, HALFWIDTH_KATAKANA); | |
1006 | strcat(temp, "]"); | |
1007 | test.test(UnicodeString("[a-zA-Z]", ""), | |
46f4442e | 1008 | UnicodeString(KATAKANA, -1, US_INV), |
b75a7d8f A |
1009 | temp, |
1010 | this, quick, legal); | |
1011 | delete legal; | |
1012 | } | |
1013 | ||
1014 | void TransliteratorRoundTripTest::TestJamo() { | |
1015 | RTTest t("Latin-Jamo"); | |
1016 | Legal *legal = new LegalJamo(); | |
1017 | t.test(UnicodeString("[a-zA-Z]", ""), | |
1018 | UnicodeString("[\\u1100-\\u1112 \\u1161-\\u1175 \\u11A8-\\u11C2]", | |
1019 | ""), | |
1020 | NULL, this, quick, legal); | |
1021 | delete legal; | |
1022 | } | |
1023 | ||
1024 | void TransliteratorRoundTripTest::TestHangul() { | |
1025 | RTTest t("Latin-Hangul"); | |
1026 | Legal *legal = new Legal(); | |
1027 | if (quick) t.setPairLimit(1000); | |
1028 | t.test(UnicodeString("[a-zA-Z]", ""), | |
1029 | UnicodeString("[\\uAC00-\\uD7A4]", ""), | |
1030 | NULL, this, quick, legal, 1); | |
1031 | delete legal; | |
1032 | } | |
1033 | ||
374ca955 A |
1034 | |
1035 | #define ASSERT_SUCCESS(status) {if (U_FAILURE(status)) { \ | |
1036 | errln("error at file %s, line %d, status = %s", __FILE__, __LINE__, \ | |
1037 | u_errorName(status)); \ | |
1038 | return;}} | |
1039 | ||
1040 | ||
1041 | static void writeStringInU8(FILE *out, const UnicodeString &s) { | |
1042 | int i; | |
1043 | for (i=0; i<s.length(); i=s.moveIndex32(i, 1)) { | |
1044 | UChar32 c = s.char32At(i); | |
1045 | uint8_t bufForOneChar[10]; | |
1046 | UBool isError = FALSE; | |
1047 | int32_t destIdx = 0; | |
73c04bcf | 1048 | U8_APPEND(bufForOneChar, destIdx, (int32_t)sizeof(bufForOneChar), c, isError); |
374ca955 A |
1049 | fwrite(bufForOneChar, 1, destIdx, out); |
1050 | } | |
1051 | } | |
1052 | ||
1053 | ||
1054 | ||
1055 | ||
1056 | void TransliteratorRoundTripTest::TestHan() { | |
1057 | UErrorCode status = U_ZERO_ERROR; | |
1058 | ||
1059 | // TODO: getExemplars() exists only as a C API, taking a USet. | |
1060 | // The set API we need to use exists only on UnicodeSet, not on USet. | |
1061 | // Do a hacky cast, knowing that a USet is really a UnicodeSet in | |
1062 | // the implementation. Once USet gets the missing API, switch back | |
1063 | // to using that. | |
1064 | USet *USetExemplars = NULL; | |
73c04bcf | 1065 | ULocaleData *uld = ulocdata_open("zh",&status); |
374ca955 | 1066 | USetExemplars = uset_open(0, 0); |
73c04bcf | 1067 | USetExemplars = ulocdata_getExemplarSet(uld, USetExemplars, 0, ULOCDATA_ES_STANDARD, &status); |
374ca955 | 1068 | ASSERT_SUCCESS(status); |
73c04bcf | 1069 | ulocdata_close(uld); |
374ca955 A |
1070 | |
1071 | UnicodeString source; | |
1072 | UChar32 c; | |
1073 | int i; | |
1074 | for (i=0; ;i++) { | |
1075 | // Add all of the Chinese exemplar chars to the string "source". | |
46f4442e | 1076 | c = uset_charAt(USetExemplars, i); |
374ca955 A |
1077 | if (c == (UChar32)-1) { |
1078 | break; | |
1079 | } | |
1080 | source.append(c); | |
1081 | } | |
1082 | ||
1083 | // transform with Han translit | |
1084 | Transliterator *hanTL = Transliterator::createInstance("Han-Latin", UTRANS_FORWARD, status); | |
1085 | ASSERT_SUCCESS(status); | |
1086 | UnicodeString target=source; | |
1087 | hanTL->transliterate(target); | |
1088 | // now verify that there are no Han characters left | |
1089 | UnicodeSet allHan("[:han:]", status); | |
1090 | ASSERT_SUCCESS(status); | |
1091 | if (allHan.containsSome(target)) { | |
1092 | errln("file %s, line %d, No Han must be left after Han-Latin transliteration", | |
1093 | __FILE__, __LINE__); | |
1094 | } | |
1095 | ||
1096 | // check the pinyin translit | |
1097 | Transliterator *pn = Transliterator::createInstance("Latin-NumericPinyin", UTRANS_FORWARD, status); | |
1098 | ASSERT_SUCCESS(status); | |
1099 | UnicodeString target2 = target; | |
1100 | pn->transliterate(target2); | |
1101 | ||
1102 | // verify that there are no marks | |
73c04bcf | 1103 | Transliterator *nfd = Transliterator::createInstance("nfd", UTRANS_FORWARD, status); |
374ca955 A |
1104 | ASSERT_SUCCESS(status); |
1105 | ||
73c04bcf A |
1106 | UnicodeString nfded = target2; |
1107 | nfd->transliterate(nfded); | |
46f4442e | 1108 | UnicodeSet allMarks(UNICODE_STRING_SIMPLE("[\\u0304\\u0301\\u030C\\u0300\\u0306]"), status); // look only for Pinyin tone marks, not all marks (there are some others in there) |
374ca955 | 1109 | ASSERT_SUCCESS(status); |
73c04bcf | 1110 | assertFalse("NumericPinyin must contain no marks", allMarks.containsSome(nfded)); |
374ca955 A |
1111 | |
1112 | // verify roundtrip | |
1113 | Transliterator *np = pn->createInverse(status); | |
1114 | ASSERT_SUCCESS(status); | |
73c04bcf | 1115 | UnicodeString target3 = target2; |
374ca955 A |
1116 | np->transliterate(target3); |
1117 | UBool roundtripOK = (target3.compare(target) == 0); | |
1118 | assertTrue("NumericPinyin must roundtrip", roundtripOK); | |
1119 | if (!roundtripOK) { | |
1120 | const char *filename = "numeric-pinyin.log.txt"; | |
1121 | FILE *out = fopen(filename, "w"); | |
1122 | errln("Creating log file %s\n", filename); | |
1123 | fprintf(out, "Pinyin: "); | |
1124 | writeStringInU8(out, target); | |
1125 | fprintf(out, "\nPinyin-Numeric-Pinyin: "); | |
1126 | writeStringInU8(out, target2); | |
73c04bcf A |
1127 | fprintf(out, "\nNumeric-Pinyin-Pinyin: "); |
1128 | writeStringInU8(out, target3); | |
374ca955 A |
1129 | fprintf(out, "\n"); |
1130 | fclose(out); | |
1131 | } | |
1132 | ||
1133 | delete hanTL; | |
1134 | delete pn; | |
73c04bcf | 1135 | delete nfd; |
374ca955 A |
1136 | delete np; |
1137 | uset_close(USetExemplars); | |
1138 | } | |
1139 | ||
1140 | ||
b75a7d8f | 1141 | void TransliteratorRoundTripTest::TestGreek() { |
73c04bcf | 1142 | |
46f4442e | 1143 | if (isICUVersionAtLeast(ICU_39)) { |
73c04bcf A |
1144 | // We temporarily filter against Unicode 4.1, but we only do this |
1145 | // before version 3.4. | |
1146 | errln("FAIL: TestGreek needs to be updated to remove delete the [:Age=4.0:] filter "); | |
b75a7d8f A |
1147 | return; |
1148 | } else { | |
73c04bcf | 1149 | logln("Warning: TestGreek needs to be updated to remove delete the section marked [:Age=4.0:] filter"); |
b75a7d8f | 1150 | } |
73c04bcf | 1151 | |
b75a7d8f A |
1152 | RTTest test("Latin-Greek"); |
1153 | LegalGreek *legal = new LegalGreek(TRUE); | |
1154 | ||
1155 | test.test(UnicodeString("[a-zA-Z]", ""), | |
374ca955 A |
1156 | UnicodeString("[\\u003B\\u00B7[[:Greek:]&[:Letter:]]-[" |
1157 | "\\u1D26-\\u1D2A" // L& [5] GREEK LETTER SMALL CAPITAL GAMMA..GREEK LETTER SMALL CAPITAL PSI | |
1158 | "\\u1D5D-\\u1D61" // Lm [5] MODIFIER LETTER SMALL BETA..MODIFIER LETTER SMALL CHI | |
1159 | "\\u1D66-\\u1D6A" // L& [5] GREEK SUBSCRIPT SMALL LETTER BETA..GREEK SUBSCRIPT SMALL LETTER CHI | |
1160 | "\\u03D7-\\u03EF" // \N{GREEK KAI SYMBOL}..\N{COPTIC SMALL LETTER DEI} | |
73c04bcf | 1161 | "] & [:Age=4.0:]]", |
374ca955 A |
1162 | |
1163 | //UnicodeString("[[\\u003B\\u00B7[:Greek:]-[\\u0374\\u0385\\u1fcd\\u1fce\\u1fdd\\u1fde\\u1fed-\\u1fef\\u1ffd\\u03D7-\\u03EF]]&[:Age=3.2:]]", | |
b75a7d8f | 1164 | ""), |
374ca955 | 1165 | "[\\u00B5\\u037A\\u03D0-\\u03F5\\u03f9]", /* exclusions */ |
b75a7d8f A |
1166 | this, quick, legal, 50); |
1167 | ||
1168 | ||
1169 | delete legal; | |
1170 | } | |
1171 | ||
1172 | ||
1173 | void TransliteratorRoundTripTest::TestGreekUNGEGN() { | |
73c04bcf | 1174 | |
46f4442e | 1175 | if (isICUVersionAtLeast(ICU_39)) { |
73c04bcf A |
1176 | // We temporarily filter against Unicode 4.1, but we only do this |
1177 | // before version 3.4. | |
1178 | errln("FAIL: TestGreek needs to be updated to remove delete the [:Age=4.0:] filter "); | |
b75a7d8f A |
1179 | return; |
1180 | } else { | |
73c04bcf | 1181 | logln("Warning: TestGreek needs to be updated to remove delete the section marked [:Age=4.0:] filter"); |
b75a7d8f | 1182 | } |
73c04bcf | 1183 | |
b75a7d8f A |
1184 | RTTest test("Latin-Greek/UNGEGN"); |
1185 | LegalGreek *legal = new LegalGreek(FALSE); | |
1186 | ||
1187 | test.test(UnicodeString("[a-zA-Z]", ""), | |
374ca955 A |
1188 | UnicodeString("[\\u003B\\u00B7[[:Greek:]&[:Letter:]]-[" |
1189 | "\\u1D26-\\u1D2A" // L& [5] GREEK LETTER SMALL CAPITAL GAMMA..GREEK LETTER SMALL CAPITAL PSI | |
1190 | "\\u1D5D-\\u1D61" // Lm [5] MODIFIER LETTER SMALL BETA..MODIFIER LETTER SMALL CHI | |
1191 | "\\u1D66-\\u1D6A" // L& [5] GREEK SUBSCRIPT SMALL LETTER BETA..GREEK SUBSCRIPT SMALL LETTER CHI | |
1192 | "\\u03D7-\\u03EF" // \N{GREEK KAI SYMBOL}..\N{COPTIC SMALL LETTER DEI} | |
73c04bcf | 1193 | "] & [:Age=4.0:]]", |
374ca955 | 1194 | //UnicodeString("[[\\u003B\\u00B7[:Greek:]-[\\u0374\\u0385\\u1fce\\u1fde\\u03D7-\\u03EF]]&[:Age=3.2:]]", |
b75a7d8f | 1195 | ""), |
374ca955 | 1196 | "[\\u0385\\u00B5\\u037A\\u03D0-\\uFFFF {\\u039C\\u03C0}]", /* roundtrip exclusions */ |
b75a7d8f A |
1197 | this, quick, legal); |
1198 | ||
1199 | delete legal; | |
1200 | } | |
1201 | ||
1202 | void TransliteratorRoundTripTest::Testel() { | |
73c04bcf | 1203 | |
46f4442e | 1204 | if (isICUVersionAtLeast(ICU_39)) { |
73c04bcf A |
1205 | // We temporarily filter against Unicode 4.1, but we only do this |
1206 | // before version 3.4. | |
1207 | errln("FAIL: TestGreek needs to be updated to remove delete the [:Age=4.0:] filter "); | |
b75a7d8f A |
1208 | return; |
1209 | } else { | |
73c04bcf | 1210 | logln("Warning: TestGreek needs to be updated to remove delete the section marked [:Age=4.0:] filter"); |
b75a7d8f | 1211 | } |
73c04bcf | 1212 | |
b75a7d8f A |
1213 | RTTest test("Latin-el"); |
1214 | LegalGreek *legal = new LegalGreek(FALSE); | |
1215 | ||
1216 | test.test(UnicodeString("[a-zA-Z]", ""), | |
374ca955 A |
1217 | UnicodeString("[\\u003B\\u00B7[[:Greek:]&[:Letter:]]-[" |
1218 | "\\u1D26-\\u1D2A" // L& [5] GREEK LETTER SMALL CAPITAL GAMMA..GREEK LETTER SMALL CAPITAL PSI | |
1219 | "\\u1D5D-\\u1D61" // Lm [5] MODIFIER LETTER SMALL BETA..MODIFIER LETTER SMALL CHI | |
1220 | "\\u1D66-\\u1D6A" // L& [5] GREEK SUBSCRIPT SMALL LETTER BETA..GREEK SUBSCRIPT SMALL LETTER CHI | |
1221 | "\\u03D7-\\u03EF" // \N{GREEK KAI SYMBOL}..\N{COPTIC SMALL LETTER DEI} | |
73c04bcf | 1222 | "] & [:Age=4.0:]]", |
374ca955 | 1223 | //UnicodeString("[[\\u003B\\u00B7[:Greek:]-[\\u0374\\u0385\\u1fce\\u1fde\\u03D7-\\u03EF]]&[:Age=3.2:]]", |
b75a7d8f A |
1224 | ""), |
1225 | "[\\u00B5\\u037A\\u03D0-\\uFFFF {\\u039C\\u03C0}]", /* exclusions */ | |
1226 | this, quick, legal); | |
1227 | ||
1228 | ||
1229 | delete legal; | |
1230 | } | |
1231 | ||
374ca955 A |
1232 | |
1233 | void TransliteratorRoundTripTest::TestArabic() { | |
46f4442e | 1234 | UnicodeString ARABIC("[\\u060C\\u061B\\u061F\\u0621\\u0627-\\u063A\\u0641-\\u0655\\u0660-\\u066C\\u067E\\u0686\\u0698\\u06A4\\u06AD\\u06AF\\u06CB-\\u06CC\\u06F0-\\u06F9]", -1, US_INV); |
374ca955 A |
1235 | Legal *legal = new Legal(); |
1236 | RTTest test("Latin-Arabic"); | |
46f4442e | 1237 | test.test(UNICODE_STRING_SIMPLE("[a-zA-Z\\u02BE\\u02BF\\u207F]"), ARABIC, "[a-zA-Z\\u02BE\\u02BF\\u207F]",this, quick, legal); // |
374ca955 A |
1238 | delete legal; |
1239 | } | |
1240 | class LegalHebrew : public Legal { | |
1241 | private: | |
1242 | UnicodeSet FINAL; | |
1243 | UnicodeSet NON_FINAL; | |
1244 | UnicodeSet LETTER; | |
1245 | public: | |
1246 | LegalHebrew(UErrorCode& error); | |
1247 | virtual ~LegalHebrew() {} | |
1248 | virtual UBool is(const UnicodeString& sourceString) const; | |
1249 | }; | |
1250 | ||
1251 | LegalHebrew::LegalHebrew(UErrorCode& error){ | |
46f4442e A |
1252 | FINAL.applyPattern(UNICODE_STRING_SIMPLE("[\\u05DA\\u05DD\\u05DF\\u05E3\\u05E5]"), error); |
1253 | NON_FINAL.applyPattern(UNICODE_STRING_SIMPLE("[\\u05DB\\u05DE\\u05E0\\u05E4\\u05E6]"), error); | |
374ca955 A |
1254 | LETTER.applyPattern("[:letter:]", error); |
1255 | } | |
1256 | UBool LegalHebrew::is(const UnicodeString& sourceString)const{ | |
1257 | ||
1258 | if (sourceString.length() == 0) return TRUE; | |
1259 | // don't worry about surrogates. | |
1260 | for (int i = 0; i < sourceString.length(); ++i) { | |
1261 | UChar ch = sourceString.charAt(i); | |
1262 | UChar next = i+1 == sourceString.length() ? 0x0000 : sourceString.charAt(i); | |
1263 | if (FINAL.contains(ch)) { | |
1264 | if (LETTER.contains(next)) return FALSE; | |
1265 | } else if (NON_FINAL.contains(ch)) { | |
1266 | if (!LETTER.contains(next)) return FALSE; | |
1267 | } | |
1268 | } | |
1269 | return TRUE; | |
1270 | } | |
1271 | void TransliteratorRoundTripTest::TestHebrew() { | |
46f4442e | 1272 | if (isICUVersionAtLeast(ICU_39)) { |
73c04bcf A |
1273 | // We temporarily filter against Unicode 4.1, but we only do this |
1274 | // before version 3.4. | |
1275 | errln("FAIL: TestHebrew needs to be updated to remove delete the [:Age=4.0:] filter "); | |
1276 | return; | |
1277 | } else { | |
1278 | logln("Warning: TestHebrew needs to be updated to remove delete the section marked [:Age=4.0:] filter"); | |
1279 | } | |
374ca955 A |
1280 | //long start = System.currentTimeMillis(); |
1281 | UErrorCode error = U_ZERO_ERROR; | |
1282 | LegalHebrew* legal = new LegalHebrew(error); | |
1283 | if(U_FAILURE(error)){ | |
1284 | errln("Could not construct LegalHebrew object. Error: %s", u_errorName(error)); | |
1285 | return; | |
1286 | } | |
1287 | RTTest test("Latin-Hebrew"); | |
46f4442e | 1288 | test.test(UNICODE_STRING_SIMPLE("[a-zA-Z\\u02BC\\u02BB]"), UNICODE_STRING_SIMPLE("[[[:hebrew:]-[\\u05BD\\uFB00-\\uFBFF]]&[:Age=4.0:]]"), "[\\u05F0\\u05F1\\u05F2]", this, quick, legal); |
73c04bcf | 1289 | |
374ca955 A |
1290 | //showElapsed(start, "TestHebrew"); |
1291 | delete legal; | |
1292 | } | |
b75a7d8f A |
1293 | void TransliteratorRoundTripTest::TestCyrillic() { |
1294 | RTTest test("Latin-Cyrillic"); | |
1295 | Legal *legal = new Legal(); | |
1296 | ||
1297 | test.test(UnicodeString("[a-zA-Z\\u0110\\u0111\\u02BA\\u02B9]", ""), | |
1298 | UnicodeString("[[\\u0400-\\u045F] & [:Age=3.2:]]", ""), NULL, this, quick, | |
1299 | legal); | |
1300 | ||
1301 | delete legal; | |
1302 | } | |
1303 | ||
1304 | ||
1305 | // Inter-Indic Tests ---------------------------------- | |
1306 | class LegalIndic :public Legal{ | |
1307 | UnicodeSet vowelSignSet; | |
1308 | UnicodeSet avagraha; | |
1309 | UnicodeSet nukta; | |
1310 | UnicodeSet virama; | |
1311 | UnicodeSet sanskritStressSigns; | |
1312 | UnicodeSet chandrabindu; | |
1313 | ||
73c04bcf A |
1314 | public: |
1315 | LegalIndic(); | |
b75a7d8f A |
1316 | virtual UBool is(const UnicodeString& sourceString) const; |
1317 | virtual ~LegalIndic() {}; | |
1318 | }; | |
1319 | UBool LegalIndic::is(const UnicodeString& sourceString) const{ | |
1320 | int cp=sourceString.charAt(0); | |
1321 | ||
1322 | // A vowel sign cannot be the first char | |
1323 | if(vowelSignSet.contains(cp)){ | |
1324 | return FALSE; | |
1325 | }else if(avagraha.contains(cp)){ | |
1326 | return FALSE; | |
1327 | }else if(virama.contains(cp)){ | |
1328 | return FALSE; | |
1329 | }else if(nukta.contains(cp)){ | |
1330 | return FALSE; | |
1331 | }else if(sanskritStressSigns.contains(cp)){ | |
1332 | return FALSE; | |
1333 | }else if(chandrabindu.contains(cp) && | |
1334 | ((sourceString.length()>1) && | |
1335 | vowelSignSet.contains(sourceString.charAt(1)))){ | |
1336 | return FALSE; | |
1337 | } | |
1338 | return TRUE; | |
1339 | } | |
73c04bcf A |
1340 | LegalIndic::LegalIndic(){ |
1341 | UErrorCode status = U_ZERO_ERROR; | |
1342 | vowelSignSet.addAll( UnicodeSet("[\\u0902\\u0903\\u0904\\u093e-\\u094c\\u0962\\u0963]",status));/* Devanagari */ | |
1343 | vowelSignSet.addAll( UnicodeSet("[\\u0982\\u0983\\u09be-\\u09cc\\u09e2\\u09e3\\u09D7]",status));/* Bengali */ | |
1344 | vowelSignSet.addAll( UnicodeSet("[\\u0a02\\u0a03\\u0a3e-\\u0a4c\\u0a62\\u0a63\\u0a70\\u0a71]",status));/* Gurmukhi */ | |
1345 | vowelSignSet.addAll( UnicodeSet("[\\u0a82\\u0a83\\u0abe-\\u0acc\\u0ae2\\u0ae3]",status));/* Gujarati */ | |
1346 | vowelSignSet.addAll( UnicodeSet("[\\u0b02\\u0b03\\u0b3e-\\u0b4c\\u0b62\\u0b63\\u0b56\\u0b57]",status));/* Oriya */ | |
1347 | vowelSignSet.addAll( UnicodeSet("[\\u0b82\\u0b83\\u0bbe-\\u0bcc\\u0be2\\u0be3\\u0bd7]",status));/* Tamil */ | |
1348 | vowelSignSet.addAll( UnicodeSet("[\\u0c02\\u0c03\\u0c3e-\\u0c4c\\u0c62\\u0c63\\u0c55\\u0c56]",status));/* Telugu */ | |
1349 | vowelSignSet.addAll( UnicodeSet("[\\u0c82\\u0c83\\u0cbe-\\u0ccc\\u0ce2\\u0ce3\\u0cd5\\u0cd6]",status));/* Kannada */ | |
1350 | vowelSignSet.addAll( UnicodeSet("[\\u0d02\\u0d03\\u0d3e-\\u0d4c\\u0d62\\u0d63\\u0d57]",status));/* Malayalam */ | |
1351 | ||
1352 | avagraha.addAll(UnicodeSet("[\\u093d\\u09bd\\u0abd\\u0b3d\\u0cbd]",status)); | |
1353 | nukta.addAll(UnicodeSet("[\\u093c\\u09bc\\u0a3c\\u0abc\\u0b3c\\u0cbc]",status)); | |
1354 | virama.addAll(UnicodeSet("[\\u094d\\u09cd\\u0a4d\\u0acd\\u0b4d\\u0bcd\\u0c4d\\u0ccd\\u0d4d]",status)); | |
1355 | sanskritStressSigns.addAll(UnicodeSet("[\\u0951\\u0952\\u0953\\u0954\\u097d]",status)); | |
1356 | chandrabindu.addAll(UnicodeSet("[\\u0901\\u0981\\u0A81\\u0b01\\u0c01]",status)); | |
1357 | ||
1358 | } | |
b75a7d8f A |
1359 | |
1360 | static const char latinForIndic[] = "[['.0-9A-Za-z~\\u00C0-\\u00C5\\u00C7-\\u00CF\\u00D1-\\u00D6\\u00D9-\\u00DD" | |
1361 | "\\u00E0-\\u00E5\\u00E7-\\u00EF\\u00F1-\\u00F6\\u00F9-\\u00FD\\u00FF-\\u010F" | |
1362 | "\\u0112-\\u0125\\u0128-\\u0130\\u0134-\\u0137\\u0139-\\u013E\\u0143-\\u0148" | |
1363 | "\\u014C-\\u0151\\u0154-\\u0165\\u0168-\\u017E\\u01A0-\\u01A1\\u01AF-\\u01B0" | |
1364 | "\\u01CD-\\u01DC\\u01DE-\\u01E3\\u01E6-\\u01ED\\u01F0\\u01F4-\\u01F5\\u01F8-\\u01FB" | |
73c04bcf | 1365 | "\\u0200-\\u021B\\u021E-\\u021F\\u0226-\\u0233\\u0294\\u0303-\\u0304\\u0306\\u0314-\\u0315" |
b75a7d8f A |
1366 | "\\u0325\\u040E\\u0419\\u0439\\u045E\\u04C1-\\u04C2\\u04D0-\\u04D1\\u04D6-\\u04D7" |
1367 | "\\u04E2-\\u04E3\\u04EE-\\u04EF\\u1E00-\\u1E99\\u1EA0-\\u1EF9\\u1F01\\u1F03\\u1F05" | |
1368 | "\\u1F07\\u1F09\\u1F0B\\u1F0D\\u1F0F\\u1F11\\u1F13\\u1F15\\u1F19\\u1F1B\\u1F1D\\u1F21" | |
1369 | "\\u1F23\\u1F25\\u1F27\\u1F29\\u1F2B\\u1F2D\\u1F2F\\u1F31\\u1F33\\u1F35\\u1F37\\u1F39" | |
1370 | "\\u1F3B\\u1F3D\\u1F3F\\u1F41\\u1F43\\u1F45\\u1F49\\u1F4B\\u1F4D\\u1F51\\u1F53\\u1F55" | |
1371 | "\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F\\u1F61\\u1F63\\u1F65\\u1F67\\u1F69\\u1F6B\\u1F6D" | |
1372 | "\\u1F6F\\u1F81\\u1F83\\u1F85\\u1F87\\u1F89\\u1F8B\\u1F8D\\u1F8F\\u1F91\\u1F93\\u1F95" | |
1373 | "\\u1F97\\u1F99\\u1F9B\\u1F9D\\u1F9F\\u1FA1\\u1FA3\\u1FA5\\u1FA7\\u1FA9\\u1FAB\\u1FAD" | |
1374 | "\\u1FAF-\\u1FB1\\u1FB8-\\u1FB9\\u1FD0-\\u1FD1\\u1FD8-\\u1FD9\\u1FE0-\\u1FE1\\u1FE5" | |
1375 | "\\u1FE8-\\u1FE9\\u1FEC\\u212A-\\u212B\\uE04D\\uE064]" | |
1376 | "-[\\uE000-\\uE080 \\u01E2\\u01E3]& [[:latin:][:mark:]]]"; | |
1377 | ||
1378 | void TransliteratorRoundTripTest::TestDevanagariLatin() { | |
1379 | { | |
1380 | UErrorCode status = U_ZERO_ERROR; | |
374ca955 A |
1381 | UParseError parseError; |
1382 | TransliteratorPointer t1(Transliterator::createInstance("[\\u0964-\\u0965\\u0981-\\u0983\\u0985-\\u098C\\u098F-\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BC\\u09BE-\\u09C4\\u09C7-\\u09C8\\u09CB-\\u09CD\\u09D7\\u09DC-\\u09DD\\u09DF-\\u09E3\\u09E6-\\u09FA];NFD;Bengali-InterIndic;InterIndic-Gujarati;NFC;",UTRANS_FORWARD, parseError, status)); | |
1383 | if((Transliterator *)t1 != NULL){ | |
b75a7d8f A |
1384 | TransliteratorPointer t2(t1->createInverse(status)); |
1385 | if(U_FAILURE(status)){ | |
1386 | errln("FAIL: could not create the Inverse:-( \n"); | |
1387 | } | |
374ca955 A |
1388 | }else { |
1389 | errln("FAIL: could not create the transliterator. Error: %s\n", u_errorName(status)); | |
b75a7d8f | 1390 | } |
374ca955 | 1391 | |
b75a7d8f A |
1392 | } |
1393 | RTTest test("Latin-Devanagari"); | |
1394 | Legal *legal = new LegalIndic(); | |
46f4442e | 1395 | if (isICUVersionAtLeast(ICU_39)) { |
73c04bcf A |
1396 | // We temporarily filter against Unicode 4.1, but we only do this |
1397 | // before version 3.4. | |
1398 | errln("FAIL: TestDevanagariLatin needs to be updated to remove delete the [:Age=4.1:] filter "); | |
1399 | return; | |
1400 | } else { | |
1401 | logln("Warning: TestDevanagariLatin needs to be updated to remove delete the section marked [:Age=4.1:] filter"); | |
1402 | } | |
b75a7d8f | 1403 | test.test(UnicodeString(latinForIndic, ""), |
73c04bcf | 1404 | UnicodeString("[[[:Devanagari:][\\u094d][\\u0964\\u0965]]&[:Age=4.1:]]", ""), "[\\u0965\\u0904]", this, quick, |
374ca955 A |
1405 | legal, 50); |
1406 | ||
b75a7d8f A |
1407 | delete legal; |
1408 | } | |
1409 | ||
1410 | /* Defined this way for HP/UX11CC :-( */ | |
1411 | static const int32_t INTER_INDIC_ARRAY_WIDTH = 4; | |
1412 | static const char * const interIndicArray[] = { | |
73c04bcf | 1413 | |
b75a7d8f | 1414 | "BENGALI-DEVANAGARI", "[:BENGALI:]", "[:Devanagari:]", |
73c04bcf | 1415 | "[\\u0904\\u0951-\\u0954\\u0943-\\u0949\\u094a\\u0962\\u0963\\u090D\\u090e\\u0911\\u0912\\u0929\\u0933\\u0934\\u0935\\u093d\\u0950\\u0958\\u0959\\u095a\\u095b\\u095e\\u097d]", /*roundtrip exclusions*/ |
b75a7d8f A |
1416 | |
1417 | "DEVANAGARI-BENGALI", "[:Devanagari:]", "[:BENGALI:]", | |
73c04bcf | 1418 | "[\\u0951-\\u0954\\u0951-\\u0954\\u09D7\\u090D\\u090e\\u0911\\u0912\\u0929\\u0933\\u0934\\u0935\\u093d\\u0950\\u0958\\u0959\\u095a\\u095b\\u095e\\u09f0\\u09f1\\u09f2-\\u09fa\\u09ce]", /*roundtrip exclusions*/ |
b75a7d8f A |
1419 | |
1420 | "GURMUKHI-DEVANAGARI", "[:GURMUKHI:]", "[:Devanagari:]", | |
73c04bcf | 1421 | "[\\u0904\\u0901\\u0902\\u0936\\u0933\\u0951-\\u0954\\u0902\\u0903\\u0943-\\u0949\\u094a\\u0962\\u0963\\u090B\\u090C\\u090D\\u090e\\u0911\\u0912\\u0934\\u0937\\u093D\\u0950\\u0960\\u0961\\u097d]", /*roundtrip exclusions*/ |
b75a7d8f A |
1422 | |
1423 | "DEVANAGARI-GURMUKHI", "[:Devanagari:]", "[:GURMUKHI:]", | |
374ca955 | 1424 | "[\\u0904\\u0A02\\u0946\\u0A5C\\u0951-\\u0954\\u0A70\\u0A71\\u090B\\u090C\\u090D\\u090e\\u0911\\u0912\\u0934\\u0937\\u093D\\u0950\\u0960\\u0961\\u0a72\\u0a73\\u0a74]", /*roundtrip exclusions*/ |
b75a7d8f A |
1425 | |
1426 | "GUJARATI-DEVANAGARI", "[:GUJARATI:]", "[:Devanagari:]", | |
73c04bcf | 1427 | "[\\u0946\\u094A\\u0962\\u0963\\u0951-\\u0954\\u0961\\u090c\\u090e\\u0912\\u097d]", /*roundtrip exclusions*/ |
b75a7d8f A |
1428 | |
1429 | "DEVANAGARI-GUJARATI", "[:Devanagari:]", "[:GUJARATI:]", | |
1430 | "[\\u0951-\\u0954\\u0961\\u090c\\u090e\\u0912]", /*roundtrip exclusions*/ | |
1431 | ||
1432 | "ORIYA-DEVANAGARI", "[:ORIYA:]", "[:Devanagari:]", | |
73c04bcf | 1433 | "[\\u0904\\u0943-\\u094a\\u0962\\u0963\\u0951-\\u0954\\u0950\\u090D\\u090e\\u0912\\u0911\\u0931\\u0935\\u097d]", /*roundtrip exclusions*/ |
b75a7d8f A |
1434 | |
1435 | "DEVANAGARI-ORIYA", "[:Devanagari:]", "[:ORIYA:]", | |
374ca955 | 1436 | "[\\u0b5f\\u0b56\\u0b57\\u0b70\\u0b71\\u0950\\u090D\\u090e\\u0912\\u0911\\u0931]", /*roundtrip exclusions*/ |
b75a7d8f A |
1437 | |
1438 | "Tamil-DEVANAGARI", "[:tamil:]", "[:Devanagari:]", | |
73c04bcf | 1439 | "[\\u0901\\u0904\\u093c\\u0943-\\u094a\\u0951-\\u0954\\u0962\\u0963\\u090B\\u090C\\u090D\\u0911\\u0916\\u0917\\u0918\\u091B\\u091D\\u0920\\u0921\\u0922\\u0925\\u0926\\u0927\\u092B\\u092C\\u092D\\u0936\\u093d\\u0950[\\u0958-\\u0961]\\u097d]", /*roundtrip exclusions*/ |
b75a7d8f A |
1440 | |
1441 | "DEVANAGARI-Tamil", "[:Devanagari:]", "[:tamil:]", | |
46f4442e | 1442 | "[\\u0bd7\\u0BF0\\u0BF1\\u0BF2]", /*roundtrip exclusions*/ |
b75a7d8f A |
1443 | |
1444 | "Telugu-DEVANAGARI", "[:telugu:]", "[:Devanagari:]", | |
73c04bcf | 1445 | "[\\u0904\\u093c\\u0950\\u0945\\u0949\\u0951-\\u0954\\u0962\\u0963\\u090D\\u0911\\u093d\\u0929\\u0934[\\u0958-\\u095f]\\u097d]", /*roundtrip exclusions*/ |
b75a7d8f A |
1446 | |
1447 | "DEVANAGARI-TELUGU", "[:Devanagari:]", "[:TELUGU:]", | |
1448 | "[\\u0c55\\u0c56\\u0950\\u090D\\u0911\\u093d\\u0929\\u0934[\\u0958-\\u095f]]", /*roundtrip exclusions*/ | |
1449 | ||
1450 | "KANNADA-DEVANAGARI", "[:KANNADA:]", "[:Devanagari:]", | |
73c04bcf | 1451 | "[\\u0901\\u0904\\u0946\\u093c\\u0950\\u0945\\u0949\\u0951-\\u0954\\u0962\\u0963\\u0950\\u090D\\u0911\\u093d\\u0929\\u0934[\\u0958-\\u095f]\\u097d]", /*roundtrip exclusions*/ |
b75a7d8f A |
1452 | |
1453 | "DEVANAGARI-KANNADA", "[:Devanagari:]", "[:KANNADA:]", | |
374ca955 | 1454 | "[{\\u0cb0\\u0cbc}{\\u0cb3\\u0cbc}\\u0cde\\u0cd5\\u0cd6\\u0950\\u090D\\u0911\\u093d\\u0929\\u0934[\\u0958-\\u095f]]", /*roundtrip exclusions*/ |
b75a7d8f A |
1455 | |
1456 | "MALAYALAM-DEVANAGARI", "[:MALAYALAM:]", "[:Devanagari:]", | |
73c04bcf | 1457 | "[\\u0901\\u0904\\u094a\\u094b\\u094c\\u093c\\u0950\\u0944\\u0945\\u0949\\u0951-\\u0954\\u0962\\u0963\\u090D\\u0911\\u093d\\u0929\\u0934[\\u0958-\\u095f]\\u097d]", /*roundtrip exclusions*/ |
b75a7d8f A |
1458 | |
1459 | "DEVANAGARI-MALAYALAM", "[:Devanagari:]", "[:MALAYALAM:]", | |
1460 | "[\\u0d4c\\u0d57\\u0950\\u090D\\u0911\\u093d\\u0929\\u0934[\\u0958-\\u095f]]", /*roundtrip exclusions*/ | |
1461 | ||
1462 | "GURMUKHI-BENGALI", "[:GURMUKHI:]", "[:BENGALI:]", | |
73c04bcf | 1463 | "[\\u0981\\u0982\\u09b6\\u09e2\\u09e3\\u09c3\\u09c4\\u09d7\\u098B\\u098C\\u09B7\\u09E0\\u09E1\\u09F0\\u09F1\\u09f2-\\u09fa\\u09ce]", /*roundtrip exclusions*/ |
b75a7d8f A |
1464 | |
1465 | "BENGALI-GURMUKHI", "[:BENGALI:]", "[:GURMUKHI:]", | |
1466 | "[\\u0A02\\u0a5c\\u0a47\\u0a70\\u0a71\\u0A33\\u0A35\\u0A59\\u0A5A\\u0A5B\\u0A5E\\u0A72\\u0A73\\u0A74]", /*roundtrip exclusions*/ | |
1467 | ||
1468 | "GUJARATI-BENGALI", "[:GUJARATI:]", "[:BENGALI:]", | |
73c04bcf | 1469 | "[\\u09d7\\u09e2\\u09e3\\u098c\\u09e1\\u09f0\\u09f1\\u09f2-\\u09fa\\u09ce]", /*roundtrip exclusions*/ |
b75a7d8f A |
1470 | |
1471 | "BENGALI-GUJARATI", "[:BENGALI:]", "[:GUJARATI:]", | |
1472 | "[\\u0A82\\u0a83\\u0Ac9\\u0Ac5\\u0ac7\\u0A8D\\u0A91\\u0AB3\\u0AB5\\u0ABD\\u0AD0]", /*roundtrip exclusions*/ | |
1473 | ||
1474 | "ORIYA-BENGALI", "[:ORIYA:]", "[:BENGALI:]", | |
73c04bcf | 1475 | "[\\u09c4\\u09e2\\u09e3\\u09f0\\u09f1\\u09f2-\\u09fa\\u09ce]", /*roundtrip exclusions*/ |
b75a7d8f A |
1476 | |
1477 | "BENGALI-ORIYA", "[:BENGALI:]", "[:ORIYA:]", | |
374ca955 | 1478 | "[\\u0b35\\u0b71\\u0b5f\\u0b56\\u0b33\\u0b3d]", /*roundtrip exclusions*/ |
b75a7d8f A |
1479 | |
1480 | "Tamil-BENGALI", "[:tamil:]", "[:BENGALI:]", | |
73c04bcf | 1481 | "[\\u0981\\u09bc\\u09c3\\u09c4\\u09e2\\u09e3\\u09f0\\u09f1\\u098B\\u098C\\u0996\\u0997\\u0998\\u099B\\u099D\\u09A0\\u09A1\\u09A2\\u09A5\\u09A6\\u09A7\\u09AB\\u09AC\\u09AD\\u09B6\\u09DC\\u09DD\\u09DF\\u09E0\\u09E1\\u09f2-\\u09fa\\u09ce]", /*roundtrip exclusions*/ |
b75a7d8f A |
1482 | |
1483 | "BENGALI-Tamil", "[:BENGALI:]", "[:tamil:]", | |
46f4442e | 1484 | "[\\u0bc6\\u0bc7\\u0bca\\u0B8E\\u0B92\\u0BA9\\u0BB1\\u0BB3\\u0BB4\\u0BB5\\u0BF0\\u0BF1\\u0BF2]", /*roundtrip exclusions*/ |
b75a7d8f A |
1485 | |
1486 | "Telugu-BENGALI", "[:telugu:]", "[:BENGALI:]", | |
73c04bcf | 1487 | "[\\u09e2\\u09e3\\u09bc\\u09d7\\u09f0\\u09f1\\u09dc\\u09dd\\u09df\\u09f2-\\u09fa\\u09ce]", /*roundtrip exclusions*/ |
b75a7d8f A |
1488 | |
1489 | "BENGALI-TELUGU", "[:BENGALI:]", "[:TELUGU:]", | |
1490 | "[\\u0c55\\u0c56\\u0c47\\u0c46\\u0c4a\\u0C0E\\u0C12\\u0C31\\u0C33\\u0C35]", /*roundtrip exclusions*/ | |
1491 | ||
1492 | "KANNADA-BENGALI", "[:KANNADA:]", "[:BENGALI:]", | |
73c04bcf | 1493 | "[\\u0981\\u09e2\\u09e3\\u09bc\\u09d7\\u09dc\\u09dd\\u09df\\u09f0\\u09f1\\u09f2-\\u09fa\\u09ce]", /*roundtrip exclusions*/ |
b75a7d8f A |
1494 | |
1495 | "BENGALI-KANNADA", "[:BENGALI:]", "[:KANNADA:]", | |
374ca955 | 1496 | "[{\\u0cb0\\u0cbc}{\\u0cb3\\u0cbc}\\u0cc6\\u0cca\\u0cd5\\u0cd6\\u0cc7\\u0C8E\\u0C92\\u0CB1\\u0cb3\\u0cb5\\u0cde]", /*roundtrip exclusions*/ |
b75a7d8f A |
1497 | |
1498 | "MALAYALAM-BENGALI", "[:MALAYALAM:]", "[:BENGALI:]", | |
73c04bcf | 1499 | "[\\u0981\\u09e2\\u09e3\\u09bc\\u09c4\\u09f0\\u09f1\\u09dc\\u09dd\\u09df\\u09dc\\u09dd\\u09df\\u09f2-\\u09fa\\u09ce]", /*roundtrip exclusions*/ |
b75a7d8f A |
1500 | |
1501 | "BENGALI-MALAYALAM", "[:BENGALI:]", "[:MALAYALAM:]", | |
1502 | "[\\u0d46\\u0d4a\\u0d47\\u0d31-\\u0d35\\u0d0e\\u0d12]", /*roundtrip exclusions*/ | |
46f4442e | 1503 | |
b75a7d8f A |
1504 | "GUJARATI-GURMUKHI", "[:GUJARATI:]", "[:GURMUKHI:]", |
1505 | "[\\u0A02\\u0ab3\\u0ab6\\u0A70\\u0a71\\u0a82\\u0a83\\u0ac3\\u0ac4\\u0ac5\\u0ac9\\u0a5c\\u0a72\\u0a73\\u0a74\\u0a8b\\u0a8d\\u0a91\\u0abd]", /*roundtrip exclusions*/ | |
1506 | ||
1507 | "GURMUKHI-GUJARATI", "[:GURMUKHI:]", "[:GUJARATI:]", | |
374ca955 | 1508 | "[\\u0a5c\\u0A70\\u0a71\\u0a72\\u0a73\\u0a74\\u0a82\\u0a83\\u0a8b\\u0a8c\\u0a8d\\u0a91\\u0ab3\\u0ab6\\u0ab7\\u0abd\\u0ac3\\u0ac4\\u0ac5\\u0ac9\\u0ad0\\u0ae0\\u0ae1]", /*roundtrip exclusions*/ |
b75a7d8f A |
1509 | |
1510 | "ORIYA-GURMUKHI", "[:ORIYA:]", "[:GURMUKHI:]", | |
1511 | "[\\u0A01\\u0A02\\u0a5c\\u0a21\\u0a47\\u0a71\\u0b02\\u0b03\\u0b33\\u0b36\\u0b43\\u0b56\\u0b57\\u0B0B\\u0B0C\\u0B37\\u0B3D\\u0B5F\\u0B60\\u0B61\\u0a35\\u0a72\\u0a73\\u0a74]", /*roundtrip exclusions*/ | |
1512 | ||
1513 | "GURMUKHI-ORIYA", "[:GURMUKHI:]", "[:ORIYA:]", | |
374ca955 | 1514 | "[\\u0b01\\u0b02\\u0b03\\u0b33\\u0b36\\u0b43\\u0b56\\u0b57\\u0B0B\\u0B0C\\u0B37\\u0B3D\\u0B5F\\u0B60\\u0B61\\u0b70\\u0b71]", /*roundtrip exclusions*/ |
b75a7d8f A |
1515 | |
1516 | "TAMIL-GURMUKHI", "[:TAMIL:]", "[:GURMUKHI:]", | |
374ca955 | 1517 | "[\\u0A01\\u0A02\\u0a33\\u0a36\\u0a3c\\u0a70\\u0a71\\u0a47\\u0A16\\u0A17\\u0A18\\u0A1B\\u0A1D\\u0A20\\u0A21\\u0A22\\u0A25\\u0A26\\u0A27\\u0A2B\\u0A2C\\u0A2D\\u0A59\\u0A5A\\u0A5B\\u0A5C\\u0A5E\\u0A72\\u0A73\\u0A74]", /*roundtrip exclusions*/ |
b75a7d8f A |
1518 | |
1519 | "GURMUKHI-TAMIL", "[:GURMUKHI:]", "[:TAMIL:]", | |
46f4442e | 1520 | "[\\u0b82\\u0bc6\\u0bca\\u0bd7\\u0bb7\\u0bb3\\u0b83\\u0B8E\\u0B92\\u0BA9\\u0BB1\\u0BB4\\u0bb6\\u0BF0\\u0BF1\\u0BF2]", /*roundtrip exclusions*/ |
b75a7d8f A |
1521 | |
1522 | "TELUGU-GURMUKHI", "[:TELUGU:]", "[:GURMUKHI:]", | |
1523 | "[\\u0A02\\u0a33\\u0a36\\u0a3c\\u0a70\\u0a71\\u0A59\\u0A5A\\u0A5B\\u0A5C\\u0A5E\\u0A72\\u0A73\\u0A74]", /*roundtrip exclusions*/ | |
1524 | ||
1525 | "GURMUKHI-TELUGU", "[:GURMUKHI:]", "[:TELUGU:]", | |
1526 | "[\\u0c01\\u0c02\\u0c03\\u0c33\\u0c36\\u0c44\\u0c43\\u0c46\\u0c4a\\u0c56\\u0c55\\u0C0B\\u0C0C\\u0C0E\\u0C12\\u0C31\\u0C37\\u0C60\\u0C61]", /*roundtrip exclusions*/ | |
1527 | ||
1528 | "KANNADA-GURMUKHI", "[:KANNADA:]", "[:GURMUKHI:]", | |
374ca955 | 1529 | "[\\u0A01\\u0A02\\u0a33\\u0a36\\u0a3c\\u0a70\\u0a71\\u0A59\\u0A5A\\u0A5B\\u0A5C\\u0A5E\\u0A72\\u0A73\\u0A74]", /*roundtrip exclusions*/ |
b75a7d8f A |
1530 | |
1531 | "GURMUKHI-KANNADA", "[:GURMUKHI:]", "[:KANNADA:]", | |
374ca955 | 1532 | "[{\\u0cb0\\u0cbc}{\\u0cb3\\u0cbc}\\u0c82\\u0c83\\u0cb3\\u0cb6\\u0cc4\\u0cc3\\u0cc6\\u0cca\\u0cd5\\u0cd6\\u0C8B\\u0C8C\\u0C8E\\u0C92\\u0CB1\\u0CB7\\u0cbd\\u0CE0\\u0CE1\\u0cde]", /*roundtrip exclusions*/ |
b75a7d8f A |
1533 | |
1534 | "MALAYALAM-GURMUKHI", "[:MALAYALAM:]", "[:GURMUKHI:]", | |
374ca955 | 1535 | "[\\u0A01\\u0A02\\u0a4b\\u0a4c\\u0a33\\u0a36\\u0a3c\\u0a70\\u0a71\\u0A59\\u0A5A\\u0A5B\\u0A5C\\u0A5E\\u0A72\\u0A73\\u0A74]", /*roundtrip exclusions*/ |
b75a7d8f A |
1536 | |
1537 | "GURMUKHI-MALAYALAM", "[:GURMUKHI:]", "[:MALAYALAM:]", | |
1538 | "[\\u0d02\\u0d03\\u0d33\\u0d36\\u0d43\\u0d46\\u0d4a\\u0d4c\\u0d57\\u0D0B\\u0D0C\\u0D0E\\u0D12\\u0D31\\u0D34\\u0D37\\u0D60\\u0D61]", /*roundtrip exclusions*/ | |
1539 | ||
1540 | "GUJARATI-ORIYA", "[:GUJARATI:]", "[:ORIYA:]", | |
374ca955 | 1541 | "[\\u0b56\\u0b57\\u0B0C\\u0B5F\\u0B61\\u0b70\\u0b71]", /*roundtrip exclusions*/ |
b75a7d8f A |
1542 | |
1543 | "ORIYA-GUJARATI", "[:ORIYA:]", "[:GUJARATI:]", | |
1544 | "[\\u0Ac4\\u0Ac5\\u0Ac9\\u0Ac7\\u0A8D\\u0A91\\u0AB5\\u0Ad0]", /*roundtrip exclusions*/ | |
1545 | ||
1546 | "TAMIL-GUJARATI", "[:TAMIL:]", "[:GUJARATI:]", | |
374ca955 | 1547 | "[\\u0A81\\u0a8c\\u0abc\\u0ac3\\u0Ac4\\u0Ac5\\u0Ac9\\u0Ac7\\u0A8B\\u0A8D\\u0A91\\u0A96\\u0A97\\u0A98\\u0A9B\\u0A9D\\u0AA0\\u0AA1\\u0AA2\\u0AA5\\u0AA6\\u0AA7\\u0AAB\\u0AAC\\u0AAD\\u0AB6\\u0ABD\\u0AD0\\u0AE0\\u0AE1]", /*roundtrip exclusions*/ |
b75a7d8f A |
1548 | |
1549 | "GUJARATI-TAMIL", "[:GUJARATI:]", "[:TAMIL:]", | |
46f4442e | 1550 | "[\\u0Bc6\\u0Bca\\u0Bd7\\u0B8E\\u0B92\\u0BA9\\u0BB1\\u0BB4\\u0BF0\\u0BF1\\u0BF2]", /*roundtrip exclusions*/ |
b75a7d8f A |
1551 | |
1552 | "TELUGU-GUJARATI", "[:TELUGU:]", "[:GUJARATI:]", | |
1553 | "[\\u0abc\\u0Ac5\\u0Ac9\\u0A8D\\u0A91\\u0ABD\\u0Ad0]", /*roundtrip exclusions*/ | |
1554 | ||
1555 | "GUJARATI-TELUGU", "[:GUJARATI:]", "[:TELUGU:]", | |
1556 | "[\\u0c46\\u0c4a\\u0c55\\u0c56\\u0C0C\\u0C0E\\u0C12\\u0C31\\u0C61]", /*roundtrip exclusions*/ | |
1557 | ||
1558 | "KANNADA-GUJARATI", "[:KANNADA:]", "[:GUJARATI:]", | |
1559 | "[\\u0A81\\u0abc\\u0Ac5\\u0Ac9\\u0A8D\\u0A91\\u0ABD\\u0Ad0]", /*roundtrip exclusions*/ | |
1560 | ||
1561 | "GUJARATI-KANNADA", "[:GUJARATI:]", "[:KANNADA:]", | |
374ca955 | 1562 | "[{\\u0cb0\\u0cbc}{\\u0cb3\\u0cbc}\\u0cc6\\u0cca\\u0cd5\\u0cd6\\u0C8C\\u0C8E\\u0C92\\u0CB1\\u0CDE\\u0CE1]", /*roundtrip exclusions*/ |
b75a7d8f A |
1563 | |
1564 | "MALAYALAM-GUJARATI", "[:MALAYALAM:]", "[:GUJARATI:]", | |
1565 | "[\\u0A81\\u0ac4\\u0acb\\u0acc\\u0abc\\u0Ac5\\u0Ac9\\u0A8D\\u0A91\\u0ABD\\u0Ad0]", /*roundtrip exclusions*/ | |
1566 | ||
1567 | "GUJARATI-MALAYALAM", "[:GUJARATI:]", "[:MALAYALAM:]", | |
1568 | "[\\u0d46\\u0d4a\\u0d4c\\u0d55\\u0d57\\u0D0C\\u0D0E\\u0D12\\u0D31\\u0D34\\u0D61]", /*roundtrip exclusions*/ | |
1569 | ||
1570 | "TAMIL-ORIYA", "[:TAMIL:]", "[:ORIYA:]", | |
374ca955 | 1571 | "[\\u0B01\\u0b3c\\u0b43\\u0b56\\u0B0B\\u0B0C\\u0B16\\u0B17\\u0B18\\u0B1B\\u0B1D\\u0B20\\u0B21\\u0B22\\u0B25\\u0B26\\u0B27\\u0B2B\\u0B2C\\u0B2D\\u0B36\\u0B3D\\u0B5C\\u0B5D\\u0B5F\\u0B60\\u0B61\\u0b70\\u0b71]", /*roundtrip exclusions*/ |
b75a7d8f A |
1572 | |
1573 | "ORIYA-TAMIL", "[:ORIYA:]", "[:TAMIL:]", | |
46f4442e | 1574 | "[\\u0bc6\\u0bca\\u0bc7\\u0B8E\\u0B92\\u0BA9\\u0BB1\\u0BB4\\u0BB5\\u0BF0\\u0BF1\\u0BF2]", /*roundtrip exclusions*/ |
b75a7d8f A |
1575 | |
1576 | "TELUGU-ORIYA", "[:TELUGU:]", "[:ORIYA:]", | |
374ca955 | 1577 | "[\\u0b3c\\u0b57\\u0b56\\u0B3D\\u0B5C\\u0B5D\\u0B5F\\u0b70\\u0b71]", /*roundtrip exclusions*/ |
b75a7d8f A |
1578 | |
1579 | "ORIYA-TELUGU", "[:ORIYA:]", "[:TELUGU:]", | |
1580 | "[\\u0c44\\u0c46\\u0c4a\\u0c55\\u0c47\\u0C0E\\u0C12\\u0C31\\u0C35]", /*roundtrip exclusions*/ | |
1581 | ||
1582 | "KANNADA-ORIYA", "[:KANNADA:]", "[:ORIYA:]", | |
374ca955 | 1583 | "[\\u0B01\\u0b3c\\u0b57\\u0B3D\\u0B5C\\u0B5D\\u0B5F\\u0b70\\u0b71]", /*roundtrip exclusions*/ |
b75a7d8f A |
1584 | |
1585 | "ORIYA-KANNADA", "[:ORIYA:]", "[:KANNADA:]", | |
374ca955 | 1586 | "[{\\u0cb0\\u0cbc}{\\u0cb3\\u0cbc}\\u0cc4\\u0cc6\\u0cca\\u0cd5\\u0cc7\\u0C8E\\u0C92\\u0CB1\\u0CB5\\u0CDE]", /*roundtrip exclusions*/ |
b75a7d8f A |
1587 | |
1588 | "MALAYALAM-ORIYA", "[:MALAYALAM:]", "[:ORIYA:]", | |
374ca955 | 1589 | "[\\u0B01\\u0b3c\\u0b56\\u0B3D\\u0B5C\\u0B5D\\u0B5F\\u0b70\\u0b71]", /*roundtrip exclusions*/ |
b75a7d8f A |
1590 | |
1591 | "ORIYA-MALAYALAM", "[:ORIYA:]", "[:MALAYALAM:]", | |
1592 | "[\\u0D47\\u0D46\\u0D4a\\u0D0E\\u0D12\\u0D31\\u0D34\\u0D35]", /*roundtrip exclusions*/ | |
1593 | ||
1594 | "TELUGU-TAMIL", "[:TELUGU:]", "[:TAMIL:]", | |
46f4442e | 1595 | "[\\u0bd7\\u0ba9\\u0bb4\\u0BF0\\u0BF1\\u0BF2]", /*roundtrip exclusions*/ |
b75a7d8f A |
1596 | |
1597 | "TAMIL-TELUGU", "[:TAMIL:]", "[:TELUGU:]", | |
1598 | "[\\u0C01\\u0c43\\u0c44\\u0c46\\u0c47\\u0c55\\u0c56\\u0c66\\u0C0B\\u0C0C\\u0C16\\u0C17\\u0C18\\u0C1B\\u0C1D\\u0C20\\u0C21\\u0C22\\u0C25\\u0C26\\u0C27\\u0C2B\\u0C2C\\u0C2D\\u0C36\\u0C60\\u0C61]", /*roundtrip exclusions*/ | |
1599 | ||
1600 | "KANNADA-TAMIL", "[:KANNADA:]", "[:TAMIL:]", | |
46f4442e | 1601 | "[\\u0bd7\\u0bc6\\u0ba9\\u0bb4\\u0BF0\\u0BF1\\u0BF2]", /*roundtrip exclusions*/ |
b75a7d8f A |
1602 | |
1603 | "TAMIL-KANNADA", "[:TAMIL:]", "[:KANNADA:]", | |
374ca955 | 1604 | "[\\u0cc3\\u0cc4\\u0cc6\\u0cc7\\u0cd5\\u0cd6\\u0C8B\\u0C8C\\u0C96\\u0C97\\u0C98\\u0C9B\\u0C9D\\u0CA0\\u0CA1\\u0CA2\\u0CA5\\u0CA6\\u0CA7\\u0CAB\\u0CAC\\u0CAD\\u0CB6\\u0cbc\\u0cbd\\u0CDE\\u0CE0\\u0CE1]", /*roundtrip exclusions*/ |
b75a7d8f A |
1605 | |
1606 | "MALAYALAM-TAMIL", "[:MALAYALAM:]", "[:TAMIL:]", | |
46f4442e | 1607 | "[\\u0ba9\\u0BF0\\u0BF1\\u0BF2]", /*roundtrip exclusions*/ |
b75a7d8f A |
1608 | |
1609 | "TAMIL-MALAYALAM", "[:TAMIL:]", "[:MALAYALAM:]", | |
1610 | "[\\u0d43\\u0d12\\u0D0B\\u0D0C\\u0D16\\u0D17\\u0D18\\u0D1B\\u0D1D\\u0D20\\u0D21\\u0D22\\u0D25\\u0D26\\u0D27\\u0D2B\\u0D2C\\u0D2D\\u0D36\\u0D60\\u0D61]", /*roundtrip exclusions*/ | |
1611 | ||
1612 | "KANNADA-TELUGU", "[:KANNADA:]", "[:TELUGU:]", | |
1613 | "[\\u0C01\\u0c3f\\u0c46\\u0c48\\u0c4a]", /*roundtrip exclusions*/ | |
1614 | ||
1615 | "TELUGU-KANNADA", "[:TELUGU:]", "[:KANNADA:]", | |
374ca955 | 1616 | "[\\u0cc8\\u0cd5\\u0cd6\\u0cbc\\u0cbd\\u0CDE]", /*roundtrip exclusions*/ |
b75a7d8f A |
1617 | |
1618 | "MALAYALAM-TELUGU", "[:MALAYALAM:]", "[:TELUGU:]", | |
1619 | "[\\u0C01\\u0c44\\u0c4a\\u0c4c\\u0c4b\\u0c55\\u0c56]", /*roundtrip exclusions*/ | |
1620 | ||
1621 | "TELUGU-MALAYALAM", "[:TELUGU:]", "[:MALAYALAM:]", | |
1622 | "[\\u0d4c\\u0d57\\u0D34]", /*roundtrip exclusions*/ | |
1623 | ||
1624 | "MALAYALAM-KANNADA", "[:MALAYALAM:]", "[:KANNADA:]", | |
374ca955 | 1625 | "[\\u0cbc\\u0cbd\\u0cc4\\u0cc6\\u0cca\\u0ccc\\u0ccb\\u0cd5\\u0cd6\\u0cDe]", /*roundtrip exclusions*/ |
b75a7d8f A |
1626 | |
1627 | "KANNADA-MALAYALAM", "[:KANNADA:]", "[:MALAYALAM:]", | |
1628 | "[\\u0d4c\\u0d57\\u0d46\\u0D34]", /*roundtrip exclusions*/ | |
46f4442e | 1629 | |
b75a7d8f | 1630 | "Latin-Bengali",latinForIndic, "[[:Bengali:][\\u0964\\u0965]]", |
73c04bcf | 1631 | "[\\u0965\\u09f0-\\u09fa\\u09ce]" /*roundtrip exclusions*/ , |
46f4442e | 1632 | |
b75a7d8f | 1633 | "Latin-Gurmukhi", latinForIndic, "[[:Gurmukhi:][\\u0964\\u0965]]", |
374ca955 | 1634 | "[\\u0a01\\u0965\\u0a02\\u0a72\\u0a73\\u0a74]" /*roundtrip exclusions*/, |
46f4442e | 1635 | |
b75a7d8f A |
1636 | "Latin-Gujarati",latinForIndic, "[[:Gujarati:][\\u0964\\u0965]]", |
1637 | "[\\u0965]" /*roundtrip exclusions*/, | |
46f4442e | 1638 | |
b75a7d8f | 1639 | "Latin-Oriya",latinForIndic, "[[:Oriya:][\\u0964\\u0965]]", |
374ca955 | 1640 | "[\\u0965\\u0b70]" /*roundtrip exclusions*/, |
46f4442e | 1641 | |
b75a7d8f | 1642 | "Latin-Tamil",latinForIndic, "[:Tamil:]", |
46f4442e A |
1643 | "[\\u0BF0\\u0BF1\\u0BF2]" /*roundtrip exclusions*/, |
1644 | ||
b75a7d8f A |
1645 | "Latin-Telugu",latinForIndic, "[:Telugu:]", |
1646 | NULL /*roundtrip exclusions*/, | |
46f4442e | 1647 | |
b75a7d8f A |
1648 | "Latin-Kannada",latinForIndic, "[:Kannada:]", |
1649 | NULL /*roundtrip exclusions*/, | |
46f4442e | 1650 | |
b75a7d8f A |
1651 | "Latin-Malayalam",latinForIndic, "[:Malayalam:]", |
1652 | NULL /*roundtrip exclusions*/ | |
b75a7d8f A |
1653 | }; |
1654 | ||
1655 | void TransliteratorRoundTripTest::TestDebug(const char* name,const char fromSet[], | |
1656 | const char* toSet,const char* exclusions){ | |
1657 | ||
1658 | RTTest test(name); | |
1659 | Legal *legal = new LegalIndic(); | |
1660 | test.test(UnicodeString(fromSet,""),UnicodeString(toSet,""),exclusions,this,quick,legal); | |
1661 | } | |
1662 | ||
1663 | void TransliteratorRoundTripTest::TestInterIndic() { | |
1664 | //TestDebug("Latin-Gurmukhi", latinForIndic, "[:Gurmukhi:]","[\\u0965\\u0a02\\u0a72\\u0a73\\u0a74]",TRUE); | |
1665 | int32_t num = (int32_t)(sizeof(interIndicArray)/(INTER_INDIC_ARRAY_WIDTH*sizeof(char*))); | |
1666 | if(quick){ | |
1667 | logln("Testing only 5 of %i. Skipping rest (use -e for exhaustive)",num); | |
1668 | num = 5; | |
1669 | } | |
46f4442e | 1670 | if (isICUVersionAtLeast(ICU_39)) { |
73c04bcf A |
1671 | // We temporarily filter against Unicode 4.1, but we only do this |
1672 | // before version 3.4. | |
1673 | errln("FAIL: TestInterIndic needs to be updated to remove delete the [:Age=4.1:] filter "); | |
1674 | return; | |
1675 | } else { | |
1676 | logln("Warning: TestInterIndic needs to be updated to remove delete the section marked [:Age=4.1:] filter"); | |
1677 | } | |
b75a7d8f A |
1678 | for(int i = 0; i < num;i++){ |
1679 | RTTest test(interIndicArray[i*INTER_INDIC_ARRAY_WIDTH + 0]); | |
1680 | Legal *legal = new LegalIndic(); | |
73c04bcf A |
1681 | logln(UnicodeString("Stress testing ") + interIndicArray[i*INTER_INDIC_ARRAY_WIDTH + 0]); |
1682 | /* Uncomment lines below when transliterator is fixed */ | |
1683 | /* | |
374ca955 A |
1684 | test.test( interIndicArray[i*INTER_INDIC_ARRAY_WIDTH + 1], |
1685 | interIndicArray[i*INTER_INDIC_ARRAY_WIDTH + 2], | |
1686 | interIndicArray[i*INTER_INDIC_ARRAY_WIDTH + 3], // roundtrip exclusions | |
1687 | this, quick, legal, 50); | |
73c04bcf A |
1688 | */ |
1689 | /* comment lines below when transliterator is fixed */ | |
1690 | // start | |
1691 | UnicodeString source("["); | |
1692 | source.append(interIndicArray[i*INTER_INDIC_ARRAY_WIDTH + 1]); | |
1693 | source.append(" & [:Age=4.1:]]"); | |
1694 | UnicodeString target("["); | |
1695 | target.append(interIndicArray[i*INTER_INDIC_ARRAY_WIDTH + 2]); | |
1696 | target.append(" & [:Age=4.1:]]"); | |
1697 | test.test( source, | |
1698 | target, | |
1699 | interIndicArray[i*INTER_INDIC_ARRAY_WIDTH + 3], // roundtrip exclusions | |
1700 | this, quick, legal, 50); | |
1701 | // end | |
374ca955 | 1702 | delete legal; |
b75a7d8f | 1703 | } |
b75a7d8f A |
1704 | } |
1705 | ||
1706 | // end indic tests ---------------------------------------------------------- | |
1707 | ||
1708 | #endif /* #if !UCONFIG_NO_TRANSLITERATION */ |