mirror of
https://github.com/Naios/continuable.git
synced 2025-12-06 16:56:44 +08:00
Add a unit test which tests for ready continuables explicitly
This commit is contained in:
parent
1bdee5b371
commit
1320c8eb63
@ -46,19 +46,6 @@ namespace cti {
|
|||||||
/// bool operator() (cti::is_ready_arg_t) const;
|
/// bool operator() (cti::is_ready_arg_t) const;
|
||||||
/// std::tuple<Args...> operator() (cti::query_arg_t);
|
/// std::tuple<Args...> operator() (cti::query_arg_t);
|
||||||
/// };
|
/// };
|
||||||
/// template<typename T>
|
|
||||||
/// struct continuation<T> {
|
|
||||||
/// template<typename Callback>
|
|
||||||
/// void operator() (callback<T>);
|
|
||||||
/// bool operator() (cti::is_ready_arg_t) const;
|
|
||||||
/// T operator() (cti::query_arg_t);
|
|
||||||
/// };
|
|
||||||
/// template<>
|
|
||||||
/// struct continuation<void> {
|
|
||||||
/// void operator() (callback<>);
|
|
||||||
/// bool operator() (cti::is_ready_arg_t) const;
|
|
||||||
/// void operator() (cti::query_arg_t);
|
|
||||||
/// };
|
|
||||||
/// ```
|
/// ```
|
||||||
/// ```cpp
|
/// ```cpp
|
||||||
/// template<typename... Args>
|
/// template<typename... Args>
|
||||||
|
|||||||
@ -41,11 +41,7 @@ else()
|
|||||||
set(STEP_RANGE 4)
|
set(STEP_RANGE 4)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
foreach(STEP RANGE ${STEP_RANGE})
|
set(TEST_SOURCES
|
||||||
set(PROJECT_NAME test-continuable-multi-${STEP})
|
|
||||||
set(TEST_NAME continuable-unit-tests-multi-${STEP})
|
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME}
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-await.cpp
|
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-await.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-base-chaining.cpp
|
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-base-chaining.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-base-destruct.cpp
|
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-base-destruct.cpp
|
||||||
@ -62,6 +58,12 @@ foreach(STEP RANGE ${STEP_RANGE})
|
|||||||
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-regression.cpp
|
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-regression.cpp
|
||||||
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-transforms.cpp)
|
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-transforms.cpp)
|
||||||
|
|
||||||
|
foreach(STEP RANGE ${STEP_RANGE})
|
||||||
|
set(PROJECT_NAME test-continuable-multi-${STEP})
|
||||||
|
set(TEST_NAME continuable-unit-tests-multi-${STEP})
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME} ${TEST_SOURCES})
|
||||||
|
|
||||||
target_link_libraries(${PROJECT_NAME}
|
target_link_libraries(${PROJECT_NAME}
|
||||||
PUBLIC
|
PUBLIC
|
||||||
test-continuable-base)
|
test-continuable-base)
|
||||||
@ -79,3 +81,27 @@ foreach(STEP RANGE ${STEP_RANGE})
|
|||||||
NAME ${TEST_NAME}
|
NAME ${TEST_NAME}
|
||||||
COMMAND ${PROJECT_NAME})
|
COMMAND ${PROJECT_NAME})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
# The ready tests
|
||||||
|
set(PROJECT_NAME test-continuable-multi-ready)
|
||||||
|
set(TEST_NAME continuable-unit-tests-multi-ready)
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME} ${TEST_SOURCES})
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME}
|
||||||
|
PUBLIC
|
||||||
|
test-continuable-base)
|
||||||
|
|
||||||
|
target_include_directories(${PROJECT_NAME}
|
||||||
|
PUBLIC
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}
|
||||||
|
${CMAKE_CURRENT_LIST_DIR}/multi)
|
||||||
|
|
||||||
|
target_compile_definitions(${PROJECT_NAME}
|
||||||
|
PUBLIC
|
||||||
|
-DUNIT_TEST_STEP=0
|
||||||
|
-DUNIT_TEST_READY_CONTINUABLES)
|
||||||
|
|
||||||
|
add_test(
|
||||||
|
NAME ${TEST_NAME}
|
||||||
|
COMMAND ${PROJECT_NAME})
|
||||||
|
|||||||
@ -77,11 +77,15 @@ public:
|
|||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
auto supply(Args&&... args) {
|
auto supply(Args&&... args) {
|
||||||
|
#ifdef UNIT_TEST_READY_CONTINUABLES
|
||||||
|
return cti::make_ready_continuable(std::forward<Args>(args)...);
|
||||||
|
#else
|
||||||
identity<std::decay_t<Args>...> arg_types;
|
identity<std::decay_t<Args>...> arg_types;
|
||||||
auto hint_types = to_hint(arg_types);
|
auto hint_types = to_hint(arg_types);
|
||||||
|
|
||||||
return this->make(arg_types, hint_types,
|
return this->make(arg_types, hint_types,
|
||||||
supplier_of(std::forward<Args>(args)...));
|
supplier_of(std::forward<Args>(args)...));
|
||||||
|
#endif // UNIT_TEST_READY_CONTINUABLES
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename Arg, typename Hint = identity<>>
|
template <typename Arg, typename Hint = identity<>>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user