234 FuzzedDataProvider fdp(data, size);
235 std::string source = fdp.ConsumeRandomLengthString(256);
236 std::string base = fdp.ConsumeRandomLengthString(256);
240 volatile size_t length = 0;
246 if (su.has_value() ^ sa.has_value()) {
247 printf(
"simple_abs parse agreement fail: %s\n", simple_abs.c_str());
251 if (su->get_href() != std::string(sa->get_href())) {
252 printf(
"simple_abs href mismatch:\n in=%s\n url=%s\n agg=%s\n",
253 simple_abs.c_str(), su->get_href().c_str(),
254 std::string(sa->get_href()).c_str());
259 length += su->get_href().size();
267 if (parse_url.has_value() ^ parse_url_aggregator.has_value()) {
268 printf(
"Source used to parse: %s", source.c_str());
274 length += parse_url->get_href().size();
275 length += parse_url->get_origin().size();
279 if (parse_url_aggregator) {
280 length += parse_url_aggregator->get_href().size();
281 length += parse_url_aggregator->get_origin().size();
284 volatile bool is_parse_url_aggregator_output_valid =
false;
285 is_parse_url_aggregator_output_valid = parse_url_aggregator->validate();
287 assert(parse_url->get_protocol() == parse_url_aggregator->get_protocol());
288 assert(parse_url->get_href() == parse_url_aggregator->get_href());
289 assert(std::string(parse_url->get_hostname()) ==
290 std::string(parse_url_aggregator->get_hostname()));
291 assert(std::string(parse_url->get_pathname()) ==
292 std::string(parse_url_aggregator->get_pathname()));
293 assert(std::string(parse_url->get_search()) ==
294 std::string(parse_url_aggregator->get_search()));
295 assert(std::string(parse_url->get_hash()) ==
296 std::string(parse_url_aggregator->get_hash()));
297 assert(std::string(parse_url->get_port()) ==
298 std::string(parse_url_aggregator->get_port()));
299 assert(parse_url->get_username() ==
300 std::string(parse_url_aggregator->get_username()));
301 assert(parse_url->get_password() ==
302 std::string(parse_url_aggregator->get_password()));
303 assert(std::string(parse_url->get_host()) ==
304 std::string(parse_url_aggregator->get_host()));
311 parse_url->set_href(source);
312 parse_url_aggregator->set_href(source);
313 assert(parse_url->get_href() == parse_url_aggregator->get_href());
322 assert(copied_url.
get_href() == parse_url->get_href());
326 assigned_url = *parse_url;
327 assert(assigned_url.
get_href() == parse_url->get_href());
330 ada::url moved_url = std::move(copied_url);
331 assert(moved_url.
get_href() == parse_url->get_href());
334 if (parse_url_aggregator) {
337 assert(std::string(copied_agg.
get_href()) ==
338 std::string(parse_url_aggregator->get_href()));
342 assigned_agg = *parse_url_aggregator;
343 assert(std::string(assigned_agg.
get_href()) ==
344 std::string(parse_url_aggregator->get_href()));
348 assert(std::string(moved_agg.
get_href()) ==
349 std::string(parse_url_aggregator->get_href()));
353 move_assigned_agg = std::move(assigned_agg);
354 assert(std::string(move_assigned_agg.
get_href()) ==
355 std::string(parse_url_aggregator->get_href()));
364 out_url->set_protocol(source);
365 out_url->set_username(source);
366 out_url->set_password(source);
367 out_url->set_hostname(source);
368 out_url->set_host(source);
369 out_url->set_pathname(source);
370 out_url->set_search(source);
371 out_url->set_hash(source);
372 out_url->set_port(source);
375 length += out_url->get_protocol().size();
376 length += out_url->get_username().size();
377 length += out_url->get_password().size();
378 length += out_url->get_hostname().size();
379 length += out_url->get_host().size();
380 length += out_url->get_pathname().size();
381 length += out_url->get_search().size();
382 length += out_url->get_hash().size();
383 length += out_url->get_origin().size();
384 length += out_url->get_port().size();
385 length += out_url->get_pathname_length();
387 length += out_url->to_string().size();
390 (void)out_url->has_valid_domain();
391 (void)out_url->has_credentials();
392 (void)out_url->has_empty_hostname();
393 (void)out_url->has_hostname();
394 (void)out_url->has_port();
395 (void)out_url->has_hash();
396 (void)out_url->has_search();
397 (void)out_url->get_components();
403 auto out_aggregator =
406 if (out_aggregator) {
407 out_aggregator->set_protocol(source);
408 out_aggregator->set_username(source);
409 out_aggregator->set_password(source);
410 out_aggregator->set_hostname(source);
411 out_aggregator->set_host(source);
412 out_aggregator->set_pathname(source);
413 out_aggregator->set_search(source);
414 out_aggregator->set_hash(source);
415 out_aggregator->set_port(source);
418 length += out_aggregator->get_protocol().size();
419 length += out_aggregator->get_username().size();
420 length += out_aggregator->get_password().size();
421 length += out_aggregator->get_hostname().size();
422 length += out_aggregator->get_host().size();
423 length += out_aggregator->get_pathname().size();
424 length += out_aggregator->get_search().size();
425 length += out_aggregator->get_hash().size();
426 length += out_aggregator->get_origin().size();
427 length += out_aggregator->get_port().size();
428 length += out_aggregator->get_pathname_length();
430 length += out_aggregator->to_string().size();
432 volatile bool is_output_valid =
false;
433 is_output_valid = out_aggregator->validate();
435 (void)out_aggregator->to_diagram();
438 (void)out_aggregator->has_valid_domain();
439 (void)out_aggregator->has_credentials();
440 (void)out_aggregator->has_empty_hostname();
441 (void)out_aggregator->has_hostname();
442 (void)out_aggregator->has_non_empty_username();
443 (void)out_aggregator->has_non_empty_password();
444 (void)out_aggregator->has_password();
445 (void)out_aggregator->has_port();
446 (void)out_aggregator->has_hash();
447 (void)out_aggregator->has_search();
448 (void)out_aggregator->get_components();
451 out_aggregator->clear_port();
452 if (out_aggregator->has_port()) {
453 printf(
"clear_port() did not clear has_port()\n");
456 if (!out_aggregator->get_port().empty()) {
457 printf(
"clear_port() left non-empty get_port()\n");
461 out_aggregator->clear_search();
462 if (out_aggregator->has_search()) {
463 printf(
"clear_search() did not clear has_search()\n");
466 if (!out_aggregator->get_search().empty()) {
467 printf(
"clear_search() left non-empty get_search()\n");
471 out_aggregator->clear_hash();
472 if (out_aggregator->has_hash()) {
473 printf(
"clear_hash() did not clear has_hash()\n");
476 if (!out_aggregator->get_hash().empty()) {
477 printf(
"clear_hash() left non-empty get_hash()\n");
491 length += result->get_href().size();
492 length += result->get_origin().size();
500 length += result->get_href().size();
501 length += result->get_origin().size();
513 if (res_url.has_value() ^ res_agg.has_value()) {
514 printf(
"Relative parse inconsistency for source=%s base=%s\n",
515 source.c_str(), base.c_str());
518 if (res_url && res_agg) {
519 if (res_url->get_href() != std::string(res_agg->get_href())) {
520 printf(
"Relative parse href mismatch for source=%s base=%s\n",
521 source.c_str(), base.c_str());
534 std::string input2 = fdp.ConsumeRandomLengthString(128);
537 length += level2->get_href().size();
538 volatile bool v = level2->validate();
555 length += result->get_href().size();
569 bool is_valid = ada::checkers::verify_dns_length(source);
584 "https://user:pass@example.com:8080/path?query=1#hash");
586 "https://user:pass@example.com:8080/path?query=1#hash");
587 if (url_seq && agg_seq) {
588 int steps = fdp.ConsumeIntegralInRange(1, 8);
589 for (
int i = 0; i < steps; ++i) {
590 std::string val = fdp.ConsumeRandomLengthString(64);
591 int which = fdp.ConsumeIntegralInRange(0, 8);
594 url_seq->set_protocol(val);
595 agg_seq->set_protocol(val);
598 url_seq->set_username(val);
599 agg_seq->set_username(val);
602 url_seq->set_password(val);
603 agg_seq->set_password(val);
606 url_seq->set_hostname(val);
607 agg_seq->set_hostname(val);
610 url_seq->set_host(val);
611 agg_seq->set_host(val);
614 url_seq->set_pathname(val);
615 agg_seq->set_pathname(val);
618 url_seq->set_search(val);
619 agg_seq->set_search(val);
622 url_seq->set_hash(val);
623 agg_seq->set_hash(val);
626 url_seq->set_port(val);
627 agg_seq->set_port(val);
631 if (url_seq->get_href() != std::string(agg_seq->get_href())) {
633 "Sequential setter href mismatch after setter=%d val='%s'\n"
634 " url: %s\n agg: %s\n",
635 which, val.c_str(), url_seq->get_href().c_str(),
636 std::string(agg_seq->get_href()).c_str());
640 volatile bool v = agg_seq->validate();
653 if (parse_url_aggregator) {
654 std::string href1 = std::string(parse_url_aggregator->get_href());
657 printf(
"Re-parse of href failed unexpectedly: '%s'\n", href1.c_str());
660 std::string href2 = std::string(reparsed->get_href());
661 if (href1 != href2) {
663 "Re-parse idempotency failure!\n"
664 " href1: %s\n href2: %s\n",
665 href1.c_str(), href2.c_str());
682 std::string search_url =
"https://example.com/?" + source;
684 if (url_with_search) {
686 std::string search_raw = std::string(url_with_search->get_search());
687 std::string_view search_view = search_raw;
688 if (!search_view.empty() && search_view[0] ==
'?') {
689 search_view = search_view.substr(1);
701 std::string serialized2 = sp2.
to_string();
702 if (serialized2 != serialized) {
704 "url_search_params serialisation not idempotent!\n"
705 " first: %s\n second: %s\n",
706 serialized.c_str(), serialized2.c_str());
711 url_with_search->set_search(serialized);
712 volatile bool v = url_with_search->validate();