Ada 2.9.0
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
url_search_params.cc
Go to the documentation of this file.
1#include <fuzzer/FuzzedDataProvider.h>
2
3#include <memory>
4#include <string>
5
6#include "ada.cpp"
7#include "ada.h"
8
9extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
10 FuzzedDataProvider fdp(data, size);
11 std::string source = fdp.ConsumeRandomLengthString(256);
12 std::string base_source = fdp.ConsumeRandomLengthString(256);
13
18 auto base_source_view =
19 std::string_view(base_source.data(), base_source.length());
20 auto initialized = ada::url_search_params(base_source_view);
21
22 auto search_params = ada::url_search_params();
23 search_params.append(source, base_source);
24 search_params.set(source, base_source);
25 search_params.to_string();
26 if (!search_params.has(base_source)) {
27 search_params.append(base_source, source);
28 }
29 search_params.remove(source);
30 search_params.remove(source, base_source);
31 if (search_params.has(base_source, source)) {
32 search_params.remove(base_source);
33 search_params.remove(base_source, source);
34 }
35
36 auto keys = search_params.get_keys();
37 while (keys.has_next()) {
38 keys.next();
39 }
40
41 auto values = search_params.get_values();
42 while (values.has_next()) {
43 values.next();
44 }
45
46 auto entries = search_params.get_entries();
47 while (entries.has_next()) {
48 entries.next();
49 }
50
51 // This is testing a private method used only for C API.
52 std::string resetted_value = fdp.ConsumeRandomLengthString(256);
53 search_params.reset(resetted_value);
54
55 return 0;
56}
Includes all definitions for Ada.
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)