| 20 | #include "brpc/uri.h" |
| 21 | |
| 22 | TEST(URITest, everything) { |
| 23 | brpc::URI uri; |
| 24 | std::string uri_str = " foobar://user:passwd@www.baidu.com:80/s?wd=uri#frag "; |
| 25 | ASSERT_EQ(0, uri.SetHttpURL(uri_str)); |
| 26 | ASSERT_EQ("foobar", uri.scheme()); |
| 27 | ASSERT_EQ(80, uri.port()); |
| 28 | ASSERT_EQ("www.baidu.com", uri.host()); |
| 29 | ASSERT_EQ("/s", uri.path()); |
| 30 | ASSERT_EQ("user:passwd", uri.user_info()); |
| 31 | ASSERT_EQ("frag", uri.fragment()); |
| 32 | ASSERT_TRUE(uri.GetQuery("wd")); |
| 33 | ASSERT_EQ(*uri.GetQuery("wd"), "uri"); |
| 34 | ASSERT_FALSE(uri.GetQuery("nonkey")); |
| 35 | |
| 36 | std::string scheme; |
| 37 | std::string host_out; |
| 38 | int port_out = -1; |
| 39 | brpc::ParseURL(uri_str.c_str(), &scheme, &host_out, &port_out); |
| 40 | ASSERT_EQ("foobar", scheme); |
| 41 | ASSERT_EQ("www.baidu.com", host_out); |
| 42 | ASSERT_EQ(80, port_out); |
| 43 | } |
| 44 | |
| 45 | TEST(URITest, only_host) { |
| 46 | brpc::URI uri; |
nothing calls this directly
no test coverage detected