1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "base/at_exit.h"
6 #include "base/i18n/icu_util.h"
10 TestCase() { CHECK(base::i18n::InitializeICU()); }
12 // used by ICU integration.
13 base::AtExitManager at_exit_manager;
16 TestCase* test_case = new TestCase();
18 // Entry point for LibFuzzer.
19 extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
23 base::StringPiece string_piece_input(reinterpret_cast<const char*>(data),
25 GURL url_from_string_piece(string_piece_input);
27 // Test for StringPiece16 if size is even.
29 base::StringPiece16 string_piece_input16(
30 reinterpret_cast<const base::char16*>(data), size / 2);
32 GURL url_from_string_piece16(string_piece_input16);
35 // Resolve relative url tests.
36 size_t size_t_bytes = sizeof(size_t);
37 if (size < size_t_bytes + 1) {
40 size_t relative_size =
41 *reinterpret_cast<const size_t*>(data) % (size - size_t_bytes);
42 std::string relative_string(
43 reinterpret_cast<const char*>(data + size_t_bytes), relative_size);
44 base::StringPiece string_piece_part_input(
45 reinterpret_cast<const char*>(data + size_t_bytes + relative_size),
46 size - relative_size - size_t_bytes);
47 GURL url_from_string_piece_part(string_piece_part_input);
48 url_from_string_piece_part.Resolve(relative_string);
50 if (relative_size % 2 == 0) {
51 base::string16 relative_string16(
52 reinterpret_cast<const base::char16*>(data + size_t_bytes),
54 url_from_string_piece_part.Resolve(relative_string16);