feat update

This commit is contained in:
tqcq 2024-03-29 09:32:18 +08:00
parent ffdbf161b4
commit a74d48b915
4 changed files with 18 additions and 2 deletions

View File

@ -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)

View File

@ -1,4 +1,5 @@
#include <gtest/gtest.h>
#include <sled/futures/promise.h>
TEST(Promise, Basic)
{
@ -21,7 +22,7 @@ TEST(Promise, Basic)
TEST(Future, Basic)
{
auto p = sled::Promise<int>();
auto p = sled::Promise<int>();
auto future = p.GetFuture()
.Then([](int v) {
EXPECT_EQ(v, 1);

View File

@ -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

View File

@ -1,2 +1,12 @@
#include <gtest/gtest.h>
#include <sled/uri.h>
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(), "");
}