ICU-22716 Extend Collator fuzzing

This commit is contained in:
Frank Tang 2024-09-06 18:12:45 -07:00 committed by Frank Yung-Fong Tang
parent 3a74fcf052
commit 1c3bf0bf82

View file

@ -7,6 +7,7 @@
#include "unicode/coll.h"
#include "unicode/localpointer.h"
#include "unicode/locid.h"
#include "unicode/sortkey.h"
#include "unicode/tblcoll.h"
IcuEnvironment* env = new IcuEnvironment();
@ -27,5 +28,20 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
icu::LocalPointer<icu::RuleBasedCollator> col1(
new icu::RuleBasedCollator(fuzzstr, status));
if (U_SUCCESS(status)) {
col1->getVariableTop(status);
status = U_ZERO_ERROR;
icu::CollationKey key;
col1->getCollationKey(fuzzstr, key, status);
status = U_ZERO_ERROR;
icu::LocalPointer<icu::UnicodeSet> tailoredSet(col1->getTailoredSet(status));
status = U_ZERO_ERROR;
col1->getLocale(ULOC_ACTUAL_LOCALE, status);
status = U_ZERO_ERROR;
col1->getLocale(ULOC_VALID_LOCALE, status);
col1->getMaxVariable();
col1->getStrength();
col1->getSortKey(fuzzstr, nullptr, 0);
}
return 0;
}