1 // Copyright (C) 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /********************************************************************
5 * Copyright (c) 1997-2012, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ********************************************************************/
8 /********************************************************************************
12 * Modification History:
14 * Madhu Katragadda Creation
15 *********************************************************************************
19 #include "unicode/utypes.h"
21 #if !UCONFIG_NO_COLLATION
25 #include "unicode/ucol.h"
26 #include "unicode/ustring.h"
29 void addCollTest(TestNode** root);
31 void addCollTest(TestNode** root)
34 addCurrencyCollTest(root);
35 #if !UCONFIG_NO_NORMALIZATION
38 addGermanCollTest(root);
39 addSpanishCollTest(root);
40 addFrenchCollTest(root);
41 addKannaCollTest(root);
42 addTurkishCollTest(root);
43 addEnglishCollTest(root);
44 addFinnishCollTest(root);
46 /* WEIVTODO: return tests here */
47 addRuleBasedCollTest(root);
48 addCollIterTest(root);
50 addMiscCollTest(root);
51 #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO
58 /*Internal functions used*/
59 static char* dumpSk(uint8_t *sourceKey, char *sk) {
60 uint32_t kLen = (uint32_t)strlen((const char *)sourceKey);
65 for(i = 0; i<kLen; i++) {
66 sprintf(sk+2*i, "%02X", sourceKey[i]);
71 static const char *getCompareResult(UCollationResult result)
73 if (result == UCOL_LESS)
77 else if (result == UCOL_EQUAL)
81 else if (result == UCOL_GREATER)
85 return "invalid UCollationResult?";
88 void reportCResult( const UChar source[], const UChar target[],
89 uint8_t *sourceKey, uint8_t *targetKey,
90 UCollationResult compareResult,
91 UCollationResult keyResult,
92 UCollationResult incResult,
93 UCollationResult expectedResult )
95 if (expectedResult < -1 || expectedResult > 1)
97 log_err("***** invalid call to reportCResult ****\n");
101 if (compareResult != expectedResult)
103 log_err("Compare(%s , %s) returned: %s expected: %s\n", aescstrdup(source,-1), aescstrdup(target,-1),
104 getCompareResult(compareResult), getCompareResult(expectedResult) );
107 if (incResult != expectedResult)
109 log_err("incCompare(%s , %s) returned: %s expected: %s\n", aescstrdup(source,-1), aescstrdup(target,-1),
110 getCompareResult(incResult), getCompareResult(expectedResult) );
113 if (keyResult != expectedResult)
115 log_err("KeyCompare(%s , %s) returned: %s expected: %s\n", aescstrdup(source,-1), aescstrdup(target,-1),
116 getCompareResult(keyResult), getCompareResult(expectedResult) );
119 if (keyResult != compareResult)
121 log_err("difference between sortkey and compare result for (%s , %s) Keys: %s compare %s\n", aescstrdup(source,-1), aescstrdup(target,-1),
122 getCompareResult(keyResult), getCompareResult(compareResult));
125 if(keyResult != expectedResult || keyResult != compareResult)
128 log_verbose("SortKey1: %s\n", dumpSk(sourceKey, sk));
129 log_verbose("SortKey2: %s\n", dumpSk(targetKey, sk));
133 #endif /* #if !UCONFIG_NO_COLLATION */