2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
2012-10-18 19:51:28 +00:00
|
|
|
* Copyright (c) 1997-2012, International Business Machines Corporation and
|
2000-01-15 02:00:06 +00:00
|
|
|
* others. All Rights Reserved.
|
|
|
|
********************************************************************/
|
|
|
|
/********************************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*
|
|
|
|
* File CCOLLTST.C
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
* Name Description
|
|
|
|
* Madhu Katragadda Creation
|
|
|
|
*********************************************************************************
|
|
|
|
*/
|
2001-04-23 23:39:58 +00:00
|
|
|
#include <stdio.h>
|
2002-09-20 17:54:45 +00:00
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_COLLATION
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "cintltst.h"
|
|
|
|
#include "ccolltst.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/ucol.h"
|
|
|
|
#include "unicode/ustring.h"
|
2001-06-01 00:34:42 +00:00
|
|
|
#include "cmemory.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2001-06-01 00:34:42 +00:00
|
|
|
void addCollTest(TestNode** root);
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
void addCollTest(TestNode** root)
|
|
|
|
{
|
|
|
|
addCollAPITest(root);
|
2005-06-16 18:44:30 +00:00
|
|
|
addCurrencyCollTest(root);
|
2012-10-18 19:51:28 +00:00
|
|
|
#if !UCONFIG_NO_NORMALIZATION
|
1999-08-16 21:50:52 +00:00
|
|
|
addNormTest(root);
|
2012-10-18 19:51:28 +00:00
|
|
|
#endif
|
1999-08-16 21:50:52 +00:00
|
|
|
addGermanCollTest(root);
|
|
|
|
addSpanishCollTest(root);
|
|
|
|
addFrenchCollTest(root);
|
|
|
|
addKannaCollTest(root);
|
|
|
|
addTurkishCollTest(root);
|
|
|
|
addEnglishCollTest(root);
|
2001-04-03 00:32:05 +00:00
|
|
|
addFinnishCollTest(root);
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2001-01-26 00:12:23 +00:00
|
|
|
/* WEIVTODO: return tests here */
|
2001-02-27 07:28:58 +00:00
|
|
|
addRuleBasedCollTest(root);
|
|
|
|
addCollIterTest(root);
|
|
|
|
addAllCollTest(root);
|
2001-03-03 02:03:05 +00:00
|
|
|
addMiscCollTest(root);
|
2009-08-04 21:09:17 +00:00
|
|
|
#if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILE_IO
|
2001-08-25 02:06:37 +00:00
|
|
|
addSearchTest(root);
|
2008-06-20 22:53:25 +00:00
|
|
|
#endif
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*Internal functions used*/
|
2001-04-23 23:39:58 +00:00
|
|
|
static char* dumpSk(uint8_t *sourceKey, char *sk) {
|
2001-04-30 20:57:12 +00:00
|
|
|
uint32_t kLen = (uint32_t)strlen((const char *)sourceKey);
|
|
|
|
uint32_t i = 0;
|
|
|
|
|
|
|
|
*sk = 0;
|
|
|
|
|
|
|
|
for(i = 0; i<kLen; i++) {
|
|
|
|
sprintf(sk+2*i, "%02X", sourceKey[i]);
|
|
|
|
}
|
|
|
|
return sk;
|
2001-04-23 23:39:58 +00:00
|
|
|
}
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2008-02-16 22:58:32 +00:00
|
|
|
static const char *getCompareResult(UCollationResult result)
|
|
|
|
{
|
|
|
|
if (result == UCOL_LESS)
|
|
|
|
{
|
|
|
|
return "LESS";
|
|
|
|
}
|
|
|
|
else if (result == UCOL_EQUAL)
|
|
|
|
{
|
|
|
|
return "EQUAL";
|
|
|
|
}
|
|
|
|
else if (result == UCOL_GREATER)
|
|
|
|
{
|
|
|
|
return "GREATER";
|
|
|
|
}
|
|
|
|
return "invalid UCollationResult?";
|
|
|
|
}
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
void reportCResult( const UChar source[], const UChar target[],
|
|
|
|
uint8_t *sourceKey, uint8_t *targetKey,
|
|
|
|
UCollationResult compareResult,
|
|
|
|
UCollationResult keyResult,
|
2000-12-12 21:35:26 +00:00
|
|
|
UCollationResult incResult,
|
1999-08-16 21:50:52 +00:00
|
|
|
UCollationResult expectedResult )
|
|
|
|
{
|
|
|
|
if (expectedResult < -1 || expectedResult > 1)
|
|
|
|
{
|
|
|
|
log_err("***** invalid call to reportCResult ****\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (compareResult != expectedResult)
|
|
|
|
{
|
2002-04-02 03:36:54 +00:00
|
|
|
log_err("Compare(%s , %s) returned: %s expected: %s\n", aescstrdup(source,-1), aescstrdup(target,-1),
|
2008-02-16 22:58:32 +00:00
|
|
|
getCompareResult(compareResult), getCompareResult(expectedResult) );
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2000-12-12 21:35:26 +00:00
|
|
|
if (incResult != expectedResult)
|
|
|
|
{
|
2002-04-02 03:36:54 +00:00
|
|
|
log_err("incCompare(%s , %s) returned: %s expected: %s\n", aescstrdup(source,-1), aescstrdup(target,-1),
|
2008-02-16 22:58:32 +00:00
|
|
|
getCompareResult(incResult), getCompareResult(expectedResult) );
|
2000-12-12 21:35:26 +00:00
|
|
|
}
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
if (keyResult != expectedResult)
|
|
|
|
{
|
2002-04-02 03:36:54 +00:00
|
|
|
log_err("KeyCompare(%s , %s) returned: %s expected: %s\n", aescstrdup(source,-1), aescstrdup(target,-1),
|
2008-02-16 22:58:32 +00:00
|
|
|
getCompareResult(keyResult), getCompareResult(expectedResult) );
|
2000-12-05 01:04:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (keyResult != compareResult)
|
|
|
|
{
|
2002-04-02 03:36:54 +00:00
|
|
|
log_err("difference between sortkey and compare result for (%s , %s) Keys: %s compare %s\n", aescstrdup(source,-1), aescstrdup(target,-1),
|
2008-02-16 22:58:32 +00:00
|
|
|
getCompareResult(keyResult), getCompareResult(compareResult));
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
2001-04-23 23:39:58 +00:00
|
|
|
|
|
|
|
if(keyResult != expectedResult || keyResult != compareResult)
|
|
|
|
{
|
2008-02-16 22:58:32 +00:00
|
|
|
char sk[10000];
|
|
|
|
log_verbose("SortKey1: %s\n", dumpSk(sourceKey, sk));
|
|
|
|
log_verbose("SortKey2: %s\n", dumpSk(targetKey, sk));
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-09-20 17:54:45 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_COLLATION */
|