28 fbstring s(
"http://www.facebook.com/hello/world?query#fragment");
35 EXPECT_EQ(
"www.facebook.com", u.authority());
43 fbstring s(
"http://www.facebook.com:8080/hello/world?query#fragment");
50 EXPECT_EQ(
"www.facebook.com:8080", u.authority());
58 fbstring s(
"http://127.0.0.1:8080/hello/world?query#fragment");
65 EXPECT_EQ(
"127.0.0.1:8080", u.authority());
73 fbstring s(
"http://[::1]:8080/hello/world?query#fragment");
89 fbstring s(
"http://[2401:db00:20:7004:face:0:29:0]:8080/hello/world?query");
94 EXPECT_EQ(
"[2401:db00:20:7004:face:0:29:0]", u.host());
95 EXPECT_EQ(
"2401:db00:20:7004:face:0:29:0", u.hostname());
97 EXPECT_EQ(
"[2401:db00:20:7004:face:0:29:0]:8080", u.authority());
105 fbstring s(
"http://[2401:db00:20:7004:face:0:29:0]/hello/world?query");
110 EXPECT_EQ(
"[2401:db00:20:7004:face:0:29:0]", u.host());
111 EXPECT_EQ(
"2401:db00:20:7004:face:0:29:0", u.hostname());
113 EXPECT_EQ(
"[2401:db00:20:7004:face:0:29:0]", u.authority());
121 fbstring s(
"http://user:pass@host.com/");
128 EXPECT_EQ(
"user:pass@host.com", u.authority());
143 EXPECT_EQ(
"user@host.com", u.authority());
158 EXPECT_EQ(
"user@host.com", u.authority());
162 EXPECT_EQ(
"http://user@host.com/", u.fbstr());
173 EXPECT_EQ(
":pass@host.com", u.authority());
192 EXPECT_EQ(
"http://host.com/", u.fbstr());
207 EXPECT_EQ(
"http://host.com/", u.fbstr());
257 fbstring s(
"http://localhost?&key1=foo&key2=&key3&=bar&=bar=&");
259 auto paramsList = u.getQueryParams();
260 std::map<fbstring, fbstring>
params;
261 for (
auto& param : paramsList) {
262 params[param.first] = param.second;
266 EXPECT_NE(params.end(), params.find(
"key2"));
268 EXPECT_NE(params.end(), params.find(
"key3"));
274 fbstring s(
"http://localhost?&&&&&&&&&&&&&&&");
276 auto params = u.getQueryParams();
282 fbstring s(
"http://localhost?&=invalid_key&key2&key3=foo");
284 auto paramsList = u.getQueryParams();
285 std::map<fbstring, fbstring>
params;
286 for (
auto& param : paramsList) {
287 params[param.first] = param.second;
290 EXPECT_NE(params.end(), params.find(
"key2"));
297 fbstring s(
"http://localhost?&key1=====&&=key2&key3=");
299 auto paramsList = u.getQueryParams();
300 std::map<fbstring, fbstring>
params;
301 for (
auto& param : paramsList) {
302 params[param.first] = param.second;
305 EXPECT_NE(params.end(), params.find(
"key3"));
311 fbstring s(
"http://localhost?key1=foo=bar&key2=foobar&");
313 auto paramsList = u.getQueryParams();
314 std::map<fbstring, fbstring>
params;
315 for (
auto& param : paramsList) {
316 params[param.first] = param.second;
327 CHECK(
false) <<
"Control should not have reached here";
328 }
catch (
const std::invalid_argument& ex) {
337 Uri u(
"http://" +
s);
338 CHECK(
false) <<
"Control should not have reached here";
339 }
catch (
const std::invalid_argument& ex) {
345 fbstring s(
"http://[::1:8080/hello/world?query#fragment");
349 CHECK(
false) <<
"Control should not have reached here";
350 }
catch (
const std::invalid_argument&) {
356 fbstring s(
"http://::1]:8080/hello/world?query#fragment");
360 CHECK(
false) <<
"Control should not have reached here";
361 }
catch (
const std::invalid_argument&) {
367 fbstring s(
"http://::1:8080/hello/world?query#fragment");
371 CHECK(
false) <<
"Control should not have reached here";
372 }
catch (
const std::invalid_argument&) {
378 fbstring s(
"http://2401:db00:20:7004:face:0:29:0/hello/world?query");
382 CHECK(
false) <<
"Control should not have reached here";
383 }
catch (
const std::invalid_argument&) {
400 EXPECT_EQ(
"is:another:valid:uri", u.path());
407 EXPECT_EQ(
"is@another:valid:uri", u.path());
#define EXPECT_EQ(val1, val2)
constexpr Params params[]
#define EXPECT_TRUE(condition)
#define EXPECT_NE(val1, val2)