mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-08 06:53:45 +00:00
ICU-5024 Add test case for diactric matching bug.
X-SVN-Rev: 22839
This commit is contained in:
parent
55aa34b9ef
commit
f6ec12ee6c
4 changed files with 71 additions and 0 deletions
|
@ -485,6 +485,10 @@ static const SearchData CONTRACTIONCANONICAL[] = {
|
|||
{NULL, NULL, NULL, UCOL_TERTIARY, NULL, {-1}, {0}}
|
||||
};
|
||||
|
||||
static const SearchData DIACTRICMATCH[] = {
|
||||
{"\\u0061\\u0061\\u00E1", "\\u0061\\u00E1", NULL, UCOL_SECONDARY, NULL, {1, -1}, {2}}
|
||||
};
|
||||
|
||||
#endif /* #if !UCONFIG_NO_COLLATION */
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1537,6 +1537,38 @@ static void TestIgnorable(void)
|
|||
ucol_close(collator);
|
||||
}
|
||||
|
||||
static void TestDiactricMatch(void)
|
||||
{
|
||||
UChar pattern[128];
|
||||
UChar text[128];
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UStringSearch *strsrch;
|
||||
uint32_t count = 0;
|
||||
|
||||
memset(pattern, 0, 128*sizeof(UChar));
|
||||
memset(text, 0, 128*sizeof(UChar));
|
||||
|
||||
strsrch = usearch_open(pattern, 1, text, 1, uloc_getDefault(), NULL,
|
||||
&status);
|
||||
if (U_FAILURE(status)) {
|
||||
log_err("Error opening string search %s\n", u_errorName(status));
|
||||
}
|
||||
|
||||
ucol_setStrength(usearch_getCollator(strsrch), DIACTRICMATCH[count].strength);
|
||||
|
||||
while (DIACTRICMATCH[count].text != NULL) {
|
||||
u_unescape(DIACTRICMATCH[count].text, text, 128);
|
||||
u_unescape(DIACTRICMATCH[count].pattern, pattern, 128);
|
||||
usearch_setText(strsrch, text, -1, &status);
|
||||
usearch_setPattern(strsrch, pattern, -1, &status);
|
||||
if (!assertEqualWithUStringSearch(strsrch, DIACTRICMATCH[count])) {
|
||||
log_err("Error at test number %d\n", count);
|
||||
}
|
||||
count ++;
|
||||
}
|
||||
usearch_close(strsrch);
|
||||
}
|
||||
|
||||
static void TestCanonical(void)
|
||||
{
|
||||
int count = 0;
|
||||
|
@ -2191,6 +2223,7 @@ void addSearchTest(TestNode** root)
|
|||
"tscoll/usrchtst/TestContractionCanonical");
|
||||
addTest(root, &TestEnd, "tscoll/usrchtst/TestEnd");
|
||||
addTest(root, &TestNumeric, "tscoll/usrchtst/TestNumeric");
|
||||
addTest(root, &TestDiactricMatch, "tscoll/usrchtst/TestDiactricMatch");
|
||||
}
|
||||
|
||||
#endif /* #if !UCONFIG_NO_COLLATION */
|
||||
|
|
|
@ -154,6 +154,7 @@ void StringSearchTest::runIndexedTest(int32_t index, UBool exec,
|
|||
CASE(33, TestUClassID)
|
||||
CASE(34, TestSubclass)
|
||||
CASE(35, TestCoverage)
|
||||
CASE(36, TestDiactricMatch)
|
||||
default: name = ""; break;
|
||||
}
|
||||
}
|
||||
|
@ -1544,6 +1545,38 @@ void StringSearchTest::TestIgnorable()
|
|||
delete strsrch;
|
||||
delete collator;
|
||||
}
|
||||
|
||||
void StringSearchTest::TestDiactricMatch()
|
||||
{
|
||||
UChar temp[128];
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
int count = 0;
|
||||
|
||||
UnicodeString pattern("pattern");
|
||||
UnicodeString text("text");
|
||||
StringSearch *strsrch = new StringSearch(pattern, text, Locale::getDefault(), NULL,
|
||||
status);
|
||||
if (U_FAILURE(status)) {
|
||||
errln("Error opening string search %s", u_errorName(status));
|
||||
return;
|
||||
}
|
||||
|
||||
strsrch->getCollator()->setStrength(getECollationStrength(DIACTRICMATCH[count].strength));
|
||||
|
||||
while (DIACTRICMATCH[count].text != NULL) {
|
||||
u_unescape(DIACTRICMATCH[count].text, temp, 128);
|
||||
text.setTo(temp, u_strlen(temp));
|
||||
u_unescape(DIACTRICMATCH[count].pattern, temp, 128);
|
||||
pattern.setTo(temp, u_strlen(temp));
|
||||
strsrch->setText(text, status);
|
||||
strsrch->setPattern(pattern, status);
|
||||
if (!assertEqualWithStringSearch(strsrch, &DIACTRICMATCH[count])) {
|
||||
errln("Error at test number %d", count);
|
||||
}
|
||||
count ++;
|
||||
}
|
||||
delete strsrch;
|
||||
}
|
||||
|
||||
void StringSearchTest::TestCanonical()
|
||||
{
|
||||
|
|
|
@ -88,6 +88,7 @@ private:
|
|||
void TestUClassID();
|
||||
void TestSubclass();
|
||||
void TestCoverage();
|
||||
void TestDiactricMatch();
|
||||
};
|
||||
|
||||
#endif /* #if !UCONFIG_NO_COLLATION */
|
||||
|
|
Loading…
Add table
Reference in a new issue