feat update
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Failing after 2m5s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 1m59s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 2m10s
linux-arm-gcc / linux-gcc-armhf (push) Failing after 2m13s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 2m28s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 2m33s
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Failing after 2m5s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 1m59s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 2m10s
linux-arm-gcc / linux-gcc-armhf (push) Failing after 2m13s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 2m28s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 2m33s
This commit is contained in:
parent
40a8ffd402
commit
6d15ae737d
@ -15,10 +15,24 @@ TEST_SUITE("future")
|
||||
CHECK_EQ(f.Result(), 42);
|
||||
}
|
||||
|
||||
TEST_CASE("base failed")
|
||||
TEST_CASE("base success 1")
|
||||
{
|
||||
sled::Promise<int, std::string> p;
|
||||
auto f = p.GetFuture();
|
||||
auto f = p.GetFuture().OnSuccess([](int i) { CHECK_EQ(i, 42); }).OnFailure([](const std::string &) {
|
||||
REQUIRE(false);
|
||||
});
|
||||
p.Success(42);
|
||||
CHECK(f.Wait(-1));
|
||||
CHECK(f.IsValid());
|
||||
CHECK_EQ(f.Result(), 42);
|
||||
}
|
||||
|
||||
TEST_CASE("base failed 1")
|
||||
{
|
||||
sled::Promise<int, std::string> p;
|
||||
auto f = p.GetFuture().OnFailure([](const std::string &str) { CHECK_EQ(str, "error"); }).OnSuccess([](int) {
|
||||
REQUIRE(false);
|
||||
});
|
||||
p.Failure("error");
|
||||
REQUIRE(p.IsFilled());
|
||||
REQUIRE(f.IsCompleted());
|
||||
@ -40,7 +54,7 @@ TEST_SUITE("future")
|
||||
REQUIRE(f.IsFailed());
|
||||
CHECK_EQ(f.FailureReason(), "test");
|
||||
}
|
||||
|
||||
//
|
||||
TEST_CASE("base failed")
|
||||
{
|
||||
sled::Promise<int, std::string> p;
|
||||
|
@ -15,14 +15,16 @@ struct is_invocable : std::is_constructible<std::function<void(Args...)>,
|
||||
|
||||
}// namespace
|
||||
|
||||
template<typename FailureT>
|
||||
template<typename FailureT,
|
||||
typename = typename std::enable_if<!std::is_constructible<FailureT, std::string>::value>::type>
|
||||
inline FailureT
|
||||
FailureFromString(std::string &&)
|
||||
{
|
||||
return FailureT();
|
||||
}
|
||||
|
||||
template<typename FailureT>
|
||||
template<typename FailureT,
|
||||
typename = typename std::enable_if<std::is_constructible<FailureT, std::string>::value>::type>
|
||||
inline FailureT
|
||||
FailureFromString(const std::string &str)
|
||||
{
|
||||
@ -32,18 +34,25 @@ FailureFromString(const std::string &str)
|
||||
|
||||
template<>
|
||||
inline std::string
|
||||
FailureFromString<std::string>(std::string &&str)
|
||||
FailureFromString<std::string>(const std::string &str)
|
||||
{
|
||||
return std::move(str);
|
||||
return {str};
|
||||
}
|
||||
|
||||
template<typename FailureT,
|
||||
typename = typename std::enable_if<std::is_constructible<FailureT, std::string>::value>::type>
|
||||
inline FailureT
|
||||
FailureFromString(std::string &&str)
|
||||
{
|
||||
return FailureT(std::move(str));
|
||||
}
|
||||
// template<>
|
||||
// inline std::string
|
||||
// FailureFromString<std::string>(std::string &&str)
|
||||
// {
|
||||
// return std::move(str);
|
||||
// }
|
||||
|
||||
// template<typename FailureT,
|
||||
// typename = typename std::enable_if<std::is_constructible<FailureT, std::string>::value>::type>
|
||||
// inline FailureT
|
||||
// FailureFromString(std::string &&str)
|
||||
// {
|
||||
// return FailureT(std::move(str));
|
||||
// }
|
||||
|
||||
}// namespace failure
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user