12 (void)result.get_protocol();
13 (void)result.get_username();
14 (void)result.get_password();
15 (void)result.get_hostname();
16 (void)result.get_port();
17 (void)result.get_pathname();
18 (void)result.get_search();
19 (void)result.get_hash();
20 (void)result.ignore_case();
21 (void)result.has_regexp_groups();
25 auto to_ascii = [](
const std::string& source) -> std::string {
27 result.reserve(source.size());
28 for (
char c : source) {
29 result.push_back(
static_cast<unsigned char>(c) % 128);
33 FuzzedDataProvider fdp(data, size);
35 std::string source_1 =
"/" + to_ascii(fdp.ConsumeRandomLengthString(50)) +
36 "/" + to_ascii(fdp.ConsumeRandomLengthString(50));
37 std::string base_source_1 =
"/" +
38 to_ascii(fdp.ConsumeRandomLengthString(50)) +
39 "/" + to_ascii(fdp.ConsumeRandomLengthString(50));
41 std::string source_2 =
"https://ada-url.com/*";
42 std::string base_source_2 =
"https://ada-url.com";
44 std::array<std::pair<std::string, std::string>, 2> sources = {{
45 {source_1, base_source_1},
46 {source_2, base_source_2},
49 for (
const auto& [source, base_source] : sources) {
52 ada::parse_url_pattern<regex_provider>(source,
nullptr,
nullptr);
56 std::string_view base_source_view(base_source.data(), base_source.length());
57 auto result_with_base = ada::parse_url_pattern<regex_provider>(
58 source, &base_source_view,
nullptr);
62 ada::url_pattern_options options{.ignore_case = fdp.ConsumeBool()};
63 auto result_with_base_and_options = ada::parse_url_pattern<regex_provider>(
64 source, &base_source_view, &options);
65 if (result_with_base_and_options)
69 int field_index = fdp.ConsumeIntegralInRange(0, 7);
70 std::string random_value = to_ascii(fdp.ConsumeRandomLengthString(50));
71 ada::url_pattern_init init{};
72 switch (field_index) {
74 init.protocol = random_value;
77 init.username = random_value;
80 init.password = random_value;
83 init.hostname = random_value;
86 init.port = random_value;
89 init.pathname = random_value;
92 init.search = random_value;
95 init.hash = random_value;
98 auto result_with_init = ada::parse_url_pattern<regex_provider>(
99 init, &base_source_view,
nullptr);