From 087047e26d0b428bf06471de157c0f4ab1b54bfc Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Thu, 8 Mar 2018 13:22:49 +0100 Subject: [PATCH] Initial work on testing the new seq and all strategy --- test/unit-test/CMakeLists.txt | 1 + .../test-continuable-connection-all-seq.hpp | 112 ++++++++++++++++++ .../multi/test-continuable-connection-all.cpp | 74 ++++++++++-- 3 files changed, 176 insertions(+), 11 deletions(-) create mode 100644 test/unit-test/multi/test-continuable-connection-all-seq.hpp diff --git a/test/unit-test/CMakeLists.txt b/test/unit-test/CMakeLists.txt index 4ebec5d..13ea7bd 100644 --- a/test/unit-test/CMakeLists.txt +++ b/test/unit-test/CMakeLists.txt @@ -43,6 +43,7 @@ foreach(STEP RANGE 4) ${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-base-destruct.cpp ${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-base-errors.cpp ${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-base-partial.cpp + ${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-connection-all-seq.hpp ${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-connection-all.cpp ${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-connection-any.cpp ${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-connection-seq.cpp diff --git a/test/unit-test/multi/test-continuable-connection-all-seq.hpp b/test/unit-test/multi/test-continuable-connection-all-seq.hpp new file mode 100644 index 0000000..6da74a4 --- /dev/null +++ b/test/unit-test/multi/test-continuable-connection-all-seq.hpp @@ -0,0 +1,112 @@ + +/* + Copyright(c) 2015 - 2018 Denis Blank + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files(the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and / or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions : + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. +**/ + +#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); + } +} + +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_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)); + } +} diff --git a/test/unit-test/multi/test-continuable-connection-all.cpp b/test/unit-test/multi/test-continuable-connection-all.cpp index cae5413..6da74a4 100644 --- a/test/unit-test/multi/test-continuable-connection-all.cpp +++ b/test/unit-test/multi/test-continuable-connection-all.cpp @@ -23,32 +23,84 @@ #include -TYPED_TEST(single_dimension_tests, is_logical_all_connectable) { - +template +void test_all_seq_op(Supplier&& supply, OperatorConnector&& op) { { - auto chain = this->supply() && this->supply(); + auto chain = op(supply(), supply()); EXPECT_ASYNC_RESULT(std::move(chain)); } { - auto chain = this->supply(1) && this->supply(2); + auto chain = op(supply(1), supply(2)); EXPECT_ASYNC_RESULT(std::move(chain), 1, 2); } { - auto chain = this->supply(1, 2) && this->supply(3, 4, 5); + auto chain = op(supply(1, 2), supply(3, 4, 5)); EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3, 4, 5); } { - auto chain = cti::when_all(this->supply(1, 2), this->supply(3, 4)); - EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3, 4); - } - - { - auto chain = this->supply(tag1{}) && this->supply(tag2{}, tag3{}); + auto chain = op(supply(tag1{}), supply(tag2{}, tag3{})); ASSERT_ASYNC_TYPES(std::move(chain), tag1, tag2, tag3); } +} + +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_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