mirror of
https://github.com/Naios/continuable.git
synced 2026-01-01 03:12:12 +08:00
More work on the unit test
This commit is contained in:
parent
8ef86d3b70
commit
78f1c0ae78
@ -3,20 +3,20 @@ foreach(STEP RANGE 4)
|
||||
set(TEST_NAME continuable-unit-tests-${STEP})
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable.hpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-await.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-base-chaining.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-base-destruct.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-base-errors.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-base-partial.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-connection-all.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-connection-any.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-connection-seq.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-expected.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-erasure.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-regression.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-transforms.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable.hpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-await.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-base-chaining.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-base-destruct.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-base-errors.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-base-partial.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-connection-all.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-connection-any.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-connection-seq.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-expected.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-erasure.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-regression.cpp
|
||||
# ${CMAKE_CURRENT_LIST_DIR}/test-continuable-transforms.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-traverse.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/test-continuable-traverse-async.cpp)
|
||||
|
||||
|
||||
@ -72,6 +72,48 @@ struct all_map {
|
||||
}
|
||||
};
|
||||
|
||||
TEST(traverse_single_test, test_container_categories) {
|
||||
using cti::detail::traversal::container_category_of_t;
|
||||
using cti::detail::traversal::container_category_tag;
|
||||
|
||||
static_assert(std::is_same<container_category_tag<false, false>,
|
||||
container_category_of_t<int>>::value,
|
||||
"Wrong category!");
|
||||
|
||||
static_assert(std::is_same<container_category_tag<true, false>,
|
||||
container_category_of_t<std::vector<int>>>::value,
|
||||
"Wrong category!");
|
||||
|
||||
static_assert(std::is_same<container_category_tag<false, true>,
|
||||
container_category_of_t<std::tuple<int>>>::value,
|
||||
"Wrong category!");
|
||||
|
||||
static_assert(
|
||||
std::is_same<container_category_tag<true, true>,
|
||||
container_category_of_t<std::array<int, 2>>>::value,
|
||||
"Wrong category!");
|
||||
}
|
||||
|
||||
TEST(traverse_single_test, test_simple_mapping) {
|
||||
/*auto res = map_pack(
|
||||
[](int i) {
|
||||
// ...
|
||||
return i + 1;
|
||||
},
|
||||
0, 1, 2, std::vector<int>{3, 4, 5});*/
|
||||
|
||||
auto res =
|
||||
map_pack(all_map_float{}, 0, 1.f, make_tuple(1.f, 3),
|
||||
std::vector<std::vector<int>>{{1, 2}, {4, 5}},
|
||||
std::vector<std::vector<float>>{{1.f, 2.f}, {4.f, 5.f}}, 2);
|
||||
|
||||
auto expected = make_tuple( // ...
|
||||
1.f, 2.f, make_tuple(2.f, 4.f),
|
||||
std::vector<std::vector<float>>{{2.f, 3.f}, {5.f, 6.f}},
|
||||
std::vector<std::vector<float>>{{2.f, 3.f}, {5.f, 6.f}}, 3.f);
|
||||
}
|
||||
|
||||
|
||||
static void test_mixed_traversal() {
|
||||
{
|
||||
auto res =
|
||||
@ -143,6 +185,7 @@ struct my_unwrapper {
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
static void test_mixed_early_unwrapping() {
|
||||
{
|
||||
auto res = map_pack(my_unwrapper{}, // ...
|
||||
@ -785,7 +828,6 @@ static void test_spread_tuple_like_traverse() {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
TODO Convert this to gtest
|
||||
int main(int, char**) {
|
||||
test_mixed_traversal();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user