1 /********************************************************************
3 * Copyright (c) 1997-2012, International Business Machines Corporation and
4 * others. All Rights Reserved.
5 ********************************************************************/
6 /********************************************************************************
10 * Modification History:
12 * Madhu Katragadda Creation
13 *********************************************************************************
17 #include "unicode/utypes.h"
19 #if !UCONFIG_NO_COLLATION
23 #include "unicode/ucol.h"
24 #include "unicode/ustring.h"
27 void addCollTest(TestNode
** root
);
29 void addCollTest(TestNode
** root
)
32 addCurrencyCollTest(root
);
33 #if !UCONFIG_NO_NORMALIZATION
36 addGermanCollTest(root
);
37 addSpanishCollTest(root
);
38 addFrenchCollTest(root
);
39 addKannaCollTest(root
);
40 addTurkishCollTest(root
);
41 addEnglishCollTest(root
);
42 addFinnishCollTest(root
);
44 /* WEIVTODO: return tests here */
45 addRuleBasedCollTest(root
);
46 addCollIterTest(root
);
48 addMiscCollTest(root
);
49 #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO
56 /*Internal functions used*/
57 static char* dumpSk(uint8_t *sourceKey
, char *sk
) {
58 uint32_t kLen
= (uint32_t)strlen((const char *)sourceKey
);
63 for(i
= 0; i
<kLen
; i
++) {
64 sprintf(sk
+2*i
, "%02X", sourceKey
[i
]);
69 static const char *getCompareResult(UCollationResult result
)
71 if (result
== UCOL_LESS
)
75 else if (result
== UCOL_EQUAL
)
79 else if (result
== UCOL_GREATER
)
83 return "invalid UCollationResult?";
86 void reportCResult( const UChar source
[], const UChar target
[],
87 uint8_t *sourceKey
, uint8_t *targetKey
,
88 UCollationResult compareResult
,
89 UCollationResult keyResult
,
90 UCollationResult incResult
,
91 UCollationResult expectedResult
)
93 if (expectedResult
< -1 || expectedResult
> 1)
95 log_err("***** invalid call to reportCResult ****\n");
99 if (compareResult
!= expectedResult
)
101 log_err("Compare(%s , %s) returned: %s expected: %s\n", aescstrdup(source
,-1), aescstrdup(target
,-1),
102 getCompareResult(compareResult
), getCompareResult(expectedResult
) );
105 if (incResult
!= expectedResult
)
107 log_err("incCompare(%s , %s) returned: %s expected: %s\n", aescstrdup(source
,-1), aescstrdup(target
,-1),
108 getCompareResult(incResult
), getCompareResult(expectedResult
) );
111 if (keyResult
!= expectedResult
)
113 log_err("KeyCompare(%s , %s) returned: %s expected: %s\n", aescstrdup(source
,-1), aescstrdup(target
,-1),
114 getCompareResult(keyResult
), getCompareResult(expectedResult
) );
117 if (keyResult
!= compareResult
)
119 log_err("difference between sortkey and compare result for (%s , %s) Keys: %s compare %s\n", aescstrdup(source
,-1), aescstrdup(target
,-1),
120 getCompareResult(keyResult
), getCompareResult(compareResult
));
123 if(keyResult
!= expectedResult
|| keyResult
!= compareResult
)
126 log_verbose("SortKey1: %s\n", dumpSk(sourceKey
, sk
));
127 log_verbose("SortKey2: %s\n", dumpSk(targetKey
, sk
));
131 #endif /* #if !UCONFIG_NO_COLLATION */