MCPcopy Create free account
hub / github.com/comaps/comaps / TestUrl

Class TestUrl

libs/coding/coding_tests/url_tests.cpp:16–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14using namespace url;
15
16class TestUrl
17{
18public:
19 explicit TestUrl(string && url) : m_url(std::move(url)) {}
20
21 TestUrl & Scheme(string && scheme)
22 {
23 m_scheme = std::move(scheme);
24 return *this;
25 }
26 TestUrl & Host(string && host)
27 {
28 m_host = std::move(host);
29 return *this;
30 }
31 TestUrl & Path(string && path)
32 {
33 m_path = std::move(path);
34 return *this;
35 }
36 TestUrl & KV(string && key, string && value)
37 {
38 m_keyValuePairs.emplace(std::move(key), std::move(value));
39 return *this;
40 }
41
42 ~TestUrl()
43 {
44 Url url(m_url);
45 TEST_EQUAL(url.GetScheme(), m_scheme, ());
46 TEST_EQUAL(url.GetHost(), m_host, ());
47 TEST_EQUAL(url.GetPath(), m_path, ());
48
49 TEST(!m_scheme.empty() || !url.IsValid(), ("Scheme is empty if and only if url is invalid!"));
50
51 url.ForEachParam([this](string const & name, string const & value)
52 {
53 TEST(!m_keyValuePairs.empty(), ("Failed for url = ", m_url));
54 TEST_EQUAL(m_keyValuePairs.front().first, name, ());
55 TEST_EQUAL(m_keyValuePairs.front().second, value, ());
56 m_keyValuePairs.pop();
57 });
58 }
59
60private:
61 string m_url, m_scheme, m_host, m_path;
62 queue<pair<string, string>> m_keyValuePairs;
63};
64
65char const * orig1 = "http://google.com/main_index.php";
66char const * enc1 = "http%3A%2F%2Fgoogle.com%2Fmain_index.php";

Callers 1

UNIT_TESTFunction · 0.85

Calls 1

emplaceMethod · 0.45

Tested by 1

UNIT_TESTFunction · 0.68