diff --git a/test/unit-test/CMakeLists.txt b/test/unit-test/CMakeLists.txt index 13ea7bd..00c1d69 100644 --- a/test/unit-test/CMakeLists.txt +++ b/test/unit-test/CMakeLists.txt @@ -57,7 +57,8 @@ foreach(STEP RANGE 4) target_include_directories(${PROJECT_NAME} PUBLIC - ${CMAKE_CURRENT_LIST_DIR}) + ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_CURRENT_LIST_DIR}/multi) target_compile_definitions(${PROJECT_NAME} PUBLIC diff --git a/test/unit-test/multi/test-continuable-connection-all-seq.hpp b/test/unit-test/multi/test-continuable-connection-all-seq.hpp index 6da74a4..f0eac07 100644 --- a/test/unit-test/multi/test-continuable-connection-all-seq.hpp +++ b/test/unit-test/multi/test-continuable-connection-all-seq.hpp @@ -21,6 +21,9 @@ SOFTWARE. **/ +#ifndef TEST_CONTINUABLE_CONNECTION_HPP__ +#define TEST_CONTINUABLE_CONNECTION_HPP__ + #include template @@ -49,64 +52,9 @@ void test_all_seq_op(Supplier&& supply, OperatorConnector&& op) { template void test_all_seq_aggregate(Supplier&& supply, AggregateConnector&& ag) { { - auto chain = ag(supply(1, 2), supply(3, 4)); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3, 4); + auto chain = ag(supply(1, 2), supply(3, 4), supply(5, 6)); + EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3, 4, 5, 6); } } -/* -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable) { - auto chain = this->supply() >> this->supply(); - EXPECT_ASYNC_RESULT(std::move(chain)); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_value) { - auto chain = this->supply(1) >> this->supply(2); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_when_seq) { - auto chain = cti::when_seq(this->supply(1), this->supply(2), this->supply(3)); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_duplicated_val) { - auto chain = this->supply(1, 2) >> this->supply(3, 4); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3, 4); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_tag) { - auto chain = this->supply(tag1{}, tag2{}) >> this->supply(tag1{}, tag2{}); - ASSERT_ASYNC_TYPES(std::move(chain), tag1, tag2, tag1, tag2); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_three_tags) { - auto chain = this->supply(tag1{}, tag2{}, tag3{}) >> - this->supply(tag1{}, tag2{}, tag3{}); - ASSERT_ASYNC_TYPES(std::move(chain), tag1, tag2, tag3, tag1, tag2, tag3); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_composed) { - // Check the evaluation order - unsigned i = 0; - auto composed = - make_step(this, i, 0) >> make_step(this, i, 1) >> make_step(this, i, 2); - EXPECT_ASYNC_RESULT(std::move(composed)); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_chars) { - auto chain = this->supply('a') >> this->supply('b') >> this->supply('c'); - EXPECT_ASYNC_RESULT(std::move(chain), 'a', 'b', 'c'); -} - */ - -TYPED_TEST(single_dimension_tests, is_logical_all_connectable) { - - { - // Check the evaluation order - unsigned i = 0; - auto composed = - make_step(this, i, 0) && make_step(this, i, 1) && make_step(this, i, 2); - EXPECT_ASYNC_RESULT(std::move(composed)); - } -} +#endif // TEST_CONTINUABLE_CONNECTION_HPP__ diff --git a/test/unit-test/multi/test-continuable-connection-all.cpp b/test/unit-test/multi/test-continuable-connection-all.cpp index 6da74a4..6e5a504 100644 --- a/test/unit-test/multi/test-continuable-connection-all.cpp +++ b/test/unit-test/multi/test-continuable-connection-all.cpp @@ -21,84 +21,29 @@ SOFTWARE. **/ +#include #include -template -void test_all_seq_op(Supplier&& supply, OperatorConnector&& op) { - { - auto chain = op(supply(), supply()); - EXPECT_ASYNC_RESULT(std::move(chain)); - } - - { - auto chain = op(supply(1), supply(2)); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2); - } - - { - auto chain = op(supply(1, 2), supply(3, 4, 5)); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3, 4, 5); - } - - { - auto chain = op(supply(tag1{}), supply(tag2{}, tag3{})); - ASSERT_ASYNC_TYPES(std::move(chain), tag1, tag2, tag3); - } +TYPED_TEST(single_dimension_tests, is_op_all_connectable) { + test_all_seq_op( + [this](auto&&... args) { + return this->supply(std::forward(args)...); + }, + [](auto&& left, auto&& right) { + return std::forward(left) && + std::forward(right); + }); } -template -void test_all_seq_aggregate(Supplier&& supply, AggregateConnector&& ag) { - { - auto chain = ag(supply(1, 2), supply(3, 4)); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3, 4); - } +TYPED_TEST(single_dimension_tests, is_aggregate_all_connectable) { + test_all_seq_aggregate( + [this](auto&&... args) { + return this->supply(std::forward(args)...); + }, + [](auto&&... args) { + return cti::when_all(std::forward(args)...); + }); } -/* - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable) { - auto chain = this->supply() >> this->supply(); - EXPECT_ASYNC_RESULT(std::move(chain)); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_value) { - auto chain = this->supply(1) >> this->supply(2); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_when_seq) { - auto chain = cti::when_seq(this->supply(1), this->supply(2), this->supply(3)); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_duplicated_val) { - auto chain = this->supply(1, 2) >> this->supply(3, 4); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3, 4); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_tag) { - auto chain = this->supply(tag1{}, tag2{}) >> this->supply(tag1{}, tag2{}); - ASSERT_ASYNC_TYPES(std::move(chain), tag1, tag2, tag1, tag2); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_three_tags) { - auto chain = this->supply(tag1{}, tag2{}, tag3{}) >> - this->supply(tag1{}, tag2{}, tag3{}); - ASSERT_ASYNC_TYPES(std::move(chain), tag1, tag2, tag3, tag1, tag2, tag3); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_composed) { - // Check the evaluation order - unsigned i = 0; - auto composed = - make_step(this, i, 0) >> make_step(this, i, 1) >> make_step(this, i, 2); - EXPECT_ASYNC_RESULT(std::move(composed)); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_chars) { - auto chain = this->supply('a') >> this->supply('b') >> this->supply('c'); - EXPECT_ASYNC_RESULT(std::move(chain), 'a', 'b', 'c'); -} - */ TYPED_TEST(single_dimension_tests, is_logical_all_connectable) { diff --git a/test/unit-test/multi/test-continuable-connection-seq.cpp b/test/unit-test/multi/test-continuable-connection-seq.cpp index 004bfb2..f6810d0 100644 --- a/test/unit-test/multi/test-continuable-connection-seq.cpp +++ b/test/unit-test/multi/test-continuable-connection-seq.cpp @@ -21,37 +21,28 @@ SOFTWARE. **/ +#include #include -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable) { - auto chain = this->supply() >> this->supply(); - EXPECT_ASYNC_RESULT(std::move(chain)); +TYPED_TEST(single_dimension_tests, is_op_seq_connectable) { + test_all_seq_op( + [this](auto&&... args) { + return this->supply(std::forward(args)...); + }, + [](auto&& left, auto&& right) { + return std::forward(left) >> + std::forward(right); + }); } -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_value) { - auto chain = this->supply(1) >> this->supply(2); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_when_seq) { - auto chain = cti::when_seq(this->supply(1), this->supply(2), this->supply(3)); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_duplicated_val) { - auto chain = this->supply(1, 2) >> this->supply(3, 4); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3, 4); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_tag) { - auto chain = this->supply(tag1{}, tag2{}) >> this->supply(tag1{}, tag2{}); - ASSERT_ASYNC_TYPES(std::move(chain), tag1, tag2, tag1, tag2); -} - -TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_three_tags) { - auto chain = this->supply(tag1{}, tag2{}, tag3{}) >> - this->supply(tag1{}, tag2{}, tag3{}); - ASSERT_ASYNC_TYPES(std::move(chain), tag1, tag2, tag3, tag1, tag2, tag3); +TYPED_TEST(single_dimension_tests, is_aggregate_seq_connectable) { + test_all_seq_aggregate( + [this](auto&&... args) { + return this->supply(std::forward(args)...); + }, + [](auto&&... args) { + return cti::when_seq(std::forward(args)...); + }); } TYPED_TEST(single_dimension_tests, is_logical_seq_connectable_composed) {