Initial work on testing the new seq and all strategy

This commit is contained in:
Denis Blank 2018-03-08 13:22:49 +01:00
parent d59c0730b8
commit 087047e26d
3 changed files with 176 additions and 11 deletions

View File

@ -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-destruct.cpp
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-base-errors.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-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-all.cpp
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-connection-any.cpp ${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-connection-any.cpp
${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-connection-seq.cpp ${CMAKE_CURRENT_LIST_DIR}/multi/test-continuable-connection-seq.cpp

View File

@ -0,0 +1,112 @@
/*
Copyright(c) 2015 - 2018 Denis Blank <denis.blank at outlook dot com>
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 <test-continuable.hpp>
template <typename Supplier, typename OperatorConnector>
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 <typename Supplier, typename AggregateConnector>
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));
}
}

View File

@ -23,33 +23,85 @@
#include <test-continuable.hpp> #include <test-continuable.hpp>
TYPED_TEST(single_dimension_tests, is_logical_all_connectable) { template <typename Supplier, typename OperatorConnector>
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)); 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); 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); EXPECT_ASYNC_RESULT(std::move(chain), 1, 2, 3, 4, 5);
} }
{ {
auto chain = cti::when_all(this->supply(1, 2), this->supply(3, 4)); auto chain = op(supply(tag1{}), supply(tag2{}, tag3{}));
ASSERT_ASYNC_TYPES(std::move(chain), tag1, tag2, tag3);
}
}
template <typename Supplier, typename AggregateConnector>
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); 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{}) && this->supply(tag2{}, tag3{}); auto chain = this->supply(tag1{}, tag2{}) >> this->supply(tag1{}, tag2{});
ASSERT_ASYNC_TYPES(std::move(chain), tag1, tag2, tag3); 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 // Check the evaluation order
unsigned i = 0; unsigned i = 0;