feat update
Some checks failed
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 3m18s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 3m19s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 6m2s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Failing after 6m11s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 6m38s
linux-arm-gcc / linux-gcc-armhf (push) Failing after 7m0s
Some checks failed
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 3m18s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 3m19s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 6m2s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Failing after 6m11s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 6m38s
linux-arm-gcc / linux-gcc-armhf (push) Failing after 7m0s
This commit is contained in:
parent
f896568619
commit
00be161b61
@ -293,7 +293,7 @@ public:
|
|||||||
{
|
{
|
||||||
Future<T, OtherFailureT> result = Future<T, OtherFailureT>::Create();
|
Future<T, OtherFailureT> result = Future<T, OtherFailureT>::Create();
|
||||||
OnSuccess([result](const T &v) mutable noexcept { result.FillSuccess(v); });
|
OnSuccess([result](const T &v) mutable noexcept { result.FillSuccess(v); });
|
||||||
OnFailure([result, f](const FailureT &failure) noexcept {
|
OnFailure([result, f](const FailureT &failure) mutable noexcept {
|
||||||
try {
|
try {
|
||||||
result.FillFailure(f(failure));
|
result.FillFailure(f(failure));
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
@ -126,4 +126,24 @@ TEST_SUITE("future")
|
|||||||
REQUIRE_EQ(f1.Result(), 1);
|
REQUIRE_EQ(f1.Result(), 1);
|
||||||
REQUIRE_EQ(f2.FailureReason(), "1");
|
REQUIRE_EQ(f2.FailureReason(), "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("MapFailure")
|
||||||
|
{
|
||||||
|
sled::Future<int, bool> f = false;
|
||||||
|
auto f1 = f.MapFailure([](bool) { return std::string("error"); });
|
||||||
|
CHECK_EQ(f1.FailureReason(), "error");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("Chain")
|
||||||
|
{
|
||||||
|
sled::Future<int, bool> f = 1;
|
||||||
|
auto f1 = f.Map([](int i) { return i + 1; })
|
||||||
|
.FlatMap([](int i) {
|
||||||
|
sled::Promise<std::string, bool> p;
|
||||||
|
p.Success(std::to_string(i));
|
||||||
|
return p.GetFuture();
|
||||||
|
})
|
||||||
|
.MapFailure([](bool) { return std::exception(); });
|
||||||
|
CHECK_EQ(f1.Result(), "2");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user