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