]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/fuzzer/unicode_string_codepage_create_fuzzer.cpp
1 // © 2019 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
12 #include "fuzzer_utils.h"
13 #include "unicode/unistr.h"
15 // Taken from third_party/icu/source/data/mappings/convrtrs.txt file.
16 static const std::array
<const char*, 45> kConverters
= {
51 "x-mac-cyrillic-html",
56 "ISO_2022,locale=ja,version=0",
66 IcuEnvironment
* env
= new IcuEnvironment();
68 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data
, size_t size
) {
73 // First byte is used for random converter selection.
78 std::unique_ptr
<char[]> fuzzbuff(new char[size
]);
79 std::memcpy(fuzzbuff
.get(), data
, size
);
81 icu::UnicodeString
str(fuzzbuff
.get(), size
,
82 kConverters
[rnd
% kConverters
.size()]);