initial work on the multipathing unit tests

This commit is contained in:
Denis Blank 2018-11-25 03:18:35 +01:00
parent 07c8ed0cf9
commit f4268f60f9
5 changed files with 95 additions and 14 deletions

View File

@ -114,8 +114,8 @@ public:
} }
explicit result(exception_t exception) : variant_(std::move(exception)) { explicit result(exception_t exception) : variant_(std::move(exception)) {
} }
explicit result(empty_result){}; result(empty_result){};
explicit result(exceptional_result exceptional_result) result(exceptional_result exceptional_result)
: variant_(std::move(exceptional_result.get_exception())) { : variant_(std::move(exceptional_result.get_exception())) {
} }

View File

@ -220,6 +220,8 @@ template <typename Hint>
auto invoker_of(Hint, traits::identity<empty_result>) { auto invoker_of(Hint, traits::identity<empty_result>) {
return make_invoker( return make_invoker(
[](auto&& callback, auto&& next_callback, auto&&... args) { [](auto&& callback, auto&& next_callback, auto&&... args) {
util::unused(callback, next_callback, args...);
// TODO
/*CONTINUABLE_BLOCK_TRY_BEGIN /*CONTINUABLE_BLOCK_TRY_BEGIN
util::partial_invoke(std::forward<decltype(callback)>(callback), util::partial_invoke(std::forward<decltype(callback)>(callback),
std::forward<decltype(args)>(args)...); std::forward<decltype(args)>(args)...);
@ -235,6 +237,8 @@ template <typename Hint>
auto invoker_of(Hint, traits::identity<exceptional_result>) { auto invoker_of(Hint, traits::identity<exceptional_result>) {
return make_invoker( return make_invoker(
[](auto&& callback, auto&& next_callback, auto&&... args) { [](auto&& callback, auto&& next_callback, auto&&... args) {
util::unused(callback, next_callback, args...);
// TODO
/*CONTINUABLE_BLOCK_TRY_BEGIN /*CONTINUABLE_BLOCK_TRY_BEGIN
util::partial_invoke(std::forward<decltype(callback)>(callback), util::partial_invoke(std::forward<decltype(callback)>(callback),
std::forward<decltype(args)>(args)...); std::forward<decltype(args)>(args)...);
@ -250,6 +254,8 @@ template <typename Hint, typename... Args>
auto invoker_of(Hint, traits::identity<result<Args...>>) { auto invoker_of(Hint, traits::identity<result<Args...>>) {
return make_invoker( return make_invoker(
[](auto&& callback, auto&& next_callback, auto&&... args) { [](auto&& callback, auto&& next_callback, auto&&... args) {
util::unused(callback, next_callback, args...);
// TODO
/*CONTINUABLE_BLOCK_TRY_BEGIN /*CONTINUABLE_BLOCK_TRY_BEGIN
util::partial_invoke(std::forward<decltype(callback)>(callback), util::partial_invoke(std::forward<decltype(callback)>(callback),
std::forward<decltype(args)>(args)...); std::forward<decltype(args)>(args)...);

View File

@ -23,8 +23,83 @@
#include <test-continuable.hpp> #include <test-continuable.hpp>
TYPED_TEST(single_dimension_tests, are_recoverable) { using namespace cti;
/*EXPECT_ASYNC_RESULT(this->supply().then([] () -> cti::expected<> {
return; // void static int const CANARY = 382947;
}));*/
TYPED_TEST(single_dimension_tests, multipath_result_is_forwardable) {
EXPECT_ASYNC_RESULT(this->supply().then([](auto&&... canaries) -> result<> {
//
return make_result(std::forward<decltype(canaries)>(canaries)...);
}));
EXPECT_ASYNC_RESULT(
this->supply(CANARY).then([](auto&&... canaries) -> result<int> {
//
return make_result(std::forward<decltype(canaries)>(canaries)...);
}),
CANARY);
EXPECT_ASYNC_RESULT(
this->supply(1, CANARY, 3)
.then([](auto&&... canaries) -> result<int, int, int> {
//
return make_result(std::forward<decltype(canaries)>(canaries)...);
}),
1, CANARY, 3);
}
TYPED_TEST(single_dimension_tests, multipath_result_is_throwable) {
ASSERT_ASYNC_EXCEPTION_COMPLETION(
this->supply().then([]() -> exceptional_result {
//
return make_exceptional_result(supply_test_exception());
}));
ASSERT_ASYNC_EXCEPTION_COMPLETION(this->supply().then([]() -> result<> {
//
return make_exceptional_result(supply_test_exception());
}));
}
TYPED_TEST(single_dimension_tests, multipath_result_is_cancelable) {
ASSERT_ASYNC_INCOMPLETION(this->supply().then([]() -> empty_result {
//
return make_empty_result();
}));
ASSERT_ASYNC_INCOMPLETION(this->supply().then([]() -> result<> {
//
return make_empty_result();
}));
}
TYPED_TEST(single_dimension_tests, multipath_exception_is_recoverable) {
/*EXPECT_ASYNC_RESULT(this->supply_exception(supply_test_exception())
.fail([](exception_t) -> result<> {
//
return make_result();
}));
EXPECT_ASYNC_RESULT(this->supply_exception(supply_test_exception())
.fail([](exception_t) -> result<int> {
//
return make_result(CANARY);
}),
CANARY);
EXPECT_ASYNC_RESULT(this->supply_exception(supply_test_exception())
.fail([](exception_t) -> result<int, int, int> {
//
return make_result(1, CANARY, 3);
}),
1, CANARY, 3);*/
}
TYPED_TEST(single_dimension_tests, multipath_exception_is_forwardable) {
// TODO
}
TYPED_TEST(single_dimension_tests, multipath_exception_is_cancelable) {
// TODO
} }

View File

@ -80,7 +80,7 @@ TYPED_TEST(result_all_tests, can_carry_errors) {
} }
{ {
TypeParam e(exception_t{}); TypeParam e(supply_test_exception());
EXPECT_FALSE(bool(e)); EXPECT_FALSE(bool(e));
EXPECT_FALSE(e.is_value()); EXPECT_FALSE(e.is_value());
@ -104,7 +104,7 @@ TYPED_TEST(result_all_tests, is_move_constructible) {
} }
{ {
TypeParam e(TypeParam(exception_t{})); TypeParam e(TypeParam(supply_test_exception()));
EXPECT_FALSE(bool(e)); EXPECT_FALSE(bool(e));
EXPECT_FALSE(e.is_value()); EXPECT_FALSE(e.is_value());
EXPECT_TRUE(e.is_exception()); EXPECT_TRUE(e.is_exception());
@ -123,7 +123,7 @@ TYPED_TEST(result_all_tests, is_value_move_assignable) {
} }
TYPED_TEST(result_all_tests, is_error_move_assignable) { TYPED_TEST(result_all_tests, is_error_move_assignable) {
TypeParam old(exception_t{}); TypeParam old(supply_test_exception());
TypeParam e; TypeParam e;
e = std::move(old); e = std::move(old);
@ -144,7 +144,7 @@ TEST(result_copyable_tests, is_copy_constructible) {
} }
{ {
copyable_type const e_old(exception_t{}); copyable_type const e_old(supply_test_exception());
copyable_type e(e_old); copyable_type e(e_old);
EXPECT_FALSE(bool(e)); EXPECT_FALSE(bool(e));
@ -166,7 +166,7 @@ TEST(result_copyable_tests, is_copy_assignable) {
} }
{ {
copyable_type const e_old(exception_t{}); copyable_type const e_old(supply_test_exception());
copyable_type e; copyable_type e;
e = e_old; e = e_old;
@ -177,7 +177,7 @@ TEST(result_copyable_tests, is_copy_assignable) {
} }
TYPED_TEST(result_all_tests, is_constructible_from_error_helper) { TYPED_TEST(result_all_tests, is_constructible_from_error_helper) {
cti::exceptional_result e1(exception_t{}); cti::exceptional_result e1(supply_test_exception());
{ auto e2 = e1; } { auto e2 = e1; }
auto e2 = std::move(e1); auto e2 = std::move(e1);
@ -189,7 +189,7 @@ TYPED_TEST(result_all_tests, is_constructible_from_error_helper) {
} }
TYPED_TEST(result_all_tests, is_assignable_from_error_helper) { TYPED_TEST(result_all_tests, is_assignable_from_error_helper) {
cti::exceptional_result e1(exception_t{}); cti::exceptional_result e1(supply_test_exception());
{ auto e2 = e1; } { auto e2 = e1; }
auto e2 = std::move(e1); auto e2 = std::move(e1);

View File

@ -267,7 +267,7 @@ struct test_exception : std::exception {
test_exception get_test_exception_proto(); test_exception get_test_exception_proto();
inline auto supply_test_exception() { inline std::exception_ptr supply_test_exception() {
try { try {
throw get_test_exception_proto(); throw get_test_exception_proto();
} catch (...) { } catch (...) {