2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
|
|
|
* COPYRIGHT:
|
2001-03-21 19:46:49 +00:00
|
|
|
* Copyright (c) 1997-2001, 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 CTURTST.C
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
* Name Description
|
1999-10-18 22:48:32 +00:00
|
|
|
* Madhu Katragadda Ported for C API
|
2000-08-14 23:35:57 +00:00
|
|
|
*********************************************************************************/
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* CollationTurkishTest is a third level test class. This tests the locale
|
|
|
|
* specific primary, secondary and tertiary rules. For example, the ignorable
|
|
|
|
* character '-' in string "black-bird". The en_US locale uses the default
|
|
|
|
* collation rules as its sorting sequence.
|
|
|
|
*/
|
|
|
|
|
2000-08-28 21:43:03 +00:00
|
|
|
#include <stdlib.h>
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
#include "unicode/ucol.h"
|
|
|
|
#include "unicode/uloc.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "cintltst.h"
|
|
|
|
#include "ccolltst.h"
|
2001-03-06 03:42:35 +00:00
|
|
|
#include "callcoll.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "cturtst.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/ustring.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "string.h"
|
|
|
|
|
|
|
|
static UCollator *myCollation;
|
|
|
|
const static UChar testSourceCases[][MAX_TOKEN_LEN] = {
|
|
|
|
{0x0073/*'s'*/, 0x0327, 0x0000},
|
|
|
|
{0x0076/*'v'*/, 0x00E4, 0x0074/*'t'*/, 0x0000},
|
|
|
|
{0x006f/*'o'*/, 0x006c/*'l'*/, 0x0064/*'d'*/, 0x0000},
|
|
|
|
{0x00FC, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064/*'d'*/, 0x0000},
|
|
|
|
{0x0068/*'h'*/, 0x011E, 0x0061/*'a'*/, 0x006c/*'l'*/, 0x0074/*'t'*/, 0x0000},
|
|
|
|
{0x0073/*'s'*/, 0x0074/*'t'*/, 0x0072/*'r'*/, 0x0065/*'e'*/, 0x0073/*'s'*/, 0x015E, 0x0000},
|
|
|
|
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0131, 0x0064/*'d'*/, 0x0000},
|
|
|
|
{0x0069/*'i'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
|
|
|
|
{0x00FC, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
|
|
|
|
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0131, 0x0064 /*d'*/, 0x0000},
|
|
|
|
{0x0069/*'i'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
|
|
|
|
};
|
|
|
|
|
|
|
|
const static UChar testTargetCases[][MAX_TOKEN_LEN] = {
|
|
|
|
{0x0075/*'u'*/, 0x0308, 0x0000},
|
|
|
|
{0x0076/*'v'*/, 0x0062/*'b'*/, 0x0074/*'t'*/, 0x0000},
|
|
|
|
{0x00D6, 0x0061/*'a'*/, 0x0079/*'y'*/, 0x0000},
|
|
|
|
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
|
|
|
|
{0x0068/*'h'*/, 0x0061/*'a'*/, 0x006c/*'l'*/, 0x0074/*'t'*/, 0x0000},
|
|
|
|
{0x015E, 0x0074/*'t'*/, 0x0072/*'r'*/, 0x0065/*'e'*/, 0x015E, 0x0073/*'s'*/, 0x0000},
|
|
|
|
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
|
|
|
|
{0x0049/*'I'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
|
|
|
|
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
|
|
|
|
{0x0076/*'v'*/, 0x006f/*'o'*/, 0x0069/*'i'*/, 0x0064 /*d'*/, 0x0000},
|
|
|
|
{0x0049/*'I'*/, 0x0064/*'d'*/, 0x0065/*'e'*/, 0x0061/*'a'*/, 0x0000},
|
|
|
|
};
|
|
|
|
|
|
|
|
const static UCollationResult results[] = {
|
|
|
|
UCOL_LESS,
|
|
|
|
UCOL_LESS,
|
|
|
|
UCOL_LESS,
|
|
|
|
UCOL_LESS,
|
|
|
|
UCOL_GREATER,
|
|
|
|
UCOL_LESS,
|
|
|
|
UCOL_LESS,
|
|
|
|
UCOL_GREATER,
|
|
|
|
/* test priamry > 8 */
|
|
|
|
UCOL_LESS,
|
2001-05-31 22:14:18 +00:00
|
|
|
UCOL_LESS, /*Turkish translator made a primary differnce between dotted and dotless I */
|
|
|
|
UCOL_GREATER
|
1999-08-16 21:50:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void addTurkishCollTest(TestNode** root)
|
|
|
|
{
|
|
|
|
|
|
|
|
addTest(root, &TestPrimary, "tscoll/cturtst/TestPrimary");
|
|
|
|
addTest(root, &TestTertiary, "tscoll/cturtst/TestTertiary");
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2000-11-21 04:05:39 +00:00
|
|
|
|
|
|
|
static void TestTertiary( )
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
int32_t i;
|
|
|
|
|
1999-10-07 00:07:53 +00:00
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
myCollation = ucol_open("tr", &status);
|
1999-10-18 22:48:32 +00:00
|
|
|
if(U_FAILURE(status)){
|
1999-08-16 21:50:52 +00:00
|
|
|
log_err("ERROR: in creation of rule based collator: %s\n", myErrorName(status));
|
2001-02-17 17:54:25 +00:00
|
|
|
return;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
log_verbose("Testing Turkish Collation with Tertiary strength\n");
|
|
|
|
ucol_setStrength(myCollation, UCOL_TERTIARY);
|
|
|
|
for (i = 0; i < 8 ; i++)
|
|
|
|
{
|
|
|
|
doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
|
|
|
|
}
|
|
|
|
ucol_close(myCollation);
|
|
|
|
}
|
|
|
|
|
2000-11-21 04:05:39 +00:00
|
|
|
static void TestPrimary()
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
|
|
|
|
|
|
|
int32_t i;
|
|
|
|
|
1999-10-07 00:07:53 +00:00
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
myCollation = ucol_open("tr", &status);
|
1999-10-18 22:48:32 +00:00
|
|
|
if(U_FAILURE(status)){
|
1999-08-16 21:50:52 +00:00
|
|
|
log_err("ERROR: in creation of rule based collator: %s\n", myErrorName(status));
|
2001-02-17 17:54:25 +00:00
|
|
|
return;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
log_verbose("Testing Turkish Collation with Primary strength\n");
|
|
|
|
ucol_setStrength(myCollation, UCOL_PRIMARY);
|
|
|
|
for (i = 8; i < 11; i++)
|
|
|
|
{
|
|
|
|
doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
|
|
|
|
}
|
|
|
|
ucol_close(myCollation);
|
|
|
|
}
|
|
|
|
|