mirror of
https://github.com/Naios/continuable.git
synced 2025-12-08 01:36:46 +08:00
Use cxx_function as second testing backend
This commit is contained in:
parent
e22db05cc3
commit
a2f9007cf6
@ -145,6 +145,8 @@ TYPED_TEST(single_dimension_tests, are_chainable) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NO_FUTURE_TESTS
|
||||
|
||||
TYPED_TEST(single_dimension_tests, are_convertible_to_futures) {
|
||||
auto is_ready = [](auto& future) {
|
||||
// Check that the future is ready
|
||||
@ -185,6 +187,8 @@ TYPED_TEST(single_dimension_tests, are_convertible_to_futures) {
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NO_FUTURE_TESTS
|
||||
|
||||
TYPED_TEST(single_dimension_tests, are_partial_callable) {
|
||||
EXPECT_ASYNC_RESULT(this->supply(1, 2).then([] {
|
||||
// ...
|
||||
|
||||
@ -23,6 +23,8 @@
|
||||
|
||||
#include "test-continuable.hpp"
|
||||
|
||||
#ifndef NO_ERASURE_TESTS
|
||||
|
||||
TYPED_TEST(single_dimension_tests, is_eraseable) {
|
||||
|
||||
{
|
||||
@ -49,3 +51,5 @@ TYPED_TEST(single_dimension_tests, is_callable) {
|
||||
|
||||
EXPECT_ASYNC_RESULT(std::move(erased), 0xDF, 0xDD);
|
||||
}
|
||||
|
||||
#endif // #ifndef NO_ERASURE_TESTS
|
||||
|
||||
@ -24,22 +24,55 @@
|
||||
#ifndef TEST_CONTINUABLE_HPP__
|
||||
#define TEST_CONTINUABLE_HPP__
|
||||
|
||||
#if UNIT_TEST_STEP >= 3
|
||||
#define THIRD_PARTY_TESTS
|
||||
#endif
|
||||
|
||||
#ifdef THIRD_PARTY_TESTS
|
||||
#if _MSC_VER
|
||||
#pragma warning(push, 0)
|
||||
#endif
|
||||
#endif // THIRD_PARTY_TESTS
|
||||
|
||||
#include <cassert>
|
||||
|
||||
#include "continuable/continuable-base.hpp"
|
||||
#include "continuable/continuable-testing.hpp"
|
||||
#include "continuable/continuable.hpp"
|
||||
#include "cxx_function/cxx_function.hpp"
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
#ifdef THIRD_PARTY_TESTS
|
||||
|
||||
#include "cxx_function/cxx_function.hpp"
|
||||
|
||||
template <typename... Args>
|
||||
using cxx_trait_of = cti::continuable_trait<cxx_function::function,
|
||||
cxx_function::function, Args...>;
|
||||
using std_trait_of =
|
||||
cti::continuable_trait<std::function, std::function, Args...>;
|
||||
|
||||
template <typename... Args>
|
||||
using std_continuable = typename std_trait_of<Args...>::continuable;
|
||||
|
||||
template <typename T> using cxx_function_fn = cxx_function::function<T>;
|
||||
|
||||
template <typename... Args>
|
||||
using cxx_trait_of =
|
||||
cti::continuable_trait<cxx_function_fn, cxx_function_fn, Args...>;
|
||||
|
||||
template <typename... Args>
|
||||
using cxx_continuable = typename cxx_trait_of<Args...>::continuable;
|
||||
|
||||
template <typename T>
|
||||
using cxx_function_unique_fn = cxx_function::unique_function<T>;
|
||||
|
||||
template <typename... Args>
|
||||
using unique_cxx_trait_of =
|
||||
cti::continuable_trait<cxx_function::unique_function,
|
||||
cxx_function::unique_function, Args...>;
|
||||
cti::continuable_trait<cxx_function_unique_fn, cxx_function_unique_fn,
|
||||
Args...>;
|
||||
|
||||
template <typename... Args>
|
||||
using cxx_unique_continuable =
|
||||
typename unique_cxx_trait_of<Args...>::continuable;
|
||||
#endif // THIRD_PARTY_TESTS
|
||||
|
||||
using cti::detail::util::identity;
|
||||
|
||||
@ -108,18 +141,9 @@ struct provide_unique {
|
||||
}
|
||||
};
|
||||
|
||||
struct provide_copyable_erasure {
|
||||
template <template <typename...> class Erasure> struct provide_erasure {
|
||||
template <typename... Args, typename... Hint, typename T>
|
||||
cti::continuable<Args...> make(identity<Args...>, identity<Hint...>,
|
||||
T&& callback) {
|
||||
return cti::make_continuable<Hint...>(std::forward<T>(callback));
|
||||
}
|
||||
};
|
||||
|
||||
struct provide_unique_erasure {
|
||||
template <typename... Args, typename... Hint, typename T>
|
||||
cti::unique_continuable<Args...> make(identity<Args...>, identity<Hint...>,
|
||||
T&& callback) {
|
||||
Erasure<Args...> make(identity<Args...>, identity<Hint...>, T&& callback) {
|
||||
return cti::make_continuable<Hint...>(std::forward<T>(callback));
|
||||
}
|
||||
};
|
||||
@ -161,22 +185,28 @@ using single_types = ::testing::Types<
|
||||
#if UNIT_TEST_STEP == 0
|
||||
provide_copyable,
|
||||
// provide_unique,
|
||||
// provide_copyable_erasure,
|
||||
provide_unique_erasure
|
||||
// provide_erasure<cti::continuable>,
|
||||
provide_erasure<cti::unique_continuable>
|
||||
#elif UNIT_TEST_STEP == 1
|
||||
// Some instantiations out commented for compilation speed reasons
|
||||
// provide_continuation_and_left<provide_copyable>,
|
||||
provide_continuation_and_left<provide_unique>
|
||||
// provide_continuation_and_left<provide_copyable_erasure>,
|
||||
// provide_continuation_and_left<provide_unique_erasure>,
|
||||
provide_continuation_and_left<provide_unique>,
|
||||
// provide_continuation_and_left<provide_erasure<cti::continuable>>,
|
||||
// provide_continuation_and_left<provide_erasure<cti::unique_continuable>>,
|
||||
// provide_continuation_and_right<provide_copyable>,
|
||||
provide_continuation_and_right<provide_unique>,
|
||||
provide_continuation_and_left<provide_erasure<cti::continuable>>
|
||||
#elif UNIT_TEST_STEP == 2
|
||||
provide_continuation_and_right<provide_unique>
|
||||
// provide_continuation_and_left<provide_copyable_erasure>,
|
||||
#elif UNIT_TEST_STEP == 3
|
||||
provide_continuation_and_left<provide_unique_erasure>
|
||||
#elif UNIT_TEST_STEP == 4
|
||||
provide_continuation_and_left<provide_erasure<cti::unique_continuable>>,
|
||||
provide_continuation_seq_right<provide_unique>
|
||||
#elif UNIT_TEST_STEP == 3
|
||||
#define NO_ERASURE_TESTS
|
||||
provide_erasure<cxx_unique_continuable>
|
||||
#elif UNIT_TEST_STEP == 4
|
||||
#define NO_ERASURE_TESTS
|
||||
#define NO_FUTURE_TESTS
|
||||
provide_erasure<std_continuable>,
|
||||
provide_erasure<cxx_continuable>
|
||||
#endif
|
||||
>;
|
||||
// clang-format on
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user