Skip to content

Commit

Permalink
ICU22511 Add additional unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang committed Jul 1, 2024
1 parent 36ad138 commit 6e5fc50
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
30 changes: 25 additions & 5 deletions icu4c/source/test/intltest/collationtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,6 @@ void CollationTest::TestWoHang22511() {
char16_t str1[] = {
0x0000, 0x0100, 0x032a, 0x01e0, 0xd804, 0xdd00, 0x031c,
};

int32_t num_locales = 0;
const icu::Locale* locales = icu::Locale::getAvailableLocales(num_locales);
for (int32_t i = 0; i < num_locales; i++) {
Expand All @@ -1901,12 +1900,33 @@ void CollationTest::TestWoHang22511() {
}
coll->setStrength(icu::Collator::IDENTICAL);

coll->compare(str1,
sizeof(str1)/sizeof(char16_t),
str1+1,
(sizeof(str1)/sizeof(char16_t))-1,
coll->compare(str1, sizeof(str1)/sizeof(char16_t),
str1+1, (sizeof(str1)/sizeof(char16_t))-1,
errorCode);
}

char16_t str2[] = {
0x0355, 0x01d8, 0xd804, 0x036c, 0x0355, 0x01d8, 0xd804, 0xdf6c, 0x0335, 0x4d34, 0x0300, 0xd800, 0xd855,
};
char16_t str3[] = {
0x0355, 0x01d8, 0xd804, 0x036c, 0x0355, 0x01da, 0xd804, 0xdf6c, 0x0335, 0x2753, 0x55d8, 0x2253, 0xff0c,
};

for (int32_t i = 0; i < num_locales; i++) {
errorCode.reset();
icu::Locale l = locales[i];
LocalPointer<Collator> coll(Collator::createInstance(l, errorCode));
if(errorCode.isFailure()) {
logln("cannot built the Collator");
continue;
}
coll->setStrength(icu::Collator::IDENTICAL);
coll->compare(str2, sizeof(str2)/sizeof(char16_t),
str3, sizeof(str3)/sizeof(char16_t),
errorCode);
}


}
void CollationTest::TestHang22414() {
IcuTestErrorCode errorCode(*this, "TestHang22414");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1774,5 +1774,18 @@ public void TestWoHang22511() {
} catch (IllegalStateException e) {
}
}

String str3 = "\u0355\u01d8\ud804\u036c\u0355\u01d8\ud804\udf6c\u0335\u4d34\u0300\ud800\ud855";
String str4 = "\u0355\u01d8\ud804\u036c\u0355\u01da\ud804\udf6c\u0335\u2753\u55d8\u2253\uff0c";

for (Locale l : Collator.getAvailableLocales()) {
Collator col = Collator.getInstance(l);
col.setStrength(Collator.IDENTICAL);
try {
col.compare(str3, str4);
} catch (IllegalStateException e) {
}
}

}
}

0 comments on commit 6e5fc50

Please sign in to comment.