/******************************************************************** * COPYRIGHT: * Copyright (c) 2001, International Business Machines Corporation and * others. All Rights Reserved. ********************************************************************/ /******************************************************************************* * * File cmsccoll.C * *******************************************************************************/ /** * These are the tests specific to ICU 1.8 and above, that I didn't know where * to fit. */ #include #include "unicode/utypes.h" #include "unicode/ucol.h" #include "unicode/ucoleitr.h" #include "unicode/uloc.h" #include "cintltst.h" #include "ccolltst.h" #include "callcoll.h" #include "unicode/ustring.h" #include "string.h" #include "ucol_imp.h" #include "ucol_tok.h" #include "cmemory.h" #include "cstring.h" #include "unicode/parseerr.h" #define MAX_TOKEN_LEN 16 #define RULE_BUFFER_LEN 8192 typedef int tst_strcoll(void *collator, const int object, const UChar *source, const int sLen, const UChar *target, const int tLen); /** * Return an integer array containing all of the collation orders * returned by calls to next on the specified iterator */ static int32_t* getOrders(UCollationElements *iter, int32_t *orderLength) { UErrorCode status; int32_t order; int32_t maxSize = 100; int32_t size = 0; int32_t *temp; int32_t *orders =(int32_t*)malloc(sizeof(int32_t) * maxSize); status= U_ZERO_ERROR; while ((order=ucol_next(iter, &status)) != UCOL_NULLORDER) { if (size == maxSize) { maxSize *= 2; temp = (int32_t*)malloc(sizeof(int32_t) * maxSize); memcpy(temp, orders, size * sizeof(int32_t)); free(orders); orders = temp; } orders[size++] = order; } if (maxSize > size && size > 0) { temp = (int32_t*)malloc(sizeof(int32_t) * size); memcpy(temp, orders, size * sizeof(int32_t)); free(orders); orders = temp; } *orderLength = size; return orders; } static void backAndForth(UCollationElements *iter) { /* Run through the iterator forwards and stick it into an array */ int32_t index, o; UErrorCode status = U_ZERO_ERROR; int32_t orderLength = 0; int32_t *orders; orders= getOrders(iter, &orderLength); /* Now go through it backwards and make sure we get the same values */ index = orderLength; ucol_reset(iter); /* synwee : changed */ while ((o = ucol_previous(iter, &status)) != UCOL_NULLORDER) { if (o != orders[-- index]) { if (o == 0) index ++; else { while (index > 0 && orders[-- index] == 0) { } if (o != orders[index]) { log_err("Mismatch at index : %d\n", index); break; } } } } while (index != 0 && orders[index - 1] == 0) { index --; } if (index != 0) { log_err("Didn't get back to beginning - index is %d\n", index); ucol_reset(iter); log_err("\nnext: "); while ((o = ucol_next(iter, &status)) != UCOL_NULLORDER) { log_err("Error at %d\n", o); } log_err("\nprev: "); while ((o = ucol_previous(iter, &status)) != UCOL_NULLORDER) { log_err("Error at %d\n", o); } log_verbose("\n"); } free(orders); } const static char cnt1[][10] = { "AA", "AC", "AZ", "AQ", "AB", "ABZ", "ABQ", "Z", "ABC", "Q", "B" }; const static char cnt2[][10] = { "DA", "DAD", "DAZ", "MAR", "Z", "DAVIS", "MARK", "DAV", "DAVI" }; static void IncompleteCntTest( ) { UErrorCode status = U_ZERO_ERROR; UChar *temp=(UChar*)malloc(sizeof(UChar) * 90); UChar *t1 =(UChar*)malloc(sizeof(UChar) * 90); UChar *t2 =(UChar*)malloc(sizeof(UChar) * 90); UCollator *coll = NULL; uint32_t i = 0, j = 0; uint32_t size = 0; u_uastrcpy(temp, " & Z < ABC < Q < B"); coll = ucol_openRules(temp, u_strlen(temp), UCOL_OFF, UCOL_DEFAULT_STRENGTH, NULL,&status); if(U_SUCCESS(status)) { size = sizeof(cnt1)/sizeof(cnt1[0]); for(i = 0; i < size-1; i++) { for(j = i+1; j < size; j++) { UCollationElements *iter; u_uastrcpy(t1, cnt1[i]); u_uastrcpy(t2, cnt1[j]); doTest(coll, t1, t2, UCOL_LESS); /* synwee : added collation element iterator test */ iter = ucol_openElements(coll, t2, u_strlen(t2), &status); if (U_FAILURE(status)) { log_err("Creation of iterator failed\n"); break; } backAndForth(iter); free(iter); } } } ucol_close(coll); u_uastrcpy(temp, " & Z < DAVIS < MARK 0x0400 && *p<0x0500)?0x00e1:0x491; UChar preQ = (*p>0x0400 && *p<0x0500)?0x0041:0x413; */ /*log_verbose("Testing primary\n");*/ doTest(col, p, q, UCOL_LESS); /* UCollationResult result = ucol_strcoll(col,p,u_strlen(p),q,u_strlen(q)); if(result!=UCOL_LESS){ aescstrdup(p,utfSource,256); aescstrdup(q,utfTarget,256); fprintf(file,"Primary failed source: %s target: %s \n", utfSource,utfTarget); } */ source[0] = preP; u_strcpy(source+1,p); target[0] = preQ; u_strcpy(target+1,q); doTest(col, source, target, UCOL_LESS); /* fprintf(file,"Primary swamps 2nd failed source: %s target: %s \n", utfSource,utfTarget); */ } static void testSecondary(UCollator* col, const UChar* p,const UChar* q){ UChar source[256] = { '\0'}; UChar target[256] = { '\0'}; /*log_verbose("Testing secondary\n");*/ doTest(col, p, q, UCOL_LESS); /* fprintf(file,"secondary failed source: %s target: %s \n", utfSource,utfTarget); */ source[0] = 0x0053; u_strcpy(source+1,p); target[0]= 0x0073; u_strcpy(target+1,q); doTest(col, source, target, UCOL_LESS); /* fprintf(file,"secondary swamps 3rd failed source: %s target: %s \n",utfSource,utfTarget); */ u_strcpy(source,p); source[u_strlen(p)] = 0x62; source[u_strlen(p)+1] = 0; u_strcpy(target,q); target[u_strlen(q)] = 0x61; target[u_strlen(q)+1] = 0; doTest(col, source, target, UCOL_GREATER); /* fprintf(file,"secondary is swamped by 1 failed source: %s target: %s \n",utfSource,utfTarget); */ } static void testTertiary(UCollator* col, const UChar* p,const UChar* q){ UChar source[256] = { '\0'}; UChar target[256] = { '\0'}; /*log_verbose("Testing tertiary\n");*/ doTest(col, p, q, UCOL_LESS); /* fprintf(file,"Tertiary failed source: %s target: %s \n",utfSource,utfTarget); */ source[0] = 0x0020; u_strcpy(source+1,p); target[0]= 0x002D; u_strcpy(target+1,q); doTest(col, source, target, UCOL_LESS); /* fprintf(file,"Tertiary swamps 4th failed source: %s target: %s \n", utfSource,utfTarget); */ u_strcpy(source,p); source[u_strlen(p)] = 0xE0; source[u_strlen(p)+1] = 0; u_strcpy(target,q); target[u_strlen(q)] = 0x61; target[u_strlen(q)+1] = 0; doTest(col, source, target, UCOL_GREATER); /* fprintf(file,"Tertiary is swamped by 3rd failed source: %s target: %s \n",utfSource,utfTarget); */ } static void testEquality(UCollator* col, const UChar* p,const UChar* q){ /* UChar source[256] = { '\0'}; UChar target[256] = { '\0'}; */ doTest(col, p, q, UCOL_EQUAL); /* fprintf(file,"Primary failed source: %s target: %s \n", utfSource,utfTarget); */ } static void testCollator(UCollator *coll, UErrorCode *status) { const UChar *rules = NULL, *current = NULL; int32_t ruleLen = 0; uint32_t strength = 0; uint32_t chOffset = 0; uint32_t chLen = 0; uint32_t exOffset = 0; uint32_t exLen = 0; uint32_t prefixOffset = 0; uint32_t prefixLen = 0; uint32_t firstEx = 0; /* uint32_t rExpsLen = 0; */ uint32_t firstLen = 0; UBool varT = FALSE; UBool top_ = TRUE; uint8_t specs = 0; UBool startOfRules = TRUE; UBool lastReset = FALSE; UColTokenParser src; UColOptionSet opts; UChar first[256]; UChar second[256]; UChar *rulesCopy = NULL; UParseError parseError; src.opts = &opts; rules = ucol_getRules(coll, &ruleLen); if(U_SUCCESS(*status) && ruleLen > 0) { rulesCopy = (UChar *)uprv_malloc((ruleLen+UCOL_TOK_EXTRA_RULE_SPACE_SIZE)*sizeof(UChar)); uprv_memcpy(rulesCopy, rules, ruleLen*sizeof(UChar)); src.source = src.current = rulesCopy; src.end = rulesCopy+ruleLen; src.extraCurrent = src.end; src.extraEnd = src.end+UCOL_TOK_EXTRA_RULE_SPACE_SIZE; *first = *second = 0; while ((current = ucol_tok_parseNextToken(&src, &strength, &chOffset, &chLen, &exOffset, &exLen, &prefixOffset, &prefixLen, &specs, startOfRules,&parseError, status)) != NULL) { startOfRules = FALSE; varT = (UBool)((specs & UCOL_TOK_VARIABLE_TOP) != 0); top_ = (UBool)((specs & UCOL_TOK_TOP) != 0); u_strncpy(second,rulesCopy+chOffset, chLen); second[chLen] = 0; if(exLen > 0 && firstEx == 0) { u_strncat(first, rulesCopy+exOffset, exLen); first[firstLen+exLen] = 0; } lastReset = FALSE; switch(strength){ case UCOL_IDENTICAL: testEquality(coll,first,second); break; case UCOL_PRIMARY: testPrimary(coll,first,second); break; case UCOL_SECONDARY: testSecondary(coll,first,second); break; case UCOL_TERTIARY: testTertiary(coll,first,second); break; case UCOL_TOK_RESET: default: break; } firstLen = chLen; firstEx = exLen; u_strcpy(first, second); } uprv_free(rulesCopy); } } static int ucaTest(void *collator, const int object, const UChar *source, const int sLen, const UChar *target, const int tLen) { UCollator *UCA = (UCollator *)collator; return ucol_strcoll(UCA, source, sLen, target, tLen); } /* static int winTest(void *collator, const int object, const UChar *source, const int sLen, const UChar *target, const int tLen) { #ifdef WIN32 LCID lcid = (LCID)collator; return CompareString(lcid, 0, source, sLen, target, tLen); #else return 0; #endif } */ static UCollationResult swampEarlier(tst_strcoll* func, void *collator, int opts, UChar s1, UChar s2, const UChar *s, const uint32_t sLen, const UChar *t, const uint32_t tLen) { UChar source[256] = {0}; UChar target[256] = {0}; source[0] = s1; u_strcpy(source+1, s); target[0] = s2; u_strcpy(target+1, t); return func(collator, opts, source, sLen+1, target, tLen+1); } static UCollationResult swampLater(tst_strcoll* func, void *collator, int opts, UChar s1, UChar s2, const UChar *s, const uint32_t sLen, const UChar *t, const uint32_t tLen) { UChar source[256] = {0}; UChar target[256] = {0}; u_strcpy(source, s); source[sLen] = s1; u_strcpy(target, t); target[tLen] = s2; return func(collator, opts, source, sLen+1, target, tLen+1); } static uint32_t probeStrength(tst_strcoll* func, void *collator, int opts, const UChar *s, const uint32_t sLen, const UChar *t, const uint32_t tLen, UCollationResult result) { /*UChar fPrimary = 0x6d;*/ /*UChar sPrimary = 0x6e;*/ UChar fSecondary = 0x310d; UChar sSecondary = 0x31a3; UChar fTertiary = 0x310f; UChar sTertiary = 0x31b7; UCollationResult oposite; if(result == UCOL_EQUAL) { return UCOL_IDENTICAL; } else if(result == UCOL_GREATER) { oposite = UCOL_LESS; } else { oposite = UCOL_GREATER; } if(swampEarlier(func, collator, opts, sSecondary, fSecondary, s, sLen, t, tLen) == result) { return UCOL_PRIMARY; } else if((swampEarlier(func, collator, opts, sTertiary, 0x310f, s, sLen, t, tLen) == result) && (swampEarlier(func, collator, opts, 0x310f, sTertiary, s, sLen, t, tLen) == result)) { return UCOL_SECONDARY; } else if((swampLater(func, collator, opts, sTertiary, fTertiary, s, sLen, t, tLen) == result) && (swampLater(func, collator, opts, fTertiary, sTertiary, s, sLen, t, tLen) == result)) { return UCOL_TERTIARY; } else if((swampLater(func, collator, opts, sTertiary, 0x310f, s, sLen, t, tLen) == oposite) && (swampLater(func, collator, opts, fTertiary, sTertiary, s, sLen, t, tLen) == oposite)) { return UCOL_QUATERNARY; } else { return UCOL_IDENTICAL; } } static char *getRelationSymbol(UCollationResult res, uint32_t strength, char *buffer) { uint32_t i = 0; if(res == UCOL_EQUAL || strength == 0xdeadbeef) { buffer[0] = '='; buffer[1] = '='; buffer[2] = '\0'; } else if(res == UCOL_GREATER) { for(i = 0; i=0x20) { toPrint = (char)rules[i]; if(toPrint == '&') { line = 1; fprintf(stdout, "\n&"); } else if(toPrint == ';') { fprintf(stdout, "<<"); line+=2; } else if(toPrint == ',') { fprintf(stdout, "<<<"); line+=3; } else { fprintf(stdout, "%c", toPrint); line++; } } else if(rules[i]<0x3400 || rules[i]>=0xa000) { fprintf(stdout, "\\u%04X", rules[i]); line+=6; } if(line>72) { fprintf(stdout, "\n"); line = 0; } } log_verbose("\n"); } */ static uint32_t testSwitch(tst_strcoll* func, void *collator, int opts, uint32_t strength, const UChar *first, const UChar *second, const char* msg, UBool error) { uint32_t diffs = 0; UCollationResult realResult; uint32_t realStrength; uint32_t sLen = u_strlen(first); uint32_t tLen = u_strlen(second); realResult = func(collator, opts, first, sLen, second, tLen); realStrength = probeStrength(func, collator, opts, first, sLen, second, tLen, realResult); if(strength == UCOL_IDENTICAL && realResult != UCOL_IDENTICAL) { logFailure(msg, "tailoring", first, sLen, second, tLen, realResult, realStrength, UCOL_EQUAL, strength, error); diffs++; } else if(realResult != UCOL_LESS || realStrength != strength) { logFailure(msg, "tailoring", first, sLen, second, tLen, realResult, realStrength, UCOL_LESS, strength, error); diffs++; } return diffs; } static void testAgainstUCA(UCollator *coll, UCollator *UCA, const char *refName, UBool error, UErrorCode *status) { const UChar *rules = NULL, *current = NULL; int32_t ruleLen = 0; uint32_t strength = 0; uint32_t chOffset = 0; uint32_t chLen = 0; uint32_t exOffset = 0; uint32_t exLen = 0; uint32_t prefixOffset = 0; uint32_t prefixLen = 0; /* uint32_t rExpsLen = 0; */ uint32_t firstLen = 0, secondLen = 0; UBool varT = FALSE; UBool top_ = TRUE; uint8_t specs = 0; UBool startOfRules = TRUE; UColTokenParser src; UColOptionSet opts; UChar first[256]; UChar second[256]; UChar *rulesCopy = NULL; uint32_t UCAdiff = 0; uint32_t Windiff = 1; UParseError parseError; src.opts = &opts; rules = ucol_getRules(coll, &ruleLen); /*printOutRules(rules);*/ if(U_SUCCESS(*status) && ruleLen > 0) { rulesCopy = (UChar *)uprv_malloc((ruleLen+UCOL_TOK_EXTRA_RULE_SPACE_SIZE)*sizeof(UChar)); uprv_memcpy(rulesCopy, rules, ruleLen*sizeof(UChar)); src.source = src.current = rulesCopy; src.end = rulesCopy+ruleLen; src.extraCurrent = src.end; src.extraEnd = src.end+UCOL_TOK_EXTRA_RULE_SPACE_SIZE; *first = *second = 0; while ((current = ucol_tok_parseNextToken(&src, &strength, &chOffset, &chLen, &exOffset, &exLen, &prefixOffset, &prefixLen, &specs, startOfRules, &parseError,status)) != NULL) { startOfRules = FALSE; varT = (UBool)((specs & UCOL_TOK_VARIABLE_TOP) != 0); top_ = (UBool)((specs & UCOL_TOK_TOP) != 0); u_strncpy(second,rulesCopy+chOffset, chLen); second[chLen] = 0; secondLen = chLen; if(exLen > 0) { u_strncat(first, rulesCopy+exOffset, exLen); first[firstLen+exLen] = 0; firstLen += exLen; } if(strength != UCOL_TOK_RESET) { if((*first<0x3400 || *first>=0xa000) && (*second<0x3400 || *second>=0xa000)) { UCAdiff += testSwitch(&ucaTest, (void *)UCA, 0, strength, first, second, refName, error); /*Windiff += testSwitch(&winTest, (void *)lcid, 0, strength, first, second, "Win32");*/ } } firstLen = chLen; u_strcpy(first, second); } if(UCAdiff != 0 && Windiff != 0) { log_verbose("\n"); } if(UCAdiff == 0) { log_verbose("No immediate difference with %s!\n", refName); } if(Windiff == 0) { log_verbose("No immediate difference with Win32!\n"); } uprv_free(rulesCopy); } } static void testCEs(UCollator *coll, UErrorCode *status) { const UChar *rules = NULL, *current = NULL; int32_t ruleLen = 0; uint32_t strength = 0; uint32_t maxStrength = UCOL_IDENTICAL; uint32_t baseCE, baseContCE, nextCE, nextContCE, currCE, currContCE; uint32_t lastCE; uint32_t lastContCE; int32_t result = 0; uint32_t chOffset = 0; uint32_t chLen = 0; uint32_t exOffset = 0; uint32_t exLen = 0; uint32_t prefixOffset = 0; uint32_t prefixLen = 0; uint32_t oldOffset = 0; /* uint32_t rExpsLen = 0; */ /* uint32_t firstLen = 0; */ uint8_t specs = 0; UBool varT = FALSE; UBool top_ = TRUE; UBool startOfRules = TRUE; UColTokenParser src; UColOptionSet opts; UParseError parseError; UChar *rulesCopy = NULL; collIterate c; baseCE=baseContCE=nextCE=nextContCE=currCE=currContCE=lastCE=lastContCE = UCOL_NOT_FOUND; src.opts = &opts; rules = ucol_getRules(coll, &ruleLen); ucol_initInverseUCA(status); if(U_SUCCESS(*status) && ruleLen > 0) { rulesCopy = (UChar *)uprv_malloc((ruleLen+UCOL_TOK_EXTRA_RULE_SPACE_SIZE)*sizeof(UChar)); uprv_memcpy(rulesCopy, rules, ruleLen*sizeof(UChar)); src.source = src.current = rulesCopy; src.end = rulesCopy+ruleLen; src.extraCurrent = src.end; src.extraEnd = src.end+UCOL_TOK_EXTRA_RULE_SPACE_SIZE; while ((current = ucol_tok_parseNextToken(&src, &strength, &chOffset, &chLen, &exOffset, &exLen, &prefixOffset, &prefixLen, &specs, startOfRules, &parseError,status)) != NULL) { startOfRules = FALSE; varT = (UBool)((specs & UCOL_TOK_VARIABLE_TOP) != 0); top_ = (UBool)((specs & UCOL_TOK_TOP) != 0); init_collIterate(coll, rulesCopy+chOffset, chLen, &c); currCE = ucol_getNextCE(coll, &c, status); if(currCE == 0 && UCOL_ISTHAIPREVOWEL(*(rulesCopy+chOffset))) { log_verbose("Thai prevowel detected. Will pick next CE\n"); currCE = ucol_getNextCE(coll, &c, status); } currContCE = ucol_getNextCE(coll, &c, status); if(!isContinuation(currContCE)) { currContCE = 0; } if(strength == UCOL_TOK_RESET) { if(top_ == TRUE) { nextCE = baseCE = currCE = UCOL_RESET_TOP_VALUE; nextContCE = baseContCE = currContCE = 0; } else { nextCE = baseCE = currCE; nextContCE = baseContCE = currContCE; } maxStrength = UCOL_IDENTICAL; } else { if(strength < maxStrength) { maxStrength = strength; if(baseCE == UCOL_RESET_TOP_VALUE) { log_verbose("Resetting to [top]\n"); nextCE = UCOL_NEXT_TOP_VALUE; nextContCE = 0; } else { result = ucol_inv_getNextCE(baseCE & 0xFFFFFF3F, baseContCE, &nextCE, &nextContCE, maxStrength); } if(result < 0) { if(isTailored(coll, *(rulesCopy+oldOffset), status)) { log_verbose("Reset is tailored codepoint %04X, don't know how to continue, taking next test\n", *(rulesCopy+oldOffset)); return; } else { log_err("couldn't find the CE\n"); return; } } } currCE &= 0xFFFFFF3F; currContCE &= 0xFFFFFFBF; if(maxStrength == UCOL_IDENTICAL) { if(baseCE != currCE || baseContCE != currContCE) { log_err("current CE (initial strength UCOL_EQUAL)\n"); } } else { if(strength == UCOL_IDENTICAL) { if(lastCE != currCE || lastContCE != currContCE) { log_err("current CE (initial strength UCOL_EQUAL)\n"); } } else { if(currCE > nextCE || (currCE == nextCE && currContCE >= nextContCE)) { log_err("current CE is not less than base CE\n"); } if(currCE < lastCE || (currCE == lastCE && currContCE <= lastContCE)) { log_err("sequence of generated CEs is broken\n"); } } } } oldOffset = chOffset; lastCE = currCE & 0xFFFFFF3F; lastContCE = currContCE & 0xFFFFFFBF; } uprv_free(rulesCopy); } } #if 0 /* these locales are now picked from index RB */ static const char* localesToTest[] = { "ar", "bg", "ca", "cs", "da", "el", "en_BE", "en_US_POSIX", "es", "et", "fi", "fr", "hi", "hr", "hu", "is", "iw", "ja", "ko", "lt", "lv", "mk", "mt", "nb", "nn", "nn_NO", "pl", "ro", "ru", "sh", "sk", "sl", "sq", "sr", "sv", "th", "tr", "uk", "vi", "zh", "zh_TW" }; #endif static const char* rulesToTest[] = { /*"& Z < p, P",*/ /* Cui Mins rules */ "image->jamoSpecial == TRUE) { log_err("%s has special JAMOs\n", locName); } ucol_setAttribute(coll, UCOL_CASE_FIRST, UCOL_OFF, &status); testCollator(coll, &status); testCEs(coll, &status); ucol_close(coll); } } } for(i = 0; iNFC, NORM_BUFFER_TEST_LEN, &status); nfdSize = unorm_normalize(&u, 1, UNORM_NFD, 0, t[noCases]->NFD, NORM_BUFFER_TEST_LEN, &status); if(nfcSize != nfdSize || (uprv_memcmp(t[noCases]->NFC, t[noCases]->NFD, nfcSize * sizeof(UChar)) != 0)) { t[noCases]->u = u; noCases++; t[noCases] = (tester *)uprv_malloc(sizeof(tester)); uprv_memset(t[noCases], 0, sizeof(tester)); } } log_verbose("Testing UCA extensively\n"); coll = ucol_open("", &status); for(u=0; uNFC, t[u]->NFD, UCOL_EQUAL); } ucol_close(coll); for(i = 0; iNFC, -1, t[u]->NFD, -1)) { log_err("Failure: codePoint %04X fails TestComposeDecompose for locale %s\n", t[u]->u, cName); /*doTest(coll, t[u]->NFC, t[u]->NFD, UCOL_EQUAL);*/ } } ucol_close(coll); } } for(u = 0; u <= noCases; u++) { uprv_free(t[u]); } uprv_free(t); } static void TestEmptyRule() { UErrorCode status = U_ZERO_ERROR; UChar rulez[] = { 0 }; UCollator *coll = ucol_openRules(rulez, 0, UCOL_OFF, UCOL_TERTIARY,NULL, &status); ucol_close(coll); } static void TestUCARules() { UErrorCode status = U_ZERO_ERROR; UChar b[256]; UChar *rules = b; UCollator *UCAfromRules = NULL; UCollator *coll = ucol_open("", &status); uint32_t ruleLen = ucol_getRulesEx(coll, UCOL_FULL_RULES, rules, 256); log_verbose("TestUCARules\n"); if(ruleLen > 256) { rules = (UChar *)malloc((ruleLen+1)*sizeof(UChar)); ruleLen = ucol_getRulesEx(coll, UCOL_FULL_RULES, rules, ruleLen); } log_verbose("Rules length is %d\n", ruleLen); UCAfromRules = ucol_openRules(rules, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status); if(U_SUCCESS(status)) { ucol_close(UCAfromRules); } else { log_verbose("Unable to create a collator from UCARules!\n"); } /* u_unescape(blah, b, 256); ucol_getSortKey(coll, b, 1, res, 256); */ ucol_close(coll); if(rules != b) { free(rules); } } /* Pinyin tonal order */ /* A < .. (\u0101) < .. (\u00e1) < .. (\u01ce) < .. (\u00e0) (w/macron)< (w/acute)< (w/caron)< (w/grave) E < .. (\u0113) < .. (\u00e9) < .. (\u011b) < .. (\u00e8) I < .. (\u012b) < .. (\u00ed) < .. (\u01d0) < .. (\u00ec) O < .. (\u014d) < .. (\u00f3) < .. (\u01d2) < .. (\u00f2) U < .. (\u016b) < .. (\u00fa) < .. (\u01d4) < .. (\u00f9) < .. (\u01d6) < .. (\u01d8) < .. (\u01da) < .. (\u01dc) < .. (\u00fc) However, in testing we got the following order: A < .. (\u00e1) < .. (\u00e0) < .. (\u01ce) < .. (\u0101) (w/acute)< (w/grave)< (w/caron)< (w/macron) E < .. (\u00e9) < .. (\u00e8) < .. (\u00ea) < .. (\u011b) < .. (\u0113) I < .. (\u00ed) < .. (\u00ec) < .. (\u01d0) < .. (\u012b) O < .. (\u00f3) < .. (\u00f2) < .. (\u01d2) < .. (\u014d) U < .. (\u00fa) < .. (\u00f9) < .. (\u01d4) < .. (\u00fc) < .. (\u01d8) < .. (\u01dc) < .. (\u01da) < .. (\u01d6) < .. (\u016b) */ static void TestBefore() { const static char *data[] = { "\\u0101", "\\u00e1", "\\u01ce", "\\u00e0", "A", "\\u0113", "\\u00e9", "\\u011b", "\\u00e8", "E", "\\u012b", "\\u00ed", "\\u01d0", "\\u00ec", "I", "\\u014d", "\\u00f3", "\\u01d2", "\\u00f2", "O", "\\u016b", "\\u00fa", "\\u01d4", "\\u00f9", "U", "\\u01d6", "\\u01d8", "\\u01da", "\\u01dc", "\\u00fc" }; genericRulesStarter( "&[before 1]a<\\u0101<\\u00e1<\\u01ce<\\u00e0" "&[before 1]e<\\u0113<\\u00e9<\\u011b<\\u00e8" "&[before 1]i<\\u012b<\\u00ed<\\u01d0<\\u00ec" "&[before 1]o<\\u014d<\\u00f3<\\u01d2<\\u00f2" "&[before 1]u<\\u016b<\\u00fa<\\u01d4<\\u00f9" "&u<\\u01d6<\\u01d8<\\u01da<\\u01dc<\\u00fc", data, sizeof(data)/sizeof(data[0])); } static void TestJ784() { const static char *data[] = { "A", "\\u0101", "\\u00e1", "\\u01ce", "\\u00e0", "E", "\\u0113", "\\u00e9", "\\u011b", "\\u00e8", "I", "\\u012b", "\\u00ed", "\\u01d0", "\\u00ec", "O", "\\u014d", "\\u00f3", "\\u01d2", "\\u00f2", "U", "\\u016b", "\\u00fa", "\\u01d4", "\\u00f9", "\\u00fc", "\\u01d6", "\\u01d8", "\\u01da", "\\u01dc" }; genericLocaleStarter("zh", data, sizeof(data)/sizeof(data[0])); } static void TestJ831() { const static char *data[] = { "I", "i", "Y", "y" }; genericLocaleStarter("lv", data, sizeof(data)/sizeof(data[0])); } static void TestJ815() { const static char *data[] = { "aa", "Aa", "ab", "Ab", "ad", "Ad", "ae", "Ae", "\\u00e6", "\\u00c6", "af", "Af", "b", "B" }; genericLocaleStarter("fr", data, sizeof(data)/sizeof(data[0])); genericRulesStarter("[backwards 2]&A<<\\u00e6/e<<<\\u00c6/E", data, sizeof(data)/sizeof(data[0])); } /* "& a < b < c < d& r < c", "& a < b < d& r < c", "& a < b < c < d& c < m", "& a < b < c < m < d", "& a < b < c < d& a < m", "& a < m < b < c < d", "& a <<< b << c < d& a < m", "& a <<< b << c < m < d", "& a < b < c < d& [before 1] c < m", "& a < b < m < c < d", "& a < b <<< c << d <<< e& [before 3] e <<< x", "& a < b <<< c << d <<< x <<< e", "& a < b <<< c << d <<< e& [before 2] e <<< x", "& a < b <<< c <<< x << d <<< e", "& a < b <<< c << d <<< e& [before 1] e <<< x", "& a <<< x < b <<< c << d <<< e", "& a < b <<< c << d <<< e <<< f < g& [before 1] g < x", "& a < b <<< c << d <<< e <<< f < x < g", */ static void TestRedundantRules() { int32_t i; const static char *rules[] = { "& a <<< b <<< c << d <<< e& [before 1] e <<< x", "& a < b <<< c << d <<< e& [before 1] e <<< x", "& a < b < c < d& [before 1] c < m", "& a < b <<< c << d <<< e& [before 3] e <<< x", "& a < b <<< c << d <<< e& [before 2] e <<< x", "& a < b <<< c << d <<< e <<< f < g& [before 1] g < x", "& a <<< b << c < d& a < m", "&aimage)->jamoSpecial = TRUE; /* don't try this at home */ genericOrderingTest(coll, koreanData, sizeof(koreanData)/sizeof(koreanData[0])); ucol_close(coll); log_verbose("Using ko__LOTUS locale\n"); genericLocaleStarter("ko__LOTUS", koreanData, sizeof(koreanData)/sizeof(koreanData[0])); } static void TestCompressOverlap() { UChar secstr[150]; UChar tertstr[150]; UErrorCode status = U_ZERO_ERROR; UCollator *coll; char result[200]; uint32_t resultlen; int count = 0; char *tempptr; coll = ucol_open("", &status); if (U_FAILURE(status)) { log_err("Collator can't be created\n"); return; } while (count < 149) { secstr[count] = 0x0020; /* [06, 05, 05] */ tertstr[count] = 0x0020; count ++; } /* top down compression ----------------------------------- */ secstr[count] = 0x0332; /* [, 87, 05] */ tertstr[count] = 0x3000; /* [06, 05, 07] */ /* no compression secstr should have 150 secondary bytes, tertstr should have 150 tertiary bytes. with correct overlapping compression, secstr should have 4 secondary bytes, tertstr should have > 2 tertiary bytes */ resultlen = ucol_getSortKey(coll, secstr, 150, (uint8_t *)result, 250); tempptr = uprv_strchr(result, 1) + 1; while (*(tempptr + 1) != 1) { /* the last secondary collation element is not checked since it is not part of the compression */ if (*tempptr < UCOL_COMMON_TOP2 - UCOL_TOP_COUNT2) { log_err("Secondary compression overlapped\n"); } tempptr ++; } /* tertiary top/bottom/common for en_US is similar to the secondary top/bottom/common */ resultlen = ucol_getSortKey(coll, tertstr, 150, (uint8_t *)result, 250); tempptr = uprv_strrchr(result, 1) + 1; while (*(tempptr + 1) != 0) { /* the last secondary collation element is not checked since it is not part of the compression */ if (*tempptr < coll->tertiaryTop - coll->tertiaryTopCount) { log_err("Tertiary compression overlapped\n"); } tempptr ++; } /* bottom up compression ------------------------------------- */ secstr[count] = 0; tertstr[count] = 0; resultlen = ucol_getSortKey(coll, secstr, 150, (uint8_t *)result, 250); tempptr = uprv_strchr(result, 1) + 1; while (*(tempptr + 1) != 1) { /* the last secondary collation element is not checked since it is not part of the compression */ if (*tempptr > UCOL_COMMON_BOT2 + UCOL_BOT_COUNT2) { log_err("Secondary compression overlapped\n"); } tempptr ++; } /* tertiary top/bottom/common for en_US is similar to the secondary top/bottom/common */ resultlen = ucol_getSortKey(coll, tertstr, 150, (uint8_t *)result, 250); tempptr = uprv_strrchr(result, 1) + 1; while (*(tempptr + 1) != 0) { /* the last secondary collation element is not checked since it is not part of the compression */ if (*tempptr > coll->tertiaryBottom + coll->tertiaryBottomCount) { log_err("Tertiary compression overlapped\n"); } tempptr ++; } } static void TestCyrillicTailoring(void) { static const char *test[] = { "\\u0410b", "\\u0410\\u0306a", "\\u04d0A" }; genericLocaleStarter("ru", test, 3); genericRulesStarter("&\\u0410 = \\u0410", test, 3); genericRulesStarter("&Z < \\u0410", test, 3); genericRulesStarter("&\\u0410 = \\u0410 < \\u04d0", test, 3); genericRulesStarter("&Z < \\u0410 < \\u04d0", test, 3); genericRulesStarter("&\\u0410 = \\u0410 < \\u0410\\u0301", test, 3); genericRulesStarter("&Z < \\u0410 < \\u0410\\u0301", test, 3); } static void TestContraction() { const static char *testrules[] = { "&A = AB / B", "&A = A\\u0306/\\u0306", "&c = ch / h" }; const static UChar testdata[][2] = { {0x0041 /* 'A' */, 0x0042 /* 'B' */}, {0x0041 /* 'A' */, 0x0306 /* combining breve */}, {0x0063 /* 'c' */, 0x0068 /* 'h' */} }; const static UChar testdata2[][2] = { {0x0063 /* 'c' */, 0x0067 /* 'g' */}, {0x0063 /* 'c' */, 0x0068 /* 'h' */}, {0x0063 /* 'c' */, 0x006C /* 'l' */} }; const static char *testrules3[] = { "&z < xyz &xyzw << B", "&z < xyz &xyz << B / w", "&z < ch &achm << B", "&z < ch &a << B / chm", "&\\ud800\\udc00w << B", "&\\ud800\\udc00 << B / w", "&a\\ud800\\udc00m << B", "&a << B / \\ud800\\udc00m", }; UErrorCode status = U_ZERO_ERROR; UCollator *coll; UChar rule[256] = {0}; uint32_t rlen = 0; int i; for (i = 0; i < sizeof(testrules) / sizeof(testrules[0]); i ++) { UCollationElements *iter1; int j = 0; log_verbose("Rule %s for testing\n", testrules[i]); rlen = u_unescape(testrules[i], rule, 32); coll = ucol_openRules(rule, rlen, UCOL_ON, UCOL_TERTIARY,NULL, &status); if (U_FAILURE(status)) { log_err("Collator creation failed %s\n", testrules[i]); return; } iter1 = ucol_openElements(coll, testdata[i], 2, &status); if (U_FAILURE(status)) { log_err("Collation iterator creation failed\n"); return; } while (j < 2) { UCollationElements *iter2 = ucol_openElements(coll, &(testdata[i][j]), 1, &status); uint32_t ce; if (U_FAILURE(status)) { log_err("Collation iterator creation failed\n"); return; } ce = ucol_next(iter2, &status); while (ce != UCOL_NULLORDER) { if ((uint32_t)ucol_next(iter1, &status) != ce) { log_err("Collation elements in contraction split does not match\n"); return; } ce = ucol_next(iter2, &status); } j ++; ucol_closeElements(iter2); } if (ucol_next(iter1, &status) != UCOL_NULLORDER) { log_err("Collation elements not exhausted\n"); return; } ucol_closeElements(iter1); ucol_close(coll); } rlen = u_unescape("& a < b < c < ch < d & c = ch / h", rule, 256); coll = ucol_openRules(rule, rlen, UCOL_ON, UCOL_TERTIARY,NULL, &status); if (ucol_strcoll(coll, testdata2[0], 2, testdata2[1], 2) != UCOL_LESS) { log_err("Expected \\u%04x\\u%04x < \\u%04x\\u%04x\n", testdata2[0][0], testdata2[0][1], testdata2[1][0], testdata2[1][1]); return; } if (ucol_strcoll(coll, testdata2[1], 2, testdata2[2], 2) != UCOL_LESS) { log_err("Expected \\u%04x\\u%04x < \\u%04x\\u%04x\n", testdata2[1][0], testdata2[1][1], testdata2[2][0], testdata2[2][1]); return; } ucol_close(coll); for (i = 0; i < sizeof(testrules3) / sizeof(testrules3[0]); i += 2) { UCollator *coll1, *coll2; UCollationElements *iter1, *iter2; UChar ch = 0x0042 /* 'B' */; uint32_t ce; rlen = u_unescape(testrules3[i], rule, 32); coll1 = ucol_openRules(rule, rlen, UCOL_ON, UCOL_TERTIARY,NULL, &status); rlen = u_unescape(testrules3[i + 1], rule, 32); coll2 = ucol_openRules(rule, rlen, UCOL_ON, UCOL_TERTIARY,NULL, &status); if (U_FAILURE(status)) { log_err("Collator creation failed %s\n", testrules[i]); return; } iter1 = ucol_openElements(coll1, &ch, 1, &status); iter2 = ucol_openElements(coll2, &ch, 1, &status); if (U_FAILURE(status)) { log_err("Collation iterator creation failed\n"); return; } ce = ucol_next(iter1, &status); if (U_FAILURE(status)) { log_err("Retrieving ces failed\n"); return; } while (ce != UCOL_NULLORDER) { if (ce != (uint32_t)ucol_next(iter2, &status)) { log_err("CEs does not match\n"); return; } ce = ucol_next(iter1, &status); if (U_FAILURE(status)) { log_err("Retrieving ces failed\n"); return; } } if (ucol_next(iter2, &status) != UCOL_NULLORDER) { log_err("CEs not exhausted\n"); return; } ucol_closeElements(iter1); ucol_closeElements(iter2); ucol_close(coll1); ucol_close(coll2); } } static void TestExpansion() { const static char *testrules[] = { "&J << K / B & K << M", "&J << K / B << M" }; const static UChar testdata[][3] = { {0x004A /*'J'*/, 0x0041 /*'A'*/, 0}, {0x004D /*'M'*/, 0x0041 /*'A'*/, 0}, {0x004B /*'K'*/, 0x0041 /*'A'*/, 0}, {0x004B /*'K'*/, 0x0043 /*'C'*/, 0}, {0x004A /*'J'*/, 0x0043 /*'C'*/, 0}, {0x004D /*'M'*/, 0x0043 /*'C'*/, 0} }; UErrorCode status = U_ZERO_ERROR; UCollator *coll; UChar rule[256] = {0}; uint32_t rlen = 0; int i; for (i = 0; i < sizeof(testrules) / sizeof(testrules[0]); i ++) { int j = 0; log_verbose("Rule %s for testing\n", testrules[i]); rlen = u_unescape(testrules[i], rule, 32); coll = ucol_openRules(rule, rlen, UCOL_ON, UCOL_TERTIARY,NULL, &status); if (U_FAILURE(status)) { log_err("Collator creation failed %s\n", testrules[i]); return; } for (j = 0; j < 5; j ++) { doTest(coll, testdata[j], testdata[j + 1], UCOL_LESS); } ucol_close(coll); } } static void TestLimitations() { /* recursive expansions */ { static const char *rule = "&a=b/c&d=c/e"; static const char *tlimit01[] = {"add","b","adf"}; static const char *tlimit02[] = {"aa","b","af"}; log_verbose("recursive expansions\n"); genericRulesStarter(rule, tlimit01, sizeof(tlimit01)/sizeof(tlimit01[0])); genericRulesStarter(rule, tlimit02, sizeof(tlimit02)/sizeof(tlimit02[0])); } /* contractions spanning expansions */ { static const char *rule = "&a<< 0) { ucol_setAttribute(coll, UCOL_ALTERNATE_HANDLING, UCOL_SHIFTED, &status); src.source = src.current = rulesCopy; src.end = rulesCopy+rulesLen; src.extraCurrent = src.end; src.extraEnd = src.end+UCOL_TOK_EXTRA_RULE_SPACE_SIZE; while ((current = ucol_tok_parseNextToken(&src, &strength, &chOffset, &chLen, &exOffset, &exLen, &prefixOffset, &prefixLen, &specs, startOfRules, &parseError,&status)) != NULL) { startOfRules = FALSE; if(0) { log_verbose("%04X %d ", *(rulesCopy+chOffset), chLen); } if(strength == UCOL_PRIMARY) { status = U_ZERO_ERROR; varTopOriginal = ucol_getVariableTop(coll, &status); varTop1 = ucol_setVariableTop(coll, rulesCopy+oldChOffset, oldChLen, &status); if(U_FAILURE(status)) { if(status == U_PRIMARY_TOO_LONG_ERROR) { log_verbose("= Expected failure for %04X =", *(rulesCopy+oldChOffset)); } else { log_err("Unexpected failure setting variable top for %04X at offset %d. Error %s\n", *(rulesCopy+oldChOffset), oldChOffset, u_errorName(status)); } continue; } varTop2 = ucol_getVariableTop(coll, &status); if((varTop1 & 0xFFFF0000) != (varTop2 & 0xFFFF0000)) { log_err("cannot retrieve set varTop value!\n"); continue; } if((varTop1 & 0xFFFF0000) > 0 && oldExLen == 0) { u_strncpy(first, rulesCopy+oldChOffset, oldChLen); u_strncpy(first+oldChLen, rulesCopy+chOffset, chLen); u_strncpy(first+oldChLen+chLen, rulesCopy+oldChOffset, oldChLen); first[2*oldChLen+chLen] = 0; if(oldExLen == 0) { u_strncpy(second, rulesCopy+chOffset, chLen); second[chLen] = 0; } else { /* This is skipped momentarily, but should work once UCARules are fully UCA conformant */ u_strncpy(second, rulesCopy+oldExOffset, oldExLen); u_strncpy(second+oldChLen, rulesCopy+chOffset, chLen); u_strncpy(second+oldChLen+chLen, rulesCopy+oldExOffset, oldExLen); second[2*oldExLen+chLen] = 0; } result = ucol_strcoll(coll, first, -1, second, -1); if(result == UCOL_EQUAL) { doTest(coll, first, second, UCOL_EQUAL); } else { log_verbose("Suspicious strcoll result for %04X and %04X\n", *(rulesCopy+oldChOffset), *(rulesCopy+chOffset)); } } } if(strength != UCOL_TOK_RESET) { oldChOffset = chOffset; oldChLen = chLen; oldExOffset = exOffset; oldExLen = exLen; } } } else { log_err("Unexpected failure getting rules %s\n", u_errorName(status)); return; } status = U_ZERO_ERROR; log_verbose("Testing setting variable top to contractions\n"); { /* uint32_t tailoredCE = UCOL_NOT_FOUND; */ UChar *conts = (UChar *)((uint8_t *)coll->image + coll->image->contractionUCACombos); while(*conts != 0) { if(*(conts+2) == 0) { varTop1 = ucol_setVariableTop(coll, conts, -1, &status); } else { varTop1 = ucol_setVariableTop(coll, conts, 3, &status); } if(U_FAILURE(status)) { log_err("Couldn't set variable top to a contraction\n"); } conts+=3; } status = U_ZERO_ERROR; first[0] = 0x0040; first[1] = 0x0050; first[2] = 0x0000; ucol_setVariableTop(coll, first, -1, &status); if(U_SUCCESS(status)) { log_err("Invalid contraction succeded in setting variable top!\n"); } } log_verbose("Test restoring variable top\n"); status = U_ZERO_ERROR; ucol_restoreVariableTop(coll, varTopOriginal, &status); if(varTopOriginal != ucol_getVariableTop(coll, &status)) { log_err("Couldn't restore old variable top\n"); } log_verbose("Testing calling with error set\n"); status = U_INTERNAL_PROGRAM_ERROR; varTop1 = ucol_setVariableTop(coll, first, 1, &status); varTop2 = ucol_getVariableTop(coll, &status); ucol_restoreVariableTop(coll, varTop2, &status); varTop1 = ucol_setVariableTop(NULL, first, 1, &status); varTop2 = ucol_getVariableTop(NULL, &status); ucol_restoreVariableTop(NULL, varTop2, &status); if(status != U_INTERNAL_PROGRAM_ERROR) { log_err("Bad reaction to passed error!\n"); } ucol_close(coll); } static void TestNonChars() { static const char *test[] = { "\\u0000", "\\uFFFE", "\\uFFFF", "\\U0001FFFE", "\\U0001FFFF", "\\U0002FFFE", "\\U0002FFFF", "\\U0003FFFE", "\\U0003FFFF", "\\U0004FFFE", "\\U0004FFFF", "\\U0005FFFE", "\\U0005FFFF", "\\U0006FFFE", "\\U0006FFFF", "\\U0007FFFE", "\\U0007FFFF", "\\U0008FFFE", "\\U0008FFFF", "\\U0009FFFE", "\\U0009FFFF", "\\U000AFFFE", "\\U000AFFFF", "\\U000BFFFE", "\\U000BFFFF", "\\U000CFFFE", "\\U000CFFFF", "\\U000DFFFE", "\\U000DFFFF", "\\U000EFFFE", "\\U000EFFFF", "\\U000FFFFE", "\\U000FFFFF", "\\U0010FFFE", "\\U0010FFFF" }; UErrorCode status = U_ZERO_ERROR; UCollator *coll = ucol_open("en_US", &status); log_verbose("Test non characters\n"); if(U_SUCCESS(status)) { genericOrderingTestWithResult(coll, test, 35, UCOL_EQUAL); } else { log_err("Unable to open collator\n"); } ucol_close(coll); } static void TestExtremeCompression() { static const char *test[] = { "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaad" }; genericLocaleStarter("en_US", test, 4); } static void TestSurrogates() { UErrorCode status = U_ZERO_ERROR; static const char *test[] = { "z","\\ud900\\udc25", "\\ud805\\udc50", "\\ud800\\udc00y", "\\ud800\\udc00r", "\\ud800\\udc00f", "\\ud800\\udc00", "\\ud800\\udc00c", "\\ud800\\udc00b", "\\ud800\\udc00fa", "\\ud800\\udc00fb", "\\ud800\\udc00a", "c", "b" }; static const char *rule = "&z < \\ud900\\udc25 < \\ud805\\udc50" "< \\ud800\\udc00y < \\ud800\\udc00r" "< \\ud800\\udc00f << \\ud800\\udc00" "< \\ud800\\udc00fa << \\ud800\\udc00fb" "< \\ud800\\udc00a < c < b" ; genericRulesStarter(rule, test, 14); } static void TestNewJapanese() { UErrorCode status = U_ZERO_ERROR; /*UParseError parseError;*/ UCollator *coll = NULL; UChar string[256] = {0}; uint32_t uStringLen = 0; /*UCollator *coll = ucol_open("ja_JP_JIS", &status); */ /*"&\u304b\u3099<<<\u304c|\u309d=\u304b|\u309d\u3099=\u304c|\u309d\u3099"*/ static const char *rules = "&\\u30A1=\\u3041" "&\\u30A2=\\u3042" "&\\u30A3=\\u3043" "&\\u30A4=\\u3044" "&\\u30A5=\\u3045" "&\\u30A6=\\u3046" "&\\u30A7=\\u3047" "&\\u30A8=\\u3048" "&\\u30A9=\\u3049" "&\\u30AA=\\u304A" "&\\u30AB=\\u304B" "&\\u30AB\\u3099=\\u304B\\u3099" "&\\u30AD=\\u304D" "&\\u30AD\\u3099=\\u304D\\u3099" "&\\u30AF=\\u304F" "&\\u30AF\\u3099=\\u304F\\u3099" "&\\u30B1=\\u3051" "&\\u30B1\\u3099=\\u3051\\u3099" "&\\u30B3=\\u3053" "&\\u30B3\\u3099=\\u3053\\u3099" "&\\u30B5=\\u3055" "&\\u30B5\\u3099=\\u3055\\u3099" "&\\u30B7=\\u3057" "&\\u30B7\\u3099=\\u3057\\u3099" "&\\u30B9=\\u3059" "&\\u30B9\\u3099=\\u3059\\u3099" "&\\u30BB=\\u305B" "&\\u30BB\\u3099=\\u305B\\u3099" "&\\u30BD=\\u305D" "&\\u30BD\\u3099=\\u305D\\u3099" "&\\u30BF=\\u305F" "&\\u30BF\\u3099=\\u305F\\u3099" "&\\u30C1=\\u3061" "&\\u30C1\\u3099=\\u3061\\u3099" "&\\u30C3=\\u3063" "&\\u30C4=\\u3064" "&\\u30C4\\u3099=\\u3064\\u3099" "&\\u30C6=\\u3066" "&\\u30C6\\u3099=\\u3066\\u3099" "&\\u30C8=\\u3068" "&\\u30C8\\u3099=\\u3068\\u3099" "&\\u30CA=\\u306A" "&\\u30CB=\\u306B" "&\\u30CC=\\u306C" "&\\u30CD=\\u306D" "&\\u30CE=\\u306E" "&\\u30CF=\\u306F" "&\\u30CF\\u3099=\\u306F\\u3099" "&\\u30CF\\u309A=\\u306F\\u309A" "&\\u30D2=\\u3072" "&\\u30D2\\u3099=\\u3072\\u3099" "&\\u30D2\\u309A=\\u3072\\u309A" "&\\u30D5=\\u3075" "&\\u30D5\\u3099=\\u3075\\u3099" "&\\u30D5\\u309A=\\u3075\\u309A" "&\\u30D8=\\u3078" "&\\u30D8\\u3099=\\u3078\\u3099" "&\\u30D8\\u309A=\\u3078\\u309A" "&\\u30DB=\\u307B" "&\\u30DB\\u3099=\\u307B\\u3099" "&\\u30DB\\u309A=\\u307B\\u309A" "&\\u30DE=\\u307E" "&\\u30DF=\\u307F" "&\\u30E0=\\u3080" "&\\u30E1=\\u3081" "&\\u30E2=\\u3082" "&\\u30E3=\\u3083" "&\\u30E4=\\u3084" "&\\u30E5=\\u3085" "&\\u30E6=\\u3086" "&\\u30E7=\\u3087" "&\\u30E8=\\u3088" "&\\u30E9=\\u3089" "&\\u30EA=\\u308A" "&\\u30EB=\\u308B" "&\\u30EC=\\u308C" "&\\u30ED=\\u308D" "&\\u30EE=\\u308E" "&\\u30EF=\\u308F" "&\\u30F0=\\u3090" "&\\u30F1=\\u3091" "&\\u30F2=\\u3092" "&\\u30F3=\\u3093" "&\\u30A6\\u3099=\\u3046\\u3099" "&[before 3]\\u30a2" "<<<\\u30a1|\\u30fc=\\u30a2|\\u30fc=\\u30ab|\\u30fc=\\u30f5|\\u30fc" "=\\u30b5|\\u30fc=\\u30bf|\\u30fc=\\u30ca|\\u30fc=\\u30cf|\\u30fc" "=\\u30de|\\u30fc=\\u30e3|\\u30fc=\\u30e4|\\u30fc=\\u30e9|\\u30fc" "=\\u30ef|\\u30fc=\\u30ee|\\u30fc" "=\\u30ab\\u3099|\\u30fc=\\u30b5\\u3099|\\u30fc=\\u30bf\\u3099|\\u30fc=\\u30cf\\u3099|\\u30fc" "=\\u30cf\\u309a|\\u30fc" "&[before 3]\\u30a4" "<<<\\u30a3|\\u30fc=\\u30a4|\\u30fc=\\u30ad|\\u30fc=\\u30b7|\\u30fc" "=\\u30c1|\\u30fc=\\u30cb|\\u30fc=\\u30d2|\\u30fc=\\u30df|\\u30fc" "=\\u30ea|\\u30fc=\\u30f0|\\u30fc" "=\\u30ad\\u3099|\\u30fc=\\u30b7\\u3099|\\u30fc=\\u30c1\\u3099|\\u30fc" "=\\u30d2\\u3099|\\u30fc=\\u30f0\\u3099\\u30fc" "=\\u30d2\\u309a\\u30fc" "&[before 3]\\u30a6" "<<<\\u30a5|\\u30fc=\\u30a6|\\u30fc=\\u30af|\\u30fc=\\u30b9|\\u30fc" "=\\u30c4|\\u30fc=\\u30c3|\\u30fc=\\u30cc|\\u30fc=\\u30d5|\\u30fc" "=\\u30e0|\\u30fc=\\u30e5|\\u30fc=\\u30e6|\\u30fc=\\u30eb|\\u30fc" "=\\u30af\\u3099|\\u30fc=\\u30b9\\u3099|\\u30fc=\\u30c4\\u3099|\\u30fc" "=\\u30d5\\u3099|\\u30fc=\\u30a6\\u3099|\\u30fc" "=\\u30d5\\u309a\\u30fc" "&[before 3]\\u30a8" "<<<\\u30a7|\\u30fc=\\u30a8|\\u30fc=\\u30b1|\\u30fc=\\u30f6|\\u30fc" "=\\u30bb|\\u30fc=\\u30c6|\\u30fc=\\u30cd|\\u30fc=\\u30d8|\\u30fc" "=\\u30e1|\\u30fc=\\u30ec|\\u30fc=\\u30f1|\\u30fc" "=\\u30b1\\u3099|\\u30fc=\\u30bb\\u3099|\\u30fc\\u30c6\\u3099|\\u30fc" "\\u30d8\\u3099|\\u30fc=\\u30f1\\u3099|\\u30fc" "=\\u30d8\\u309a|\\u30fc" "&[before 3]\\u30aa" "<<<\\u30a9|\\u30fc=\\u30aa|\\u30fc=\\u30b3|\\u30fc=\\u30bd|\\u30fc" "=\\u30c8|\\u30fc=\\u30ce|\\u30fc=\\u30db|\\u30fc=\\u30e2|\\u30fc" "=\\u30e7|\\u30fc=\\u30e8|\\u30fc=\\u30ed|\\u30fc=\\u30f2|\\u30fc" "=\\u30b3\\u3099|\\u30fc=\\u30bd\\u3099|\\u30fc=\\u30c8\\u3099|\\u30fc" "=\\u30db\\u3099|\\u30fc=\\u30f2\\u3099|\\u30fc" "=\\u30db\\u309a|\\u30aa=\\u30db\\u309a|\\u30fc" "&\\u3041<<<\\u3041|\\u309d" "&[before 3]\\u3042<<<\\u3042|\\u309d" "&\\u3043<<<\\u3043|\\u309d" "&[before 3]\\u3044<<<\\u3044|\\u309d" "&\\u3045<<<\\u3045|\\u309d" "&[before 3]\\u3046<<<\\u3046|\\u309d" "&\\u3047<<<\\u3047|\\u309d" "&[before 3]\\u3048<<<\\u3048|\\u309d" "&\\u3049<<<\\u3049|\\u309d" "&[before 3]\\u304a<<<\\u304a|\\u309d" "&[before 3]\\u304b<<<\\u304b|\\u309d" "&[before 3]\\u304b\\u3099<<<\\u304b\\u3099|\\u309d=\\u304b|\\u309e=\\u304b\\u3099|\\u309e" "&[before 3]\\u304d<<<\\u304d|\\u309d" "&[before 3]\\u304d\\u3099<<<\\u304d\\u3099|\\u309d=\\u304d|\\u309e=\\u304d\\u3099|\\u309e" "&[before 3]\\u304f<<<\\u304f|\\u309d" "&[before 3]\\u304f\\u3099<<<\\u304f\\u3099|\\u309d=\\u304f|\\u309e=\\u304f\\u3099|\\u309e" "&[before 3]\\u3051<<<\\u3051|\\u309d" "&[before 3]\\u3051\\u3099<<<\\u3051\\u3099|\\u309d=\\u3051|\\u309e=\\u3051\\u3099|\\u309e" "&[before 3]\\u3053<<<\\u3053|\\u309d" "&[before 3]\\u3053\\u3099<<<\\u3053\\u3099|\\u309d=\\u3053|\\u309e=\\u3053\\u3099|\\u309e" "&[before 3]\\u3055<<<\\u3055|\\u309d" "&[before 3]\\u3055\\u3099<<<\\u3055\\u3099|\\u309d=\\u3055|\\u309e=\\u3055\\u3099|\\u309e" "&[before 3]\\u3057<<<\\u3057|\\u309d" "&[before 3]\\u3057\\u3099<<<\\u3057\\u3099|\\u309d=\\u3057|\\u309e=\\u3057\\u3099|\\u309e" "&[before 3]\\u3059<<<\\u3059|\\u309d" "&[before 3]\\u3059\\u3099<<<\\u3059\\u3099|\\u309d=\\u3059|\\u309e=\\u3059\\u3099|\\u309e" "&[before 3]\\u305b<<<\\u305b|\\u309d" "&[before 3]\\u305b\\u3099<<<\\u305b\\u3099|\\u309d=\\u305b|\\u309e=\\u305b\\u3099|\\u309e" "&[before 3]\\u305d<<<\\u305d|\\u309d" "&[before 3]\\u305d\\u3099<<<\\u305d\\u3099|\\u309d=\\u305d|\\u309e=\\u305d\\u3099|\\u309e" "&[before 3]\\u305f<<<\\u305f|\\u309d" "&[before 3]\\u305f\\u3099<<<\\u305f\\u3099|\\u309d=\\u305f|\\u309e=\\u305f\\u3099|\\u309e" "&[before 3]\\u3061<<<\\u3061|\\u309d" "&[before 3]\\u3061\\u3099<<<\\u3061\\u3099|\\u309d=\\u3061|\\u309e=\\u3061\\u3099|\\u309e" "&\\u3063<<<\\u3063|\\u309d" "&[before 3]\\u3064<<<\\u3064|\\u309d" "&[before 3]\\u3064\\u3099<<<\\u3064\\u3099|\\u309d=\\u3064|\\u309e=\\u3064\\u3099|\\u309e" "&[before 3]\\u3066<<<\\u3066|\\u309d" "&[before 3]\\u3066\\u3099<<<\\u3066\\u3099|\\u309d=\\u3066|\\u309e=\\u3066\\u3099|\\u309e" "&[before 3]\\u3068<<<\\u3068|\\u309d" "&[before 3]\\u3068\\u3099<<<\\u3068\\u3099|\\u309d=\\u3068|\\u309e=\\u3068\\u3099|\\u309e" "&[before 3]\\u306a<<<\\u306a|\\u309d" "&[before 3]\\u306b<<<\\u306b|\\u309d" "&[before 3]\\u306c<<<\\u306c|\\u309d" "&[before 3]\\u306d<<<\\u306d|\\u309d" "&[before 3]\\u306e<<<\\u306e|\\u309d" "&[before 3]\\u306f<<<\\u306f|\\u309d" "&[before 3]\\u306f\\u3099<<<\\u306f\\u3099|\\u309d=\\u306f|\\u309e=\\u306f\\u309a|\\u309e=\\u306f\\u3099|\\u309e" "&[before 3]\\u306f\\u309a<<<\\u306f\\u309a|\\u309d" "&[before 3]\\u3072<<<\\u3072|\\u309d" "&[before 3]\\u3072\\u3099<<<\\u3072\\u3099|\\u309d=\\u3072|\\u309e=\\u3072\\u309a|\\u309e=\\u3072\\u3099|\\u309e" "&[before 3]\\u3072\\u309a<<<\\u3072\\u309a|\\u309d" "&[before 3]\\u3075<<<\\u3075|\\u309d" "&[before 3]\\u3075\\u3099<<<\\u3075\\u3099|\\u309d=\\u3075|\\u309e=\\u3075\\u309a|\\u309e=\\u3075\\u3099|\\u309e" "&[before 3]\\u3075\\u309a<<<\\u3075\\u309a|\\u309d" "&[before 3]\\u3078<<<\\u3078|\\u309d" "&[before 3]\\u3078\\u3099<<<\\u3078\\u3099|\\u309d=\\u3078|\\u309e=\\u3078\\u309a|\\u309e=\\u3078\\u3099|\\u309e" "&[before 3]\\u3078\\u309a<<<\\u3078\\u309a|\\u309d" "&[before 3]\\u307b<<<\\u307b|\\u309d" "&[before 3]\\u307b\\u3099<<<\\u307b\\u3099|\\u309d=\\u307b|\\u309e=\\u307b\\u309a|\\u309e=\\u307b\\u3099|\\u309e" "&[before 3]\\u307b\\u309a<<<\\u307b\\u309a|\\u309d" "&[before 3]\\u307e<<<\\u307e|\\u309d" "&[before 3]\\u307f<<<\\u307f|\\u309d" "&[before 3]\\u3080<<<\\u3080|\\u309d" "&[before 3]\\u3081<<<\\u3081|\\u309d" "&[before 3]\\u3082<<<\\u3082|\\u309d" "&\\u3083<<<\\u3083|\\u309d" "&[before 3]\\u3084<<<\\u3084|\\u309d" "&\\u3085<<<\\u3085|\\u309d" "&[before 3]\\u3086<<<\\u3086|\\u309d" "&\\u3087<<<\\u3087|\\u309d" "&[before 3]\\u3088<<<\\u3088|\\u309d" "&[before 3]\\u3089<<<\\u3089|\\u309d" "&[before 3]\\u308a<<<\\u308a|\\u309d" "&[before 3]\\u308b<<<\\u308b|\\u309d" "&[before 3]\\u308c<<<\\u308c|\\u309d" "&[before 3]\\u308d<<<\\u308d|\\u309d" "&\\u308e<<<\\u308e|\\u309d" "&[before 3]\\u308f<<<\\u308f|\\u309d" "&[before 3]\\u3090<<<\\u3090|\\u309d" "&[before 3]\\u3091<<<\\u3091|\\u309d" "&[before 3]\\u3092<<<\\u3092|\\u309d" "&[before 3]\\u3093<<<\\u3093|\\u309d" "&[before 3]\\u3046\\u3099<<<\\u3046\\u3099|\\u309d=\\u3046|\\u309e=\\u3046\\u3099|\\u309e" "&\\u30a1<<<\\u30a1|\\u30fd" "&[before 3]\\u30a2<<<\\u30a2|\\u30fd" "&\\u30a3<<<\\u30a3|\\u30fd" "&[before 3]\\u30a4<<<\\u30a4|\\u30fd" "&\\u30a5<<<\\u30a5|\\u30fd" "&[before 3]\\u30a6<<<\\u30a6|\\u30fd" "&\\u30a7<<<\\u30a7|\\u30fd" "&[before 3]\\u30a8<<<\\u30a8|\\u30fd" "&\\u30a9<<<\\u30a9|\\u30fd" "&[before 3]\\u30aa<<<\\u30aa|\\u30fd" "&[before 3]\\u30ab<<<\\u30ab|\\u30fd" "&[before 3]\\u30ab\\u3099<<<\\u30ab\\u3099|\\u30fd=\\u30ab|\\u30fe=\\u30ab\\u3099|\\u30fe" "&[before 3]\\u30ad<<<\\u30ad|\\u30fd" "&[before 3]\\u30ad\\u3099<<<\\u30ad\\u3099|\\u30fd=\\u30ad|\\u30fe=\\u30ad\\u3099|\\u30fe" "&[before 3]\\u30af<<<\\u30af|\\u30fd" "&[before 3]\\u30af\\u3099<<<\\u30af\\u3099|\\u30fd=\\u30af|\\u30fe=\\u30af\\u3099|\\u30fe" "&[before 3]\\u30b1<<<\\u30b1|\\u30fd" "&[before 3]\\u30b1\\u3099<<<\\u30b1\\u3099|\\u30fd=\\u30b1|\\u30fe=\\u30b1\\u3099|\\u30fe" "&[before 3]\\u30b3<<<\\u30b3|\\u30fd" "&[before 3]\\u30b3\\u3099<<<\\u30b3\\u3099|\\u30fd=\\u30b3|\\u30fe=\\u30b3\\u3099|\\u30fe" "&[before 3]\\u30b5<<<\\u30b5|\\u30fd" "&[before 3]\\u30b5\\u3099<<<\\u30b5\\u3099|\\u30fd=\\u30b5|\\u30fe=\\u30b5\\u3099|\\u30fe" "&[before 3]\\u30b7<<<\\u30b7|\\u30fd" "&[before 3]\\u30b7\\u3099<<<\\u30b7\\u3099|\\u30fd=\\u30b7|\\u30fe=\\u30b7\\u3099|\\u30fe" "&[before 3]\\u30b9<<<\\u30b9|\\u30fd" "&[before 3]\\u30b9\\u3099<<<\\u30b9\\u3099|\\u30fd=\\u30b9|\\u30fe=\\u30b9\\u3099|\\u30fe" "&[before 3]\\u30bb<<<\\u30bb|\\u30fd" "&[before 3]\\u30bb\\u3099<<<\\u30bb\\u3099|\\u30fd=\\u30bb|\\u30fe=\\u30bb\\u3099|\\u30fe" "&[before 3]\\u30bd<<<\\u30bd|\\u30fd" "&[before 3]\\u30bd\\u3099<<<\\u30bd\\u3099|\\u30fd=\\u30bd|\\u30fe=\\u30bd\\u3099|\\u30fe" "&[before 3]\\u30bf<<<\\u30bf|\\u30fd" "&[before 3]\\u30bf\\u3099<<<\\u30bf\\u3099|\\u30fd=\\u30bf|\\u30fe=\\u30bf\\u3099|\\u30fe" "&[before 3]\\u30c1<<<\\u30c1|\\u30fd" "&[before 3]\\u30c1\\u3099<<<\\u30c1\\u3099|\\u30fd=\\u30c1|\\u30fe=\\u30c1\\u3099|\\u30fe" "&\\u30c3<<<\\u30c3|\\u30fd" "&[before 3]\\u30c4<<<\\u30c4|\\u30fd" "&[before 3]\\u30c4\\u3099<<<\\u30c4\\u3099|\\u30fd=\\u30c4|\\u30fe=\\u30c4\\u3099|\\u30fe" "&[before 3]\\u30c6<<<\\u30c6|\\u30fd" "&[before 3]\\u30c6\\u3099<<<\\u30c6\\u3099|\\u30fd=\\u30c6|\\u30fe=\\u30c6\\u3099|\\u30fe" "&[before 3]\\u30c8<<<\\u30c8|\\u30fd" "&[before 3]\\u30c8\\u3099<<<\\u30c8\\u3099|\\u30fd=\\u30c8|\\u30fe=\\u30c8\\u3099|\\u30fe" "&[before 3]\\u30ca<<<\\u30ca|\\u30fd" "&[before 3]\\u30cb<<<\\u30cb|\\u30fd" "&[before 3]\\u30cc<<<\\u30cc|\\u30fd" "&[before 3]\\u30cd<<<\\u30cd|\\u30fd" "&[before 3]\\u30ce<<<\\u30ce|\\u30fd" "&[before 3]\\u30cf<<<\\u30cf|\\u30fd" "&[before 3]\\u30cf\\u3099<<<\\u30cf\\u3099|\\u30fd=\\u30cf|\\u30fe=\\u30cf\\u309a|\\u30fe=\\u30cf\\u3099|\\u30fe" "&[before 3]\\u30cf\\u309a<<<\\u30cf\\u309a|\\u30fd" "&[before 3]\\u30d2<<<\\u30d2|\\u30fd" "&[before 3]\\u30d2\\u3099<<<\\u30d2\\u3099|\\u30fd=\\u30d2|\\u30fe=\\u30d2\\u309a|\\u30fe=\\u30d2\\u3099|\\u30fe" "&[before 3]\\u30d2\\u309a<<<\\u30d2\\u309a|\\u30fd" "&[before 3]\\u30d5<<<\\u30d5|\\u30fd" "&[before 3]\\u30d5\\u3099<<<\\u30d5\\u3099|\\u30fd=\\u30d5|\\u30fe=\\u30d5\\u309a|\\u30fe=\\u30d5\\u3099|\\u30fe" "&[before 3]\\u30d5\\u309a<<<\\u30d5\\u309a|\\u30fd" "&[before 3]\\u30d8<<<\\u30d8|\\u30fd" "&[before 3]\\u30d8\\u3099<<<\\u30d8\\u3099|\\u30fd=\\u30d8|\\u30fe=\\u30d8\\u309a|\\u30fe=\\u30d8\\u3099|\\u30fe" "&[before 3]\\u30d8\\u309a<<<\\u30d8\\u309a|\\u30fd" "&[before 3]\\u30db<<<\\u30db|\\u30fd" "&[before 3]\\u30db\\u3099<<<\\u30db\\u3099|\\u30fd=\\u30db|\\u30fe=\\u30db\\u309a|\\u30fe=\\u30db\\u3099|\\u30fe" "&[before 3]\\u30db\\u309a<<<\\u30db\\u309a|\\u30fd" "&[before 3]\\u30de<<<\\u30de|\\u30fd" "&[before 3]\\u30df<<<\\u30df|\\u30fd" "&[before 3]\\u30e0<<<\\u30e0|\\u30fd" "&[before 3]\\u30e1<<<\\u30e1|\\u30fd" "&[before 3]\\u30e2<<<\\u30e2|\\u30fd" "&\\u30e3<<<\\u30e3|\\u30fd" "&[before 3]\\u30e4<<<\\u30e4|\\u30fd" "&\\u30e5<<<\\u30e5|\\u30fd" "&[before 3]\\u30e6<<<\\u30e6|\\u30fd" "&\\u30e7<<<\\u30e7|\\u30fd" "&[before 3]\\u30e8<<<\\u30e8|\\u30fd" "&[before 3]\\u30e9<<<\\u30e9|\\u30fd" "&[before 3]\\u30ea<<<\\u30ea|\\u30fd" "&[before 3]\\u30eb<<<\\u30eb|\\u30fd" "&[before 3]\\u30ec<<<\\u30ec|\\u30fd" "&[before 3]\\u30ed<<<\\u30ed|\\u30fd" "&\\u30ee<<<\\u30ee|\\u30fd" "&[before 3]\\u30ef<<<\\u30ef|\\u30fd" "&[before 3]\\u30f0<<<\\u30f0|\\u30fd" "&[before 3]\\u30f1<<<\\u30f1|\\u30fd" "&[before 3]\\u30f2<<<\\u30f2|\\u30fd" "&[before 3]\\u30f3<<<\\u30f3|\\u30fd" "&[before 3]\\u30a6\\u3099<<<\\u30a6\\u3099|\\u30fd=\\u30a6|\\u30fe=\\u30a6\\u3099|\\u30fe" "&\\u30f5<<<\\u30f5|\\u30fd" "&\\u30f6<<<\\u30f6|\\u30fd" "&[before 3]\\u30ef\\u3099<<<\\u30ef\\u3099|\\u30fd=\\u30ef|\\u30fe=\\u30ef\\u3099|\\u30fe" "&[before 3]\\u30f0\\u3099<<<\\u30f0\\u3099|\\u30fd=\\u30f0|\\u30fe=\\u30f0\\u3099|\\u30fe" "&[before 3]\\u30f1\\u3099<<<\\u30f1\\u3099|\\u30fd=\\u30f1|\\u30fe=\\u30f1\\u3099|\\u30fe" "&[before 3]\\u30f2\\u3099<<<\\u30f2\\u3099|\\u30fd=\\u30f2|\\u30fe=\\u30f2\\u3099|\\u30fe"; /*"&z <<< z|a";*/ /* this should yield in zz<<< za */ static const char *testaz[] = { "\\u30d7\\u30fd", "\\u3077\\u3075", /*"zz", "za"*/ }; static const char *test[] = { /* "\\u30b7\\u30e3\\u30fc\\u30ec", "\\u30b7\\u30e3\\u30a4", "\\u30b7\\u30e4\\u30a3", "\\u30b7\\u30e3\\u30ec", "\\u3061\\u3087\\u3053", "\\u3061\\u3088\\u3053", "\\u30c1\\u30e7\\u30b3\\u30ec\\u30fc\\u30c8", "\\u3066\\u30fc\\u305f", "\\u30c6\\u30fc\\u30bf", "\\u30c6\\u30a7\\u30bf", "\\u3066\\u3048\\u305f", "\\u3067\\u30fc\\u305f", "\\u30c7\\u30fc\\u30bf", "\\u30c7\\u30a7\\u30bf", "\\u3067\\u3048\\u305f", "\\u3066\\u30fc\\u305f\\u30fc", "\\u30c6\\u30fc\\u30bf\\u30a1", "\\u30c6\\u30a7\\u30bf\\u30fc", "\\u3066\\u3047\\u305f\\u3041", "\\u3066\\u3048\\u305f\\u30fc", "\\u3067\\u30fc\\u305f\\u30fc", "\\u30c7\\u30fc\\u30bf\\u30a1", "\\u3067\\u30a7\\u305f\\u30a1", "\\u30c7\\u3047\\u30bf\\u3041", "\\u30c7\\u30a8\\u30bf\\u30a2", "\\u3072\\u3086", "\\u3073\\u3085\\u3042", "\\u3074\\u3085\\u3042", "\\u3073\\u3085\\u3042\\u30fc", "\\u30d3\\u30e5\\u30a2\\u30fc", "\\u3074\\u3085\\u3042\\u30fc", "\\u30d4\\u30e5\\u30a2\\u30fc", "\\u30d2\\u30e5\\u30a6", "\\u30d2\\u30e6\\u30a6", "\\u30d4\\u30e5\\u30a6\\u30a2", "\\u3074\\u3085\\u30fc\\u3042\\u30fc", "\\u30d3\\u30e5\\u30fc\\u30a2\\u30fc", "\\u30d3\\u30e5\\u30a6\\u30a2\\u30fc", "\\u3072\\u3085\\u3093", "\\u3074\\u3085\\u3093", "\\u3075\\u30fc\\u308a", "\\u30d5\\u30fc\\u30ea", "\\u3075\\u3045\\u308a", "\\u3075\\u30a5\\u308a", "\\u3075\\u30a5\\u30ea", "\\u30d5\\u30a6\\u30ea", "\\u3076\\u30fc\\u308a", "\\u30d6\\u30fc\\u30ea", "\\u3076\\u3045\\u308a", "\\u30d6\\u30a5\\u308a", "\\u3077\\u3046\\u308a", "\\u30d7\\u30a6\\u30ea", "\\u3075\\u30fc\\u308a\\u30fc", "\\u30d5\\u30a5\\u30ea\\u30fc", "\\u3075\\u30a5\\u308a\\u30a3", "\\u30d5\\u3045\\u308a\\u3043", "\\u30d5\\u30a6\\u30ea\\u30fc", "\\u3075\\u3046\\u308a\\u3043", "\\u30d6\\u30a6\\u30ea\\u30a4", "\\u3077\\u30fc\\u308a\\u30fc", "\\u3077\\u30a5\\u308a\\u30a4", "\\u3077\\u3046\\u308a\\u30fc", "\\u30d7\\u30a6\\u30ea\\u30a4", "\\u30d5\\u30fd", "\\u3075\\u309e", "\\u3076\\u309d", "\\u3076\\u3075", "\\u3076\\u30d5", "\\u30d6\\u3075", "\\u30d6\\u30d5", "\\u3076\\u309e", "\\u3076\\u3077", "\\u30d6\\u3077", "\\u3077\\u309d", "\\u30d7\\u30fd", "\\u3077\\u3075", */ "\\u3042\\u30fc", "\\u3042\\u3041", "\\u3042\\u309d", "\\u3042\\u3042", }; uint32_t i = 0; UCollationElements *it = NULL; uint32_t CE; genericRulesStarter(rules, testaz, 2); genericLocaleStarter("ja_JP_JIS", test, sizeof(test)/sizeof(test[0])); /*uStringLen = u_unescape(rules, string, 256);*/ coll = ucol_open("ja_JP_JIS", &status); it = ucol_openElements(coll, string, 0, &status); for(i = 0; i < sizeof(test)/sizeof(test[0]); i++) { log_verbose("%s\n", test[i]); uStringLen = u_unescape(test[i], string, 256); ucol_setText(it, string, uStringLen, &status); while((CE=ucol_next(it, &status)) != UCOL_NULLORDER) { log_verbose("%08X\n", CE); } log_verbose("\n"); } ucol_closeElements(it); ucol_close(coll); } void addMiscCollTest(TestNode** root) { /*addTest(root, &TestNewJapanese, "tscoll/cmsccoll/TestNewJapanese"); */ /*addTest(root, &TestLimitations, "tscoll/cmsccoll/TestLimitations");*/ addTest(root, &TestNonChars, "tscoll/cmsccoll/TestNonChars"); addTest(root, &TestExtremeCompression, "tscoll/cmsccoll/TestExtremeCompression"); addTest(root, &TestSurrogates, "tscoll/cmsccoll/TestSurrogates"); addTest(root, &TestVariableTopSetting, "tscoll/cmsccoll/TestVariableTopSetting"); addTest(root, &TestBocsuCoverage, "tscoll/cmsccoll/TestBocsuCoverage"); addTest(root, &TestCyrillicTailoring, "tscoll/cmsccoll/TestCyrillicTailoring"); addTest(root, &TestCase, "tscoll/cmsccoll/TestCase"); addTest(root, &IncompleteCntTest, "tscoll/cmsccoll/IncompleteCntTest"); addTest(root, &BlackBirdTest, "tscoll/cmsccoll/BlackBirdTest"); addTest(root, &FunkyATest, "tscoll/cmsccoll/FunkyATest"); addTest(root, &BillFairmanTest, "tscoll/cmsccoll/BillFairmanTest"); addTest(root, &RamsRulesTest, "tscoll/cmsccoll/RamsRulesTest"); addTest(root, &IsTailoredTest, "tscoll/cmsccoll/IsTailoredTest"); addTest(root, &TestCollations, "tscoll/cmsccoll/TestCollations"); addTest(root, &TestChMove, "tscoll/cmsccoll/TestChMove"); addTest(root, &TestImplicitTailoring, "tscoll/cmsccoll/TestImplicitTailoring"); addTest(root, &TestFCDProblem, "tscoll/cmsccoll/TestFCDProblem"); addTest(root, &TestEmptyRule, "tscoll/cmsccoll/TestEmptyRule"); addTest(root, &TestJ784, "tscoll/cmsccoll/TestJ784"); addTest(root, &TestJ815, "tscoll/cmsccoll/TestJ815"); addTest(root, &TestJ831, "tscoll/cmsccoll/TestJ831"); addTest(root, &TestBefore, "tscoll/cmsccoll/TestBefore"); addTest(root, &TestRedundantRules, "tscoll/cmsccoll/TestRedundantRules"); addTest(root, &TestExpansionSyntax, "tscoll/cmsccoll/TestExpansionSyntax"); addTest(root, &TestHangulTailoring, "tscoll/cmsccoll/TestHangulTailoring"); addTest(root, &TestUCARules, "tscoll/cmsccoll/TestUCARules"); addTest(root, &TestIncrementalNormalize, "tscoll/cmsccoll/TestIncrementalNormalize"); addTest(root, &TestComposeDecompose, "tscoll/cmsccoll/TestComposeDecompose"); addTest(root, &TestCompressOverlap, "tscoll/cmsccoll/TestCompressOverlap"); addTest(root, &TestContraction, "tscoll/cmsccoll/TestContraction"); addTest(root, &TestExpansion, "tscoll/cmsccoll/TestExpansion"); /*addTest(root, &PrintMarkDavis, "tscoll/cmsccoll/PrintMarkDavis");*/ /* this test doesn't test - just prints sortkeys */ /*addTest(root, &TestGetCaseBit, "tscoll/cmsccoll/TestGetCaseBit");*/ /*this one requires internal things to be exported */ }