MCPcopy Create free account
hub / github.com/apache/brpc / TEST

Function TEST

test/brpc_uri_unittest.cpp:22–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20#include "brpc/uri.h"
21
22TEST(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
45TEST(URITest, only_host) {
46 brpc::URI uri;

Callers

nothing calls this directly

Calls 15

ParseURLFunction · 0.85
portMethod · 0.80
GetQueryMethod · 0.80
QueryCountMethod · 0.80
set_pathMethod · 0.80
SetQueryMethod · 0.80
GenerateH2PathMethod · 0.80
RemoveQueryMethod · 0.80
error_cstrMethod · 0.80
PrintWithoutHostMethod · 0.80
modified_queryMethod · 0.80

Tested by

no test coverage detected