+ /* Test Vietnamese sort. */
+ coll = ucol_open("vi", &status);
+ if(U_FAILURE(status)) {
+ log_err("Couldn't open collator %d\n", &status);
+ return;
+ }
+ log_verbose("\n\nVI collation:");
+ if ( !ucol_equal(coll, tData[0], u_strlen(tData[0]), tData[2], u_strlen(tData[2])) ) {
+ log_err("\\u1EAC not equals to \\u1EA0+\\u0302\n");
+ }
+ if ( !ucol_equal(coll, tData[0], u_strlen(tData[0]), tData[3], u_strlen(tData[3])) ) {
+ log_err("\\u1EAC not equals to \\u00c2+\\u0323\n");
+ }
+ if ( !ucol_equal(coll, tData[5], u_strlen(tData[5]), tData[4], u_strlen(tData[4])) ) {
+ log_err("\\u1ED8 not equals to \\u1ECC+\\u0302\n");
+ }
+ if ( !ucol_equal(coll, tData[7], u_strlen(tData[7]), tData[6], u_strlen(tData[6])) ) {
+ log_err("\\u1EB7 not equals to \\u1EA1+\\u0306\n");
+ }
+
+ for (j=0; j<8; j++) {
+ tLen = u_strlen(tData[j]);
+ log_verbose("\n Data :%s \tlen: %d key: ", tData[j], tLen);
+ rLen = ucol_getSortKey(coll, tData[j], tLen, resColl, 100);
+ for(i = 0; i<rLen; i++) {
+ log_verbose(" %02X", resColl[i]);
+ }
+ }
+
+ ucol_close(coll);
+
+ /* Test Romanian sort. */
+ coll = ucol_open("ro", &status);
+ log_verbose("\n\nRO collation:");
+ if ( !ucol_equal(coll, tData[0], u_strlen(tData[0]), tData[1], u_strlen(tData[1])) ) {
+ log_err("\\u1EAC not equals to \\u1EA0+\\u0302\n");
+ }
+ if ( !ucol_equal(coll, tData[4], u_strlen(tData[4]), tData[5], u_strlen(tData[5])) ) {
+ log_err("\\u1EAC not equals to \\u00c2+\\u0323\n");
+ }
+ if ( !ucol_equal(coll, tData[6], u_strlen(tData[6]), tData[7], u_strlen(tData[7])) ) {
+ log_err("\\u1EB7 not equals to \\u1EA1+\\u0306\n");
+ }
+
+ for (j=4; j<8; j++) {
+ tLen = u_strlen(tData[j]);
+ log_verbose("\n Data :%s \tlen: %d key: ", tData[j], tLen);
+ rLen = ucol_getSortKey(coll, tData[j], tLen, resColl, 100);
+ for(i = 0; i<rLen; i++) {
+ log_verbose(" %02X", resColl[i]);
+ }
+ }
+ ucol_close(coll);
+
+ /* Test the precomposed Greek character with 3 combining marks. */
+ log_verbose("\n\nTailoring test: Greek character with 3 combining marks");
+ ruleLen = u_strlen(rule);
+ coll = ucol_openRules(rule, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status);
+ if (U_FAILURE(status)) {
+ log_err("ucol_openRules failed with %s\n", u_errorName(status));
+ return;
+ }
+ sLen = u_strlen(tailorData[0]);
+ for (j=1; j<6; j++) {
+ tLen = u_strlen(tailorData[j]);
+ if ( !ucol_equal(coll, tailorData[0], sLen, tailorData[j], tLen)) {
+ log_err("\n \\u1FA2 not equals to data[%d]:%s\n", j, tailorData[j]);
+ }
+ }
+ /* Test getSortKey. */
+ tLen = u_strlen(tailorData[0]);
+ kLen=ucol_getSortKey(coll, tailorData[0], tLen, expColl, 100);
+ for (j=0; j<6; j++) {
+ tLen = u_strlen(tailorData[j]);
+ rLen = ucol_getSortKey(coll, tailorData[j], tLen, resColl, 100);
+ if ( kLen!=rLen || uprv_memcmp(expColl, resColl, rLen*sizeof(uint8_t))!=0 ) {
+ log_err("\n Data[%d] :%s \tlen: %d key: ", j, tailorData[j], tLen);
+ for(i = 0; i<rLen; i++) {
+ log_err(" %02X", resColl[i]);
+ }
+ }
+ }
+ ucol_close(coll);
+
+ log_verbose("\n\nTailoring test for s with caron:");
+ ruleLen = u_strlen(rule2);
+ coll = ucol_openRules(rule2, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status);
+ tLen = u_strlen(tailorData2[0]);
+ kLen=ucol_getSortKey(coll, tailorData2[0], tLen, expColl, 100);
+ for (j=1; j<3; j++) {
+ tLen = u_strlen(tailorData2[j]);
+ rLen = ucol_getSortKey(coll, tailorData2[j], tLen, resColl, 100);
+ if ( kLen!=rLen || uprv_memcmp(expColl, resColl, rLen*sizeof(uint8_t))!=0 ) {
+ log_err("\n After tailoring Data[%d] :%s \tlen: %d key: ", j, tailorData[j], tLen);
+ for(i = 0; i<rLen; i++) {
+ log_err(" %02X", resColl[i]);
+ }
+ }
+ }
+ ucol_close(coll);
+
+ log_verbose("\n\nTailoring test for &z< ae with circumflex:");
+ ruleLen = u_strlen(rule3);
+ coll = ucol_openRules(rule3, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status);
+ tLen = u_strlen(tailorData3[3]);
+ kLen=ucol_getSortKey(coll, tailorData3[3], tLen, expColl, 100);
+ for (j=4; j<6; j++) {
+ tLen = u_strlen(tailorData3[j]);
+ rLen = ucol_getSortKey(coll, tailorData3[j], tLen, resColl, 100);
+
+ if ( kLen!=rLen || uprv_memcmp(expColl, resColl, rLen*sizeof(uint8_t))!=0 ) {
+ log_err("\n After tailoring Data[%d] :%s \tlen: %d key: ", j, tailorData[j], tLen);
+ for(i = 0; i<rLen; i++) {
+ log_err(" %02X", resColl[i]);
+ }
+ }
+
+ log_verbose("\n Test Data[%d] :%s \tlen: %d key: ", j, tailorData[j], tLen);
+ for(i = 0; i<rLen; i++) {
+ log_verbose(" %02X", resColl[i]);
+ }
+ }
+ ucol_close(coll);
+}
+
+static void
+TestTailor6179(void)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ int32_t i;
+ UCollator *coll =NULL;
+ uint8_t resColl[100];
+ int32_t rLen, tLen, ruleLen;
+ /* &[last primary ignorable]<< a &[first primary ignorable]<<b */
+ UChar rule1[256]={0x26,0x5B,0x6C,0x61,0x73,0x74,0x20,0x70,0x72,0x69,0x6D,0x61,0x72,0x79,
+ 0x20,0x69,0x67,0x6E,0x6F,0x72,0x61,0x62,0x6C,0x65,0x5D,0x3C,0x3C,0x20,0x61,0x20,
+ 0x26,0x5B,0x66,0x69,0x72,0x73,0x74,0x20,0x70,0x72,0x69,0x6D,0x61,0x72,0x79,0x20,
+ 0x69,0x67,0x6E,0x6F,0x72,0x61,0x62,0x6C,0x65,0x5D,0x3C,0x3C,0x62,0x20, 0};
+ /* &[last secondary ignorable]<<< a &[first secondary ignorable]<<<b */
+ UChar rule2[256]={0x26,0x5B,0x6C,0x61,0x73,0x74,0x20,0x73,0x65,0x63,0x6F,0x6E,0x64,0x61,
+ 0x72,0x79,0x20,0x69,0x67,0x6E,0x6F,0x72,0x61,0x62,0x6C,0x65,0x5D,0x3C,0x3C,0x3C,
+ 0x61,0x20,0x26,0x5B,0x66,0x69,0x72,0x73,0x74,0x20,0x73,0x65,0x63,0x6F,0x6E,
+ 0x64,0x61,0x72,0x79,0x20,0x69,0x67,0x6E,0x6F,0x72,0x61,0x62,0x6C,0x65,0x5D,0x3C,
+ 0x3C,0x3C,0x20,0x62,0};
+
+ UChar tData1[][20]={
+ {0x61, 0},
+ {0x62, 0},
+ { 0xFDD0,0x009E, 0}
+ };
+ UChar tData2[][20]={
+ {0x61, 0},
+ {0x62, 0},
+ { 0xFDD0,0x009E, 0}
+ };
+
+ /* UCA5.1, the value may increase in later version. */
+ uint8_t firstPrimaryIgnCE[6]={1, 87, 1, 5, 1, 0};
+ uint8_t lastPrimaryIgnCE[6]={1, 0xE7, 0xB9, 1, 5, 0};
+ uint8_t firstSecondaryIgnCE[6]={1, 1, 0x3f, 0x03, 0};
+ uint8_t lastSecondaryIgnCE[6]={1, 1, 0x05, 0};
+
+ /* Test [Last Primary ignorable] */
+
+ log_verbose("\n\nTailoring test: &[last primary ignorable]<<a &[first primary ignorable]<<b ");
+ ruleLen = u_strlen(rule1);
+ coll = ucol_openRules(rule1, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status);
+ if (U_FAILURE(status)) {
+ log_err("Tailoring test: &[last primary ignorable] failed!");
+ return;
+ }
+ tLen = u_strlen(tData1[0]);
+ rLen = ucol_getSortKey(coll, tData1[0], tLen, resColl, 100);
+ if (uprv_memcmp(resColl, lastPrimaryIgnCE, uprv_min(rLen,6)) < 0) {
+ log_err("\n Data[%d] :%s \tlen: %d key: ", 0, tData1[0], rLen);
+ for(i = 0; i<rLen; i++) {
+ log_err(" %02X", resColl[i]);
+ }
+ }
+ tLen = u_strlen(tData1[1]);
+ rLen = ucol_getSortKey(coll, tData1[1], tLen, resColl, 100);
+ if (uprv_memcmp(resColl, firstPrimaryIgnCE, uprv_min(rLen, 6)) < 0) {
+ log_err("\n Data[%d] :%s \tlen: %d key: ", 1, tData1[1], rLen);
+ for(i = 0; i<rLen; i++) {
+ log_err(" %02X", resColl[i]);
+ }
+ }
+ ucol_close(coll);
+
+
+ /* Test [Last Secondary ignorable] */
+ log_verbose("\n\nTailoring test: &[last secondary ignorable]<<<a &[first secondary ignorable]<<<b ");
+ ruleLen = u_strlen(rule1);
+ coll = ucol_openRules(rule2, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status);
+ if (U_FAILURE(status)) {
+ log_err("Tailoring test: &[last primary ignorable] failed!");
+ return;
+ }
+ tLen = u_strlen(tData2[0]);
+ rLen = ucol_getSortKey(coll, tData2[0], tLen, resColl, 100);
+ log_verbose("\n Data[%d] :%s \tlen: %d key: ", 0, tData2[0], rLen);
+ for(i = 0; i<rLen; i++) {
+ log_verbose(" %02X", resColl[i]);
+ }
+ if (uprv_memcmp(resColl, lastSecondaryIgnCE, uprv_min(rLen, 3)) < 0) {
+ log_err("\n Data[%d] :%s \tlen: %d key: ", 0, tData2[0], rLen);
+ for(i = 0; i<rLen; i++) {
+ log_err(" %02X", resColl[i]);
+ }
+ }
+ tLen = u_strlen(tData2[1]);
+ rLen = ucol_getSortKey(coll, tData2[1], tLen, resColl, 100);
+ log_verbose("\n Data[%d] :%s \tlen: %d key: ", 1, tData2[1], rLen);
+ for(i = 0; i<rLen; i++) {
+ log_verbose(" %02X", resColl[i]);
+ }
+ if (uprv_memcmp(resColl, firstSecondaryIgnCE, uprv_min(rLen, 4)) < 0) {
+ log_err("\n Data[%d] :%s \tlen: %d key: ", 1, tData2[1], rLen);
+ for(i = 0; i<rLen; i++) {
+ log_err(" %02X", resColl[i]);
+ }
+ }
+ ucol_close(coll);
+}
+
+static void
+TestUCAPrecontext(void)
+{
+ UErrorCode status = U_ZERO_ERROR;
+ int32_t i, j;
+ UCollator *coll =NULL;
+ uint8_t resColl[100], prevColl[100];
+ int32_t rLen, tLen, ruleLen;
+ UChar rule1[256]= {0x26, 0xb7, 0x3c, 0x61, 0}; /* & middle-dot < a */
+ UChar rule2[256]= {0x26, 0x4C, 0xb7, 0x3c, 0x3c, 0x61, 0};
+ /* & l middle-dot << a a is an expansion. */
+
+ UChar tData1[][20]={
+ { 0xb7, 0}, /* standalone middle dot(0xb7) */
+ { 0x387, 0}, /* standalone middle dot(0x387) */
+ { 0x61, 0}, /* a */
+ { 0x6C, 0}, /* l */
+ { 0x4C, 0x0332, 0}, /* l with [first primary ignorable] */
+ { 0x6C, 0xb7, 0}, /* l with middle dot(0xb7) */
+ { 0x6C, 0x387, 0}, /* l with middle dot(0x387) */
+ { 0x4C, 0xb7, 0}, /* L with middle dot(0xb7) */
+ { 0x4C, 0x387, 0}, /* L with middle dot(0x387) */
+ { 0x6C, 0x61, 0x387, 0}, /* la with middle dot(0x387) */
+ { 0x4C, 0x61, 0xb7, 0}, /* La with middle dot(0xb7) */
+ };
+
+ log_verbose("\n\nEN collation:");
+ coll = ucol_open("en", &status);
+ if (U_FAILURE(status)) {
+ log_err("Tailoring test: &z <<a|- failed!");
+ return;
+ }
+ for (j=0; j<11; j++) {
+ tLen = u_strlen(tData1[j]);
+ rLen = ucol_getSortKey(coll, tData1[j], tLen, resColl, 100);
+ if ((j>0) && (strcmp((char *)resColl, (char *)prevColl)<0)) {
+ log_err("\n Expecting greater key than previous test case: Data[%d] :%s.",
+ j, tData1[j]);
+ }
+ log_verbose("\n Data[%d] :%s \tlen: %d key: ", j, tData1[j], rLen);
+ for(i = 0; i<rLen; i++) {
+ log_verbose(" %02X", resColl[i]);
+ }
+ uprv_memcpy(prevColl, resColl, sizeof(uint8_t)*(rLen+1));
+ }
+ ucol_close(coll);
+
+
+ log_verbose("\n\nJA collation:");
+ coll = ucol_open("ja", &status);
+ if (U_FAILURE(status)) {
+ log_err("Tailoring test: &z <<a|- failed!");
+ return;
+ }
+ for (j=0; j<11; j++) {
+ tLen = u_strlen(tData1[j]);
+ rLen = ucol_getSortKey(coll, tData1[j], tLen, resColl, 100);
+ if ((j>0) && (strcmp((char *)resColl, (char *)prevColl)<0)) {
+ log_err("\n Expecting greater key than previous test case: Data[%d] :%s.",
+ j, tData1[j]);
+ }
+ log_verbose("\n Data[%d] :%s \tlen: %d key: ", j, tData1[j], rLen);
+ for(i = 0; i<rLen; i++) {
+ log_verbose(" %02X", resColl[i]);
+ }
+ uprv_memcpy(prevColl, resColl, sizeof(uint8_t)*(rLen+1));
+ }
+ ucol_close(coll);
+
+
+ log_verbose("\n\nTailoring test: & middle dot < a ");
+ ruleLen = u_strlen(rule1);
+ coll = ucol_openRules(rule1, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status);
+ if (U_FAILURE(status)) {
+ log_err("Tailoring test: & middle dot < a failed!");
+ return;
+ }
+ for (j=0; j<11; j++) {
+ tLen = u_strlen(tData1[j]);
+ rLen = ucol_getSortKey(coll, tData1[j], tLen, resColl, 100);
+ if ((j>0) && (strcmp((char *)resColl, (char *)prevColl)<0)) {
+ log_err("\n Expecting greater key than previous test case: Data[%d] :%s.",
+ j, tData1[j]);
+ }
+ log_verbose("\n Data[%d] :%s \tlen: %d key: ", j, tData1[j], rLen);
+ for(i = 0; i<rLen; i++) {
+ log_verbose(" %02X", resColl[i]);
+ }
+ uprv_memcpy(prevColl, resColl, sizeof(uint8_t)*(rLen+1));
+ }
+ ucol_close(coll);
+
+
+ log_verbose("\n\nTailoring test: & l middle-dot << a ");
+ ruleLen = u_strlen(rule2);
+ coll = ucol_openRules(rule2, ruleLen, UCOL_OFF, UCOL_TERTIARY, NULL,&status);
+ if (U_FAILURE(status)) {
+ log_err("Tailoring test: & l middle-dot << a failed!");
+ return;
+ }
+ for (j=0; j<11; j++) {
+ tLen = u_strlen(tData1[j]);
+ rLen = ucol_getSortKey(coll, tData1[j], tLen, resColl, 100);
+ if ((j>0) && (j!=3) && (strcmp((char *)resColl, (char *)prevColl)<0)) {
+ log_err("\n Expecting greater key than previous test case: Data[%d] :%s.",
+ j, tData1[j]);
+ }
+ if ((j==3)&&(strcmp((char *)resColl, (char *)prevColl)>0)) {
+ log_err("\n Expecting smaller key than previous test case: Data[%d] :%s.",
+ j, tData1[j]);
+ }
+ log_verbose("\n Data[%d] :%s \tlen: %d key: ", j, tData1[j], rLen);
+ for(i = 0; i<rLen; i++) {
+ log_verbose(" %02X", resColl[i]);
+ }
+ uprv_memcpy(prevColl, resColl, sizeof(uint8_t)*(rLen+1));
+ }
+ ucol_close(coll);
+}
+
+static void
+TestOutOfBuffer5468(void)
+{
+ static const char *test = "\\u4e00";
+ UChar ustr[256];
+ int32_t ustr_length = u_unescape(test, ustr, 256);
+ unsigned char shortKeyBuf[1];
+ int32_t sortkey_length;
+ UErrorCode status = U_ZERO_ERROR;
+ static UCollator *coll = NULL;
+
+ coll = ucol_open("root", &status);
+ if(U_FAILURE(status)) {
+ log_err("Couldn't open UCA\n");
+ return;
+ }
+ ucol_setStrength(coll, UCOL_PRIMARY);
+ ucol_setAttribute(coll, UCOL_STRENGTH, UCOL_PRIMARY, &status);
+ ucol_setAttribute(coll, UCOL_NORMALIZATION_MODE, UCOL_ON, &status);
+ if (U_FAILURE(status)) {
+ log_err("Failed setting atributes\n");
+ return;
+ }
+
+ sortkey_length = ucol_getSortKey(coll, ustr, ustr_length, shortKeyBuf, sizeof(shortKeyBuf));
+ if (sortkey_length != 4) {
+ log_err("expecting length of sortKey is 4 got:%d ", sortkey_length);
+ }
+ log_verbose("length of sortKey is %d", sortkey_length);
+ ucol_close(coll);
+}
+
+#define TSKC_DATA_SIZE 5
+#define TSKC_BUF_SIZE 50
+static void
+TestSortKeyConsistency(void)
+{
+ UErrorCode icuRC = U_ZERO_ERROR;
+ UCollator* ucol;
+ UChar data[] = { 0xFFFD, 0x0006, 0x0006, 0x0006, 0xFFFD};
+
+ uint8_t bufFull[TSKC_DATA_SIZE][TSKC_BUF_SIZE];
+ uint8_t bufPart[TSKC_DATA_SIZE][TSKC_BUF_SIZE];
+ int32_t i, j, i2;
+
+ ucol = ucol_openFromShortString("LEN_S4", FALSE, NULL, &icuRC);
+ if (U_FAILURE(icuRC))
+ {
+ log_err("ucol_openFromShortString failed\n");
+ return;
+ }
+
+ for (i = 0; i < TSKC_DATA_SIZE; i++)
+ {
+ UCharIterator uiter;
+ uint32_t state[2] = { 0, 0 };
+ int32_t dataLen = i+1;
+ for (j=0; j<TSKC_BUF_SIZE; j++)
+ bufFull[i][j] = bufPart[i][j] = 0;
+
+ /* Full sort key */
+ ucol_getSortKey(ucol, data, dataLen, bufFull[i], TSKC_BUF_SIZE);
+
+ /* Partial sort key */
+ uiter_setString(&uiter, data, dataLen);
+ ucol_nextSortKeyPart(ucol, &uiter, state, bufPart[i], TSKC_BUF_SIZE, &icuRC);
+ if (U_FAILURE(icuRC))
+ {
+ log_err("ucol_nextSortKeyPart failed\n");
+ ucol_close(ucol);
+ return;
+ }
+
+ for (i2=0; i2<i; i2++)
+ {
+ UBool fullMatch = TRUE;
+ UBool partMatch = TRUE;
+ for (j=0; j<TSKC_BUF_SIZE; j++)
+ {
+ fullMatch = fullMatch && (bufFull[i][j] != bufFull[i2][j]);
+ partMatch = partMatch && (bufPart[i][j] != bufPart[i2][j]);
+ }
+ if (fullMatch != partMatch) {
+ log_err(fullMatch ? "full key was consistent, but partial key changed\n"
+ : "partial key was consistent, but full key changed\n");
+ ucol_close(ucol);
+ return;
+ }
+ }
+ }
+
+ /*=============================================*/
+ ucol_close(ucol);
+}
+
+/* ticket: 6101 */
+static void TestCroatianSortKey(void) {
+ const char* collString = "LHR_AN_CX_EX_FX_HX_NX_S3";
+ UErrorCode status = U_ZERO_ERROR;
+ UCollator *ucol;
+ UCharIterator iter;
+
+ static const UChar text[] = { 0x0044, 0xD81A };
+
+ size_t length = sizeof(text)/sizeof(*text);
+
+ uint8_t textSortKey[32];
+ size_t lenSortKey = 32;
+ size_t actualSortKeyLen;
+ uint32_t uStateInfo[2] = { 0, 0 };
+
+ ucol = ucol_openFromShortString(collString, FALSE, NULL, &status);
+ if (U_FAILURE(status)) {
+ log_err("ucol_openFromShortString error in Craotian test.\n");
+ return;
+ }
+
+ uiter_setString(&iter, text, length);
+
+ actualSortKeyLen = ucol_nextSortKeyPart(
+ ucol, &iter, (uint32_t*)uStateInfo,
+ textSortKey, lenSortKey, &status
+ );
+
+ if (actualSortKeyLen == lenSortKey) {
+ log_err("ucol_nextSortKeyPart did not give correct result in Croatian test.\n");
+ }
+
+ ucol_close(ucol);
+}
+
+/* ticket: 6140 */
+/* This test ensures that codepoints such as 0x3099 are flagged correctly by the collator since
+ * they are both Hiragana and Katakana
+ */
+#define SORTKEYLEN 50
+static void TestHiragana(void) {
+ UErrorCode status = U_ZERO_ERROR;
+ UCollator* ucol;
+ UCollationResult strcollresult;
+ UChar data1[] = { 0x3058, 0x30B8 }; /* Hiragana and Katakana letter Zi */
+ UChar data2[] = { 0x3057, 0x3099, 0x30B7, 0x3099 };
+ int32_t data1Len = sizeof(data1)/sizeof(*data1);
+ int32_t data2Len = sizeof(data2)/sizeof(*data2);
+ int32_t i, j;
+ uint8_t sortKey1[SORTKEYLEN];
+ uint8_t sortKey2[SORTKEYLEN];
+
+ UCharIterator uiter1;
+ UCharIterator uiter2;
+ uint32_t state1[2] = { 0, 0 };
+ uint32_t state2[2] = { 0, 0 };
+ int32_t keySize1;
+ int32_t keySize2;
+
+ ucol = ucol_openFromShortString("LJA_AN_CX_EX_FX_HO_NX_S4", FALSE, NULL,
+ &status);
+ if (U_FAILURE(status)) {
+ log_err("Error status: %s; Unable to open collator from short string.", u_errorName(status));
+ return;
+ }
+
+ /* Start of full sort keys */
+ /* Full sort key1 */
+ keySize1 = ucol_getSortKey(ucol, data1, data1Len, sortKey1, SORTKEYLEN);
+ /* Full sort key2 */
+ keySize2 = ucol_getSortKey(ucol, data2, data2Len, sortKey2, SORTKEYLEN);
+ if (keySize1 == keySize2) {
+ for (i = 0; i < keySize1; i++) {
+ if (sortKey1[i] != sortKey2[i]) {
+ log_err("Full sort keys are different. Should be equal.");
+ }
+ }
+ } else {
+ log_err("Full sort keys sizes doesn't match: %d %d", keySize1, keySize2);
+ }
+ /* End of full sort keys */
+
+ /* Start of partial sort keys */
+ /* Partial sort key1 */
+ uiter_setString(&uiter1, data1, data1Len);
+ keySize1 = ucol_nextSortKeyPart(ucol, &uiter1, state1, sortKey1, SORTKEYLEN, &status);
+ /* Partial sort key2 */
+ uiter_setString(&uiter2, data2, data2Len);
+ keySize2 = ucol_nextSortKeyPart(ucol, &uiter2, state2, sortKey2, SORTKEYLEN, &status);
+ if (U_SUCCESS(status) && keySize1 == keySize2) {
+ for (j = 0; j < keySize1; j++) {
+ if (sortKey1[j] != sortKey2[j]) {
+ log_err("Partial sort keys are different. Should be equal");
+ }
+ }
+ } else {
+ log_err("Error Status: %s or Partial sort keys sizes doesn't match: %d %d", u_errorName(status), keySize1, keySize2);
+ }
+ /* End of partial sort keys */
+
+ /* Start of strcoll */
+ /* Use ucol_strcoll() to determine ordering */
+ strcollresult = ucol_strcoll(ucol, data1, data1Len, data2, data2Len);
+ if (strcollresult != UCOL_EQUAL) {
+ log_err("Result from ucol_strcoll() should be UCOL_EQUAL.");
+ }
+
+ ucol_close(ucol);
+}