feat add expected
All checks were successful
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Successful in 1m19s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 1m32s
linux-arm-gcc / linux-gcc-armhf (push) Successful in 1m39s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 1m40s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 1m54s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 2m24s

This commit is contained in:
tqcq 2024-04-09 03:04:48 +00:00
parent e9a9a2ff72
commit f2408b4aec
4 changed files with 2634 additions and 0 deletions

View File

@ -193,6 +193,7 @@ if(SLED_BUILD_TESTS)
sled_add_test(NAME sled_rpc_test SRCS src/sled/network/rpc_test.cc)
sled_add_test(NAME sled_string_view_test SRCS
src/sled/nonstd/string_view_test.cc)
sled_add_test(NAME sled_expected_test SRCS src/sled/nonstd/expected_test.cc)
endif(SLED_BUILD_TESTS)
if(SLED_BUILD_FUZZ)

2613
src/sled/nonstd/expected.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,19 @@
#include <sled/nonstd/expected.h>
#include <sled/status.h>
TEST_SUITE("expected")
{
TEST_CASE("base")
{
sled::expected<int, int> e = 21;
auto ret = e.map([](int v) { return v * 2; });
CHECK(ret);
CHECK_EQ(*ret, 42);
}
TEST_CASE("unexpect")
{
sled::expected<int, int> e{sled::unexpect, 0};
CHECK_EQ(e.error(), 0);
}
}

View File

@ -6,6 +6,7 @@
#include "inja.hpp"
#include "rx.h"
#include "sled/async/async.h"
#include "sled/nonstd/expected.h"
#include "sled/nonstd/string_view.h"
#include "toml.hpp"