Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(352)

Side by Side Diff: fuzzers/icu_break_iterator_fuzzer.cc

Issue 1995823002: [libfuzzer] moving icu fuzzers to //third_party/icu, additional fuzzers. (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/icu.git@master
Patch Set: rebase Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fuzzers/fuzzer_utils.h ('k') | fuzzers/icu_number_format_fuzzer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2
3 #include <stddef.h>
4 #include <stdint.h>
5 #include <memory>
6 #include "third_party/icu/fuzzers/fuzzer_utils.h"
7 #include "third_party/icu/source/common/unicode/brkiter.h"
8
9 IcuEnvironment* env = new IcuEnvironment();
10
11 // Entry point for LibFuzzer.
12 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
13 UErrorCode status = U_ZERO_ERROR;
14 icu::UnicodeString str(reinterpret_cast<const char*>(data), size);
15
16 auto rng = CreateRng(data, size);
17 const icu::Locale& locale = GetRandomLocale(&rng);
18
19 std::unique_ptr<icu::BreakIterator> bi;
20
21 switch (rng() % 5) {
22 case 0:
23 bi.reset(icu::BreakIterator::createWordInstance(locale, status));
24 break;
25 case 1:
26 bi.reset(icu::BreakIterator::createLineInstance(locale, status));
27 break;
28 case 2:
29 bi.reset(icu::BreakIterator::createCharacterInstance(locale, status));
30 break;
31 case 3:
32 bi.reset(icu::BreakIterator::createSentenceInstance(locale, status));
33 break;
34 case 4:
35 bi.reset(icu::BreakIterator::createTitleInstance(locale, status));
36 break;
37 }
38 if (U_FAILURE(status)) return 0;
39
40 for (int32_t p = bi->first(); p != icu::BreakIterator::DONE; p = bi->next())
41 if (U_FAILURE(status)) return 0;
42
43 return 0;
44 }
45
OLDNEW
« no previous file with comments | « fuzzers/fuzzer_utils.h ('k') | fuzzers/icu_number_format_fuzzer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698