OLD | NEW |
(Empty) | |
| 1 #include <stddef.h> |
| 2 #include <stdlib.h> |
| 3 #include <memory> |
| 4 |
| 5 #include "i18n/encodings/compact_enc_det/compact_enc_det.h" |
| 6 #include "i18n/encodings/public/encodings.h" |
| 7 #include "i18n/languages/public/languages.h" |
| 8 #include "testing/base/public/gunit.h" |
| 9 |
| 10 namespace { |
| 11 |
| 12 class CompactEncDetFuzzTest : public testing::Test {}; |
| 13 |
| 14 TEST_F(CompactEncDetFuzzTest, TestRandom) { |
| 15 for (size_t i = 0; i < 16384; ++i) { |
| 16 unsigned int seed = i; |
| 17 size_t length = static_cast<size_t>(rand_r(&seed)) % 1024; |
| 18 std::unique_ptr<char[]> text(new char[length]); |
| 19 |
| 20 for (size_t j = 0; j < length; ++j) text[j] = rand_r(&seed); |
| 21 |
| 22 int bytes_consumed; |
| 23 bool is_reliable; |
| 24 |
| 25 CompactEncDet::DetectEncoding(text.get(), length, nullptr, // URL hint |
| 26 nullptr, // HTTP hint |
| 27 nullptr, // Meta hint |
| 28 UNKNOWN_ENCODING, |
| 29 i18n::languages::UNKNOWN_LANGUAGE, |
| 30 CompactEncDet::WEB_CORPUS, |
| 31 false, // Include 7-bit encodings? |
| 32 &bytes_consumed, &is_reliable); |
| 33 } |
| 34 } |
| 35 |
| 36 } // namespace |
OLD | NEW |