2000-01-15 02:00:06 +00:00
|
|
|
/********************************************************************
|
2002-04-02 02:55:31 +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 CJAPTST.C
|
|
|
|
*
|
|
|
|
* Modification History:
|
2002-04-02 02:55:31 +00:00
|
|
|
* Name Description
|
1999-10-18 22:48:32 +00:00
|
|
|
* Madhu Katragadda Ported for C API
|
2001-03-08 20:15:53 +00:00
|
|
|
* synwee Added TestBase, TestPlainDakutenHandakuten,
|
|
|
|
* TestSmallLarge, TestKatakanaHiragana,
|
|
|
|
* TestChooonKigoo
|
2000-08-14 23:35:57 +00:00
|
|
|
*********************************************************************************/
|
1999-08-16 21:50:52 +00:00
|
|
|
/**
|
|
|
|
* CollationKannaTest 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 "cjaptst.h"
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/ustring.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
#include "string.h"
|
1999-12-22 22:57:04 +00:00
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
static UCollator *myCollation;
|
|
|
|
const static UChar testSourceCases[][MAX_TOKEN_LEN] = {
|
|
|
|
{0xff9E, 0x0000},
|
|
|
|
{0x3042, 0x0000},
|
|
|
|
{0x30A2, 0x0000},
|
|
|
|
{0x3042, 0x3042, 0x0000},
|
|
|
|
{0x30A2, 0x30FC, 0x0000},
|
2001-03-16 02:14:37 +00:00
|
|
|
{0x30A2, 0x30FC, 0x30C8, 0x0000} /* 6 */
|
1999-08-16 21:50:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const static UChar testTargetCases[][MAX_TOKEN_LEN] = {
|
|
|
|
{0xFF9F, 0x0000},
|
|
|
|
{0x30A2, 0x0000},
|
|
|
|
{0x3042, 0x3042, 0x0000},
|
|
|
|
{0x30A2, 0x30FC, 0x0000},
|
|
|
|
{0x30A2, 0x30FC, 0x30C8, 0x0000},
|
2001-03-16 02:14:37 +00:00
|
|
|
{0x3042, 0x3042, 0x3068, 0x0000} /* 6 */
|
1999-08-16 21:50:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const static UCollationResult results[] = {
|
|
|
|
UCOL_LESS,
|
2001-10-31 23:59:35 +00:00
|
|
|
UCOL_EQUAL, /*UCOL_LESS*/ /* Katakanas and Hiraganas are equal on tertiary level(ICU 2.0)*/
|
2001-03-15 02:35:49 +00:00
|
|
|
UCOL_LESS,
|
2001-10-31 23:59:35 +00:00
|
|
|
UCOL_GREATER, /*UCOL_LESS*/ /* Prolonged sound mark sorts BEFORE equivalent vowel (ICU 2.0)*/
|
1999-08-16 21:50:52 +00:00
|
|
|
UCOL_LESS,
|
2001-10-31 23:59:35 +00:00
|
|
|
UCOL_LESS, /*UCOL_GREATER*/ /* Prolonged sound mark sorts BEFORE equivalent vowel (ICU 2.0)*//* 6 */
|
1999-08-16 21:50:52 +00:00
|
|
|
};
|
|
|
|
|
2001-03-08 20:15:53 +00:00
|
|
|
const static UChar testBaseCases[][MAX_TOKEN_LEN] = {
|
|
|
|
{0x30AB, 0x0000},
|
|
|
|
{0x30AB, 0x30AD, 0x0000},
|
|
|
|
{0x30AD, 0x0000},
|
|
|
|
{0x30AD, 0x30AD, 0x0000}
|
|
|
|
};
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2001-03-08 20:15:53 +00:00
|
|
|
const static UChar testPlainDakutenHandakutenCases[][MAX_TOKEN_LEN] = {
|
|
|
|
{0x30CF, 0x30AB, 0x0000},
|
2001-03-09 01:08:50 +00:00
|
|
|
{0x30D0, 0x30AB, 0x0000},
|
2001-03-08 20:15:53 +00:00
|
|
|
{0x30CF, 0x30AD, 0x0000},
|
|
|
|
{0x30D0, 0x30AD, 0x0000}
|
|
|
|
};
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2001-03-08 20:15:53 +00:00
|
|
|
const static UChar testSmallLargeCases[][MAX_TOKEN_LEN] = {
|
|
|
|
{0x30C3, 0x30CF, 0x0000},
|
|
|
|
{0x30C4, 0x30CF, 0x0000},
|
|
|
|
{0x30C3, 0x30D0, 0x0000},
|
|
|
|
{0x30C4, 0x30D0, 0x0000}
|
|
|
|
};
|
|
|
|
|
|
|
|
const static UChar testKatakanaHiraganaCases[][MAX_TOKEN_LEN] = {
|
|
|
|
{0x3042, 0x30C3, 0x0000},
|
2001-03-15 02:35:49 +00:00
|
|
|
{0x30A2, 0x30C3, 0x0000},
|
|
|
|
{0x3042, 0x30C4, 0x0000},
|
|
|
|
{0x30A2, 0x30C4, 0x0000}
|
2001-03-08 20:15:53 +00:00
|
|
|
};
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2001-03-08 20:15:53 +00:00
|
|
|
const static UChar testChooonKigooCases[][MAX_TOKEN_LEN] = {
|
2001-03-15 02:35:49 +00:00
|
|
|
/*0*/ {0x30AB, 0x30FC, 0x3042, 0x0000},
|
|
|
|
/*1*/ {0x30AB, 0x30FC, 0x30A2, 0x0000},
|
|
|
|
/*2*/ {0x30AB, 0x30A4, 0x3042, 0x0000},
|
|
|
|
/*3*/ {0x30AB, 0x30A4, 0x30A2, 0x0000},
|
2001-10-31 23:59:35 +00:00
|
|
|
/*6*/ {0x30AD, 0x30FC, 0x3042, 0x0000}, /* Prolonged sound mark sorts BEFORE equivalent vowel (ICU 2.0)*/
|
|
|
|
/*7*/ {0x30AD, 0x30FC, 0x30A2, 0x0000}, /* Prolonged sound mark sorts BEFORE equivalent vowel (ICU 2.0)*/
|
2001-03-15 02:35:49 +00:00
|
|
|
/*4*/ {0x30AD, 0x30A4, 0x3042, 0x0000},
|
|
|
|
/*5*/ {0x30AD, 0x30A4, 0x30A2, 0x0000},
|
2001-03-08 20:15:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
void addKannaCollTest(TestNode** root)
|
|
|
|
{
|
2002-04-02 02:55:31 +00:00
|
|
|
addTest(root, &TestTertiary, "tscoll/cjacoll/TestTertiary");
|
|
|
|
addTest(root, &TestBase, "tscoll/cjacoll/TestBase");
|
|
|
|
addTest(root, &TestPlainDakutenHandakuten, "tscoll/cjacoll/TestPlainDakutenHandakuten");
|
|
|
|
addTest(root, &TestSmallLarge, "tscoll/cjacoll/TestSmallLarge");
|
|
|
|
addTest(root, &TestKatakanaHiragana, "tscoll/cjacoll/TestKatakanaHiragana");
|
|
|
|
addTest(root, &TestChooonKigoo, "tscoll/cjacoll/TestChooonKigoo");
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
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("ja_JP", &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));
|
2002-04-02 02:55:31 +00:00
|
|
|
return;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
log_verbose("Testing Kanna(Japan) Collation with Tertiary strength\n");
|
|
|
|
ucol_setStrength(myCollation, UCOL_TERTIARY);
|
2001-03-08 20:15:53 +00:00
|
|
|
ucol_setAttribute(myCollation, UCOL_CASE_LEVEL, UCOL_ON, &status);
|
2001-03-16 02:14:37 +00:00
|
|
|
for (i = 0; i < 6 ; i++)
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
|
|
|
doTest(myCollation, testSourceCases[i], testTargetCases[i], results[i]);
|
|
|
|
}
|
|
|
|
ucol_close(myCollation);
|
|
|
|
}
|
|
|
|
|
2001-03-08 20:15:53 +00:00
|
|
|
/* Testing base letters */
|
|
|
|
static void TestBase()
|
|
|
|
{
|
2002-04-02 02:55:31 +00:00
|
|
|
int32_t i;
|
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
|
|
|
myCollation = ucol_open("ja_JP", &status);
|
|
|
|
if (U_FAILURE(status))
|
|
|
|
{
|
|
|
|
log_err("ERROR: in creation of rule based collator: %s\n",
|
2001-03-08 20:15:53 +00:00
|
|
|
myErrorName(status));
|
2002-04-02 02:55:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
log_verbose("Testing Japanese Base Characters Collation\n");
|
|
|
|
ucol_setStrength(myCollation, UCOL_PRIMARY);
|
|
|
|
for (i = 0; i < 3 ; i++)
|
|
|
|
doTest(myCollation, testBaseCases[i], testBaseCases[i + 1], UCOL_LESS);
|
|
|
|
|
|
|
|
ucol_close(myCollation);
|
2001-03-08 20:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Testing plain, Daku-ten, Handaku-ten letters */
|
|
|
|
static void TestPlainDakutenHandakuten(void)
|
|
|
|
{
|
2002-04-02 02:55:31 +00:00
|
|
|
int32_t i;
|
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
|
|
|
myCollation = ucol_open("ja_JP", &status);
|
|
|
|
if (U_FAILURE(status))
|
|
|
|
{
|
|
|
|
log_err("ERROR: in creation of rule based collator: %s\n",
|
2001-03-08 20:15:53 +00:00
|
|
|
myErrorName(status));
|
2002-04-02 02:55:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
log_verbose("Testing plain, Daku-ten, Handaku-ten letters Japanese Characters Collation\n");
|
|
|
|
ucol_setStrength(myCollation, UCOL_SECONDARY);
|
|
|
|
for (i = 0; i < 3 ; i++)
|
|
|
|
doTest(myCollation, testPlainDakutenHandakutenCases[i],
|
|
|
|
testPlainDakutenHandakutenCases[i + 1], UCOL_LESS);
|
|
|
|
|
|
|
|
ucol_close(myCollation);
|
2001-03-08 20:15:53 +00:00
|
|
|
}
|
|
|
|
|
2002-04-02 02:55:31 +00:00
|
|
|
/*
|
2001-03-08 20:15:53 +00:00
|
|
|
* Test Small, Large letters
|
|
|
|
*/
|
|
|
|
static void TestSmallLarge(void)
|
|
|
|
{
|
2002-04-02 02:55:31 +00:00
|
|
|
int32_t i;
|
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
|
|
|
myCollation = ucol_open("ja_JP", &status);
|
|
|
|
if (U_FAILURE(status))
|
|
|
|
{
|
|
|
|
log_err("ERROR: in creation of rule based collator: %s\n",
|
2001-03-08 20:15:53 +00:00
|
|
|
myErrorName(status));
|
2002-04-02 02:55:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
log_verbose("Testing Japanese Small and Large Characters Collation\n");
|
|
|
|
ucol_setStrength(myCollation, UCOL_TERTIARY);
|
|
|
|
ucol_setAttribute(myCollation, UCOL_CASE_LEVEL, UCOL_ON, &status);
|
|
|
|
for (i = 0; i < 3 ; i++)
|
|
|
|
doTest(myCollation, testSmallLargeCases[i], testSmallLargeCases[i + 1],
|
|
|
|
UCOL_LESS);
|
|
|
|
|
|
|
|
ucol_close(myCollation);
|
2001-03-08 20:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test Katakana, Hiragana letters
|
|
|
|
*/
|
|
|
|
static void TestKatakanaHiragana(void)
|
|
|
|
{
|
2002-04-02 02:55:31 +00:00
|
|
|
int32_t i;
|
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
|
|
|
myCollation = ucol_open("ja_JP", &status);
|
|
|
|
if (U_FAILURE(status))
|
|
|
|
{
|
|
|
|
log_err("ERROR: in creation of rule based collator: %s\n",
|
2001-03-08 20:15:53 +00:00
|
|
|
myErrorName(status));
|
2002-04-02 02:55:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
log_verbose("Testing Japanese Katakana, Hiragana Characters Collation\n");
|
|
|
|
ucol_setStrength(myCollation, UCOL_QUATERNARY);
|
|
|
|
ucol_setAttribute(myCollation, UCOL_CASE_LEVEL, UCOL_ON, &status);
|
|
|
|
for (i = 0; i < 3 ; i++) {
|
|
|
|
doTest(myCollation, testKatakanaHiraganaCases[i],
|
|
|
|
testKatakanaHiraganaCases[i + 1], UCOL_LESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
ucol_close(myCollation);
|
2001-03-08 20:15:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Test Choo-on kigoo
|
|
|
|
*/
|
|
|
|
static void TestChooonKigoo(void)
|
|
|
|
{
|
2002-04-02 02:55:31 +00:00
|
|
|
int32_t i;
|
|
|
|
UErrorCode status = U_ZERO_ERROR;
|
|
|
|
myCollation = ucol_open("ja_JP", &status);
|
|
|
|
if (U_FAILURE(status))
|
|
|
|
{
|
|
|
|
log_err("ERROR: in creation of rule based collator: %s\n",
|
2001-03-08 20:15:53 +00:00
|
|
|
myErrorName(status));
|
2002-04-02 02:55:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
log_verbose("Testing Japanese Choo-on Kigoo Characters Collation\n");
|
|
|
|
ucol_setAttribute(myCollation, UCOL_CASE_LEVEL, UCOL_ON, &status);
|
|
|
|
for (i = 0; i < 7 ; i++) {
|
|
|
|
doTest(myCollation, testChooonKigooCases[i], testChooonKigooCases[i + 1],
|
|
|
|
UCOL_LESS);
|
|
|
|
}
|
|
|
|
|
|
|
|
ucol_close(myCollation);
|
2001-03-08 20:15:53 +00:00
|
|
|
}
|