1 /********************************************************************
3 * Copyright (c) 1997-2009, 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
);
34 addGermanCollTest(root
);
35 addSpanishCollTest(root
);
36 addFrenchCollTest(root
);
37 addKannaCollTest(root
);
38 addTurkishCollTest(root
);
39 addEnglishCollTest(root
);
40 addFinnishCollTest(root
);
42 /* WEIVTODO: return tests here */
43 addRuleBasedCollTest(root
);
44 addCollIterTest(root
);
46 addMiscCollTest(root
);
47 #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO
54 /*Internal functions used*/
55 static char* dumpSk(uint8_t *sourceKey
, char *sk
) {
56 uint32_t kLen
= (uint32_t)strlen((const char *)sourceKey
);
61 for(i
= 0; i
<kLen
; i
++) {
62 sprintf(sk
+2*i
, "%02X", sourceKey
[i
]);
67 static const char *getCompareResult(UCollationResult result
)
69 if (result
== UCOL_LESS
)
73 else if (result
== UCOL_EQUAL
)
77 else if (result
== UCOL_GREATER
)
81 return "invalid UCollationResult?";
84 void reportCResult( const UChar source
[], const UChar target
[],
85 uint8_t *sourceKey
, uint8_t *targetKey
,
86 UCollationResult compareResult
,
87 UCollationResult keyResult
,
88 UCollationResult incResult
,
89 UCollationResult expectedResult
)
91 if (expectedResult
< -1 || expectedResult
> 1)
93 log_err("***** invalid call to reportCResult ****\n");
97 if (compareResult
!= expectedResult
)
99 log_err("Compare(%s , %s) returned: %s expected: %s\n", aescstrdup(source
,-1), aescstrdup(target
,-1),
100 getCompareResult(compareResult
), getCompareResult(expectedResult
) );
103 if (incResult
!= expectedResult
)
105 log_err("incCompare(%s , %s) returned: %s expected: %s\n", aescstrdup(source
,-1), aescstrdup(target
,-1),
106 getCompareResult(incResult
), getCompareResult(expectedResult
) );
109 if (keyResult
!= expectedResult
)
111 log_err("KeyCompare(%s , %s) returned: %s expected: %s\n", aescstrdup(source
,-1), aescstrdup(target
,-1),
112 getCompareResult(keyResult
), getCompareResult(expectedResult
) );
115 if (keyResult
!= compareResult
)
117 log_err("difference between sortkey and compare result for (%s , %s) Keys: %s compare %s\n", aescstrdup(source
,-1), aescstrdup(target
,-1),
118 getCompareResult(keyResult
), getCompareResult(compareResult
));
121 if(keyResult
!= expectedResult
|| keyResult
!= compareResult
)
124 log_verbose("SortKey1: %s\n", dumpSk(sourceKey
, sk
));
125 log_verbose("SortKey2: %s\n", dumpSk(targetKey
, sk
));
129 #endif /* #if !UCONFIG_NO_COLLATION */