]> git.saurik.com Git - apple/icu.git/blob - icuSources/test/fuzzer/collator_rulebased_fuzzer.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / test / fuzzer / collator_rulebased_fuzzer.cpp
1 // © 2019 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3
4 #include <cstring>
5
6 #include "fuzzer_utils.h"
7 #include "unicode/coll.h"
8 #include "unicode/localpointer.h"
9 #include "unicode/locid.h"
10 #include "unicode/tblcoll.h"
11
12 IcuEnvironment* env = new IcuEnvironment();
13
14 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
15 UErrorCode status = U_ZERO_ERROR;
16
17 size_t unistr_size = size/2;
18 std::unique_ptr<char16_t[]> fuzzbuff(new char16_t[unistr_size]);
19 std::memcpy(fuzzbuff.get(), data, unistr_size * 2);
20 icu::UnicodeString fuzzstr(false, fuzzbuff.get(), unistr_size);
21
22 icu::LocalPointer<icu::RuleBasedCollator> col1(
23 new icu::RuleBasedCollator(fuzzstr, status));
24
25 return 0;
26 }