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