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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fuzzers/fuzzer_utils.h ('k') | fuzzers/icu_number_format_fuzzer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fuzzers/icu_break_iterator_fuzzer.cc
diff --git a/fuzzers/icu_break_iterator_fuzzer.cc b/fuzzers/icu_break_iterator_fuzzer.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b9bc8e5b4341cd0815b24dda53d8eb72cb20c0e4
--- /dev/null
+++ b/fuzzers/icu_break_iterator_fuzzer.cc
@@ -0,0 +1,45 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+
+#include <stddef.h>
+#include <stdint.h>
+#include <memory>
+#include "third_party/icu/fuzzers/fuzzer_utils.h"
+#include "third_party/icu/source/common/unicode/brkiter.h"
+
+IcuEnvironment* env = new IcuEnvironment();
+
+// Entry point for LibFuzzer.
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
+ UErrorCode status = U_ZERO_ERROR;
+ icu::UnicodeString str(reinterpret_cast<const char*>(data), size);
+
+ auto rng = CreateRng(data, size);
+ const icu::Locale& locale = GetRandomLocale(&rng);
+
+ std::unique_ptr<icu::BreakIterator> bi;
+
+ switch (rng() % 5) {
+ case 0:
+ bi.reset(icu::BreakIterator::createWordInstance(locale, status));
+ break;
+ case 1:
+ bi.reset(icu::BreakIterator::createLineInstance(locale, status));
+ break;
+ case 2:
+ bi.reset(icu::BreakIterator::createCharacterInstance(locale, status));
+ break;
+ case 3:
+ bi.reset(icu::BreakIterator::createSentenceInstance(locale, status));
+ break;
+ case 4:
+ bi.reset(icu::BreakIterator::createTitleInstance(locale, status));
+ break;
+ }
+ if (U_FAILURE(status)) return 0;
+
+ for (int32_t p = bi->first(); p != icu::BreakIterator::DONE; p = bi->next())
+ if (U_FAILURE(status)) return 0;
+
+ return 0;
+}
+
« 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