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

Unified Diff: third_party/cld/encodings/compact_enc_det/compact_enc_det_fuzz_test.cc

Issue 1956183002: CL for perf tryjob on linux (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
Index: third_party/cld/encodings/compact_enc_det/compact_enc_det_fuzz_test.cc
diff --git a/third_party/cld/encodings/compact_enc_det/compact_enc_det_fuzz_test.cc b/third_party/cld/encodings/compact_enc_det/compact_enc_det_fuzz_test.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b214f9818c069807e4838dc77fbb83e32684be26
--- /dev/null
+++ b/third_party/cld/encodings/compact_enc_det/compact_enc_det_fuzz_test.cc
@@ -0,0 +1,36 @@
+#include <stddef.h>
+#include <stdlib.h>
+#include <memory>
+
+#include "i18n/encodings/compact_enc_det/compact_enc_det.h"
+#include "i18n/encodings/public/encodings.h"
+#include "i18n/languages/public/languages.h"
+#include "testing/base/public/gunit.h"
+
+namespace {
+
+class CompactEncDetFuzzTest : public testing::Test {};
+
+TEST_F(CompactEncDetFuzzTest, TestRandom) {
+ for (size_t i = 0; i < 16384; ++i) {
+ unsigned int seed = i;
+ size_t length = static_cast<size_t>(rand_r(&seed)) % 1024;
+ std::unique_ptr<char[]> text(new char[length]);
+
+ for (size_t j = 0; j < length; ++j) text[j] = rand_r(&seed);
+
+ int bytes_consumed;
+ bool is_reliable;
+
+ CompactEncDet::DetectEncoding(text.get(), length, nullptr, // URL hint
+ nullptr, // HTTP hint
+ nullptr, // Meta hint
+ UNKNOWN_ENCODING,
+ i18n::languages::UNKNOWN_LANGUAGE,
+ CompactEncDet::WEB_CORPUS,
+ false, // Include 7-bit encodings?
+ &bytes_consumed, &is_reliable);
+ }
+}
+
+} // namespace

Powered by Google App Engine
This is Rietveld 408576698