diff --git a/include/sled/uri.h b/include/sled/uri.h index d5ae9cc..695e740 100644 --- a/include/sled/uri.h +++ b/include/sled/uri.h @@ -26,6 +26,9 @@ public: // http://xxx.com/index.html static URI ParseURIReference(const std::string &uri_str); + URI() = default; + URI(const std::string &uri_str); + // setter getter __SLED_URI_GETTER_AND_SETTER(std::string, scheme) __SLED_URI_GETTER_AND_SETTER(std::string, username) diff --git a/src/futures/promise_test.cc b/src/futures/promise_test.cc index fffe6f1..d4d675b 100644 --- a/src/futures/promise_test.cc +++ b/src/futures/promise_test.cc @@ -1,4 +1,5 @@ #include +#include TEST(Promise, Basic) { @@ -21,7 +22,7 @@ TEST(Promise, Basic) TEST(Future, Basic) { - auto p = sled::Promise(); + auto p = sled::Promise(); auto future = p.GetFuture() .Then([](int v) { EXPECT_EQ(v, 1); diff --git a/src/uri.cc b/src/uri.cc index c3449f9..b27b793 100644 --- a/src/uri.cc +++ b/src/uri.cc @@ -9,8 +9,10 @@ URI::ParseURI(const std::string &uri_str) URI uri; // TODO: decode before auto start_pos = uri_str.find_first_not_of(" "); - auto end_pos = uri_str.find(':'); + auto end_pos = uri_str.find(':'); return std::move(uri); } + +URI::URI(const std::string &uri_str) { *this = ParseURI(uri_str); } }// namespace sled diff --git a/src/uri_test.cc b/src/uri_test.cc index 7caf8b7..bacd260 100644 --- a/src/uri_test.cc +++ b/src/uri_test.cc @@ -1,2 +1,12 @@ #include #include + +TEST(URI, Absolute) +{ + sled::URI uri("http://example.com"); + EXPECT_EQ(uri.scheme(), "http"); + EXPECT_EQ(uri.host(), "example.com"); + EXPECT_EQ(uri.path(), "/"); + EXPECT_TRUE(uri.query().empty()); + EXPECT_EQ(uri.anchor(), ""); +}