From e0178e378c9996316a1ee7aa74cebc1143050822 Mon Sep 17 00:00:00 2001 From: zhekemist Date: Sun, 18 Aug 2024 23:15:13 +0200 Subject: [PATCH] Make minor adjustments in unit tests * Add missing headers * Update copyright comments * Make formatting and naming more consistent --- .../findfirstof_more_searched_for.cpp | 2 +- .../regressions/includes_empty_ranges.cpp | 1 + .../mismatch_differently_sized_ranges.cpp | 5 +- .../regressions/search_larger_2nd_range.cpp | 1 + .../algorithms/adjacentdifference_tests.hpp | 58 ++++++++++------- .../unit/algorithms/adjacentfind_tests.hpp | 30 +++++---- .../tests/unit/algorithms/all_of_tests.hpp | 7 ++- .../tests/unit/algorithms/any_of_tests.hpp | 9 +-- .../tests/unit/algorithms/copy_tests.hpp | 2 + .../tests/unit/algorithms/copyn_tests.hpp | 1 + .../tests/unit/algorithms/count_tests.hpp | 2 + .../tests/unit/algorithms/countif_tests.hpp | 2 + .../tests/unit/algorithms/destroy_tests.hpp | 4 +- .../tests/unit/algorithms/destroyn_sender.cpp | 2 + .../unit/algorithms/ends_with_sender.cpp | 1 + .../tests/unit/algorithms/equal_binary.cpp | 1 + .../unit/algorithms/equal_binary_tests.hpp | 2 + .../tests/unit/algorithms/equal_tests.hpp | 2 + .../tests/unit/algorithms/fill_tests.hpp | 2 + .../tests/unit/algorithms/filln_tests.hpp | 2 + .../tests/unit/algorithms/find_tests.hpp | 16 ++--- .../tests/unit/algorithms/findend_tests.hpp | 57 ++++++++++------- .../unit/algorithms/findfirstof_tests.hpp | 2 + .../tests/unit/algorithms/findif_tests.hpp | 2 + .../tests/unit/algorithms/findifnot_tests.hpp | 2 + .../unit/algorithms/foreach_scheduler.cpp | 12 ++-- .../tests/unit/algorithms/foreach_sender.cpp | 10 +-- .../tests/unit/algorithms/foreach_tests.hpp | 3 +- .../tests/unit/algorithms/generate_tests.hpp | 4 +- .../tests/unit/algorithms/generaten_tests.hpp | 4 +- .../tests/unit/algorithms/includes_sender.cpp | 1 + .../tests/unit/algorithms/is_heap_tests.hpp | 4 ++ .../unit/algorithms/is_partitioned_sender.cpp | 6 +- .../tests/unit/algorithms/is_sorted_tests.hpp | 7 ++- .../algorithms/is_sorted_until_sender.cpp | 6 +- .../lexicographical_compare_sender.cpp | 26 ++++---- .../unit/algorithms/max_element_sender.cpp | 58 ++++++++++------- .../unit/algorithms/min_element_sender.cpp | 59 ++++++++++------- .../unit/algorithms/minmax_element_sender.cpp | 63 +++++++++++-------- .../unit/algorithms/mismatch_binary_tests.hpp | 6 +- .../tests/unit/algorithms/mismatch_tests.hpp | 5 +- .../tests/unit/algorithms/move_sender.cpp | 1 + .../tests/unit/algorithms/none_of_sender.cpp | 1 + .../tests/unit/algorithms/none_of_tests.hpp | 3 +- .../tests/unit/algorithms/reduce_tests.hpp | 13 ++-- .../tests/unit/algorithms/remove_tests.hpp | 4 +- .../algorithms/replace_copy_if_sender.cpp | 5 +- .../unit/algorithms/replace_copy_sender.cpp | 5 +- .../tests/unit/algorithms/replace_if.cpp | 2 +- .../unit/algorithms/replace_if_sender.cpp | 5 +- .../tests/unit/algorithms/replace_sender.cpp | 5 +- .../unit/algorithms/reverse_copy_sender.cpp | 5 +- .../unit/algorithms/rotate_copy_sender.cpp | 2 + .../tests/unit/algorithms/search_sender.cpp | 13 ++-- .../unit/algorithms/starts_with_sender.cpp | 7 ++- .../unit/algorithms/swapranges_sender.cpp | 2 + .../algorithms/transform_binary2_tests.hpp | 4 +- .../algorithms/transform_binary_tests.hpp | 4 +- .../transform_reduce_binary_tests.hpp | 16 ++--- .../algorithms/transform_reduce_sender.cpp | 24 +++---- .../tests/unit/algorithms/transform_tests.hpp | 3 +- .../tests/unit/algorithms/unique_tests.hpp | 12 ++-- 62 files changed, 388 insertions(+), 237 deletions(-) diff --git a/libs/core/algorithms/tests/regressions/findfirstof_more_searched_for.cpp b/libs/core/algorithms/tests/regressions/findfirstof_more_searched_for.cpp index da4384bbfad3..4d5932f0cf5d 100644 --- a/libs/core/algorithms/tests/regressions/findfirstof_more_searched_for.cpp +++ b/libs/core/algorithms/tests/regressions/findfirstof_more_searched_for.cpp @@ -8,7 +8,7 @@ // is smaller than the range of the searched elements. #include -#include +#include #include #include diff --git a/libs/core/algorithms/tests/regressions/includes_empty_ranges.cpp b/libs/core/algorithms/tests/regressions/includes_empty_ranges.cpp index dff47939d483..63a81223e11c 100644 --- a/libs/core/algorithms/tests/regressions/includes_empty_ranges.cpp +++ b/libs/core/algorithms/tests/regressions/includes_empty_ranges.cpp @@ -9,6 +9,7 @@ // is empty. #include +#include #include #include diff --git a/libs/core/algorithms/tests/regressions/mismatch_differently_sized_ranges.cpp b/libs/core/algorithms/tests/regressions/mismatch_differently_sized_ranges.cpp index ee3f41b705c1..594a92c46795 100644 --- a/libs/core/algorithms/tests/regressions/mismatch_differently_sized_ranges.cpp +++ b/libs/core/algorithms/tests/regressions/mismatch_differently_sized_ranges.cpp @@ -9,6 +9,7 @@ // proceed as usual and not just return the first iterators of both ranges. #include +#include #include #include @@ -27,8 +28,8 @@ void mismatch_differently_size_ranges_test() auto expected = std::mismatch(a.begin(), a.end(), b.begin(), b.end()); - //HPX_TEST((a.begin() + 2) == result.first); - //HPX_TEST((b.begin() + 2) == result.second); + HPX_TEST((a.begin() + 2) == result.first); + HPX_TEST((b.begin() + 2) == result.second); HPX_TEST(result == expected); } diff --git a/libs/core/algorithms/tests/regressions/search_larger_2nd_range.cpp b/libs/core/algorithms/tests/regressions/search_larger_2nd_range.cpp index f5a5c84efdbb..29a8b8f29bdb 100644 --- a/libs/core/algorithms/tests/regressions/search_larger_2nd_range.cpp +++ b/libs/core/algorithms/tests/regressions/search_larger_2nd_range.cpp @@ -8,6 +8,7 @@ // past-the-end iterator of the second range. #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/adjacentdifference_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/adjacentdifference_tests.hpp index f1dd36b7d8ef..9cf3e15e9d74 100644 --- a/libs/core/algorithms/tests/unit/algorithms/adjacentdifference_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/adjacentdifference_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2015 Daniel Bourgeois // Copyright (c) 2022 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,8 +8,8 @@ #pragma once -#include #include +#include #include #include #include @@ -87,37 +88,46 @@ void test_adjacent_difference_sender(Policy l, ExPolicy&& policy) auto exec = ex::explicit_scheduler_executor(scheduler_t(l)); - auto result = - tt::sync_wait(ex::just(std::begin(c), std::end(c), std::begin(d)) | - hpx::adjacent_difference(policy.on(exec))); + { + auto snd_result = + tt::sync_wait(ex::just(std::begin(c), std::end(c), std::begin(d)) | + hpx::adjacent_difference(policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - std::adjacent_difference(std::begin(c), std::end(c), std::begin(d_ans)); + std::adjacent_difference(std::begin(c), std::end(c), std::begin(d_ans)); - HPX_TEST(std::equal(std::begin(d), std::end(d), std::begin(d_ans), - [](auto lhs, auto rhs) { return lhs == rhs; })); - HPX_TEST(std::end(d) == hpx::get<0>(*result)); + HPX_TEST(std::equal(std::begin(d), std::end(d), std::begin(d_ans), + [](auto lhs, auto rhs) { return lhs == rhs; })); + HPX_TEST(std::end(d) == result); + } - // 1st edge case: first == last - result = - tt::sync_wait(ex::just(std::begin(c), std::begin(c), std::begin(d)) | - hpx::adjacent_difference(policy.on(exec))); + { + // edge case: empty range + auto snd_result = + tt::sync_wait(ex::just(std::begin(c), std::begin(c), std::begin(d)) | + hpx::adjacent_difference(policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - std::adjacent_difference(std::begin(c), std::begin(c), std::begin(d_ans)); + std::adjacent_difference(std::begin(c), std::begin(c), std::begin(d_ans)); - HPX_TEST(std::begin(d) == hpx::get<0>(*result)); - HPX_TEST(std::equal(std::begin(d), std::end(d), std::begin(d_ans), - [](auto lhs, auto rhs) { return lhs == rhs; })); + HPX_TEST(std::begin(d) == result); + HPX_TEST(std::equal(std::begin(d), std::end(d), std::begin(d_ans), + [](auto lhs, auto rhs) { return lhs == rhs; })); + } - // 2nd edge case: first + 1 == last - result = - tt::sync_wait(ex::just(std::begin(c), ++std::begin(c), std::begin(d)) | - hpx::adjacent_difference(policy.on(exec))); + { + // edge case: range of size one + auto snd_result = + tt::sync_wait(ex::just(std::begin(c), ++std::begin(c), std::begin(d)) | + hpx::adjacent_difference(policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - std::adjacent_difference(std::begin(c), ++std::begin(c), std::begin(d_ans)); + std::adjacent_difference(std::begin(c), ++std::begin(c), std::begin(d_ans)); - HPX_TEST(std::equal(std::begin(d), std::end(d), std::begin(d_ans), - [](auto lhs, auto rhs) { return lhs == rhs; })); - HPX_TEST(++std::begin(d) == hpx::get<0>(*result)); + HPX_TEST(std::equal(std::begin(d), std::end(d), std::begin(d_ans), + [](auto lhs, auto rhs) { return lhs == rhs; })); + HPX_TEST(++std::begin(d) == result); + } } #endif diff --git a/libs/core/algorithms/tests/unit/algorithms/adjacentfind_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/adjacentfind_tests.hpp index 46a9a7602ddd..4231a7bbfb26 100644 --- a/libs/core/algorithms/tests/unit/algorithms/adjacentfind_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/adjacentfind_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014 Grant Mercer +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,6 +9,7 @@ #include #include +#include #include #include @@ -79,21 +81,27 @@ void test_adjacent_find_sender( auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - auto snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c))) | - hpx::adjacent_find(ex_policy.on(exec))); + { + auto snd_result = + tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c))) | + hpx::adjacent_find(ex_policy.on(exec))); - iterator index = hpx::get<0>(*snd_result); - base_iterator test_index = std::begin(c) + random_pos; + iterator index = hpx::get<0>(*snd_result); + base_iterator test_index = std::begin(c) + random_pos; - HPX_TEST(index == iterator(test_index)); + HPX_TEST(index == iterator(test_index)); + } - // edge case: first == last - snd_result = tt::sync_wait( - ex::just(iterator(std::begin(c)), iterator(std::begin(c))) | - hpx::adjacent_find(ex_policy.on(exec))); + { + // edge case: empty range + + auto snd_result = tt::sync_wait( + ex::just(iterator(std::begin(c)), iterator(std::begin(c))) | + hpx::adjacent_find(ex_policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - HPX_TEST(iterator(std::begin(c)) == hpx::get<0>(*snd_result)); + HPX_TEST(iterator(std::begin(c)) == result); + } } #endif diff --git a/libs/core/algorithms/tests/unit/algorithms/all_of_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/all_of_tests.hpp index 55e647388d51..e229122b5633 100644 --- a/libs/core/algorithms/tests/unit/algorithms/all_of_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/all_of_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,6 +8,7 @@ #pragma once #include +#include #include #include #include @@ -82,18 +84,17 @@ void test_all_of_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) namespace tt = hpx::this_thread::experimental; using scheduler_t = ex::thread_pool_policy_scheduler; + auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); + int iseq[] = {0, 23, 10007}; for (int i : iseq) { std::vector c = test::fill_all_any_none(10007, i); //-V106 - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::end(c)), [](auto v) { return v != 0; }) | hpx::all_of(ex_policy.on(exec))); - bool result = hpx::get<0>(*snd_result); // verify values diff --git a/libs/core/algorithms/tests/unit/algorithms/any_of_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/any_of_tests.hpp index eb83b57a6138..03435c5dd768 100644 --- a/libs/core/algorithms/tests/unit/algorithms/any_of_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/any_of_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,8 +7,9 @@ #pragma once -#include #include +#include +#include #include #include #include @@ -83,18 +85,17 @@ void test_any_of_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) using scheduler_t = ex::thread_pool_policy_scheduler; + auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); + int iseq[] = {0, 23, 10007}; for (int i : iseq) { std::vector c = test::fill_all_any_none(10007, i); //-V106 - auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::end(c)), [](auto v) { return v != 0; }) | hpx::any_of(ex_policy.on(exec))); - bool result = hpx::get<0>(*snd_result); // verify values diff --git a/libs/core/algorithms/tests/unit/algorithms/copy_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/copy_tests.hpp index 7a38b389c835..1e678fb6d29c 100644 --- a/libs/core/algorithms/tests/unit/algorithms/copy_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/copy_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2021 Srinivas Yadav // Copyright (c) 2014 Grant Mercer +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,6 +9,7 @@ #pragma once #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/copyn_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/copyn_tests.hpp index 0be1d08c9edb..316541d19db4 100644 --- a/libs/core/algorithms/tests/unit/algorithms/copyn_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/copyn_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2021 Srinivas Yadav // Copyright (c) 2014 Grant Mercer +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/libs/core/algorithms/tests/unit/algorithms/count_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/count_tests.hpp index 77198a999ef0..27062db0d269 100644 --- a/libs/core/algorithms/tests/unit/algorithms/count_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/count_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2016 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,6 +8,7 @@ #pragma once #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/countif_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/countif_tests.hpp index 8f4d4db06c5d..3dd04ff8be96 100644 --- a/libs/core/algorithms/tests/unit/algorithms/countif_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/countif_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2016 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,6 +8,7 @@ #pragma once #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/destroy_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/destroy_tests.hpp index 970e6b0d80fd..d1cdba2116c7 100644 --- a/libs/core/algorithms/tests/unit/algorithms/destroy_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/destroy_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,8 +7,9 @@ #pragma once -#include + #include +#include #include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/destroyn_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/destroyn_sender.cpp index 5d0f08c35aaa..9330c89a0527 100644 --- a/libs/core/algorithms/tests/unit/algorithms/destroyn_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/destroyn_sender.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2014-2020 Hartmut Kaiser // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 @@ -5,6 +6,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/ends_with_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/ends_with_sender.cpp index cfe75c77d739..55a842ae6f0e 100644 --- a/libs/core/algorithms/tests/unit/algorithms/ends_with_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/ends_with_sender.cpp @@ -7,6 +7,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/equal_binary.cpp b/libs/core/algorithms/tests/unit/algorithms/equal_binary.cpp index f1598752986e..0396e8cbc05b 100644 --- a/libs/core/algorithms/tests/unit/algorithms/equal_binary.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/equal_binary.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/libs/core/algorithms/tests/unit/algorithms/equal_binary_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/equal_binary_tests.hpp index 0ed54c46d791..9754a0934e99 100644 --- a/libs/core/algorithms/tests/unit/algorithms/equal_binary_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/equal_binary_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,6 +8,7 @@ #pragma once #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/equal_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/equal_tests.hpp index a1e53c46f161..81ca559e8e8a 100644 --- a/libs/core/algorithms/tests/unit/algorithms/equal_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/equal_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,6 +8,7 @@ #pragma once #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/fill_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/fill_tests.hpp index c1af2876ef2a..82423d46762e 100644 --- a/libs/core/algorithms/tests/unit/algorithms/fill_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/fill_tests.hpp @@ -1,6 +1,7 @@ // Copyright (c) 2014 Grant Mercer // Copyright (c) 2017-2020 Hartmut Kaiser // Copyright (c) 2021 Srinivas Yadav +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -9,6 +10,7 @@ #pragma once #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/filln_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/filln_tests.hpp index f33ee5d945dd..829e11e5ca14 100644 --- a/libs/core/algorithms/tests/unit/algorithms/filln_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/filln_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2014 Grant Mercer // Copyright (c) 2017-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,6 +9,7 @@ #pragma once #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/find_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/find_tests.hpp index aef2a4a4e38a..4714f9169f7e 100644 --- a/libs/core/algorithms/tests/unit/algorithms/find_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/find_tests.hpp @@ -1,6 +1,7 @@ // Copyright (c) 2021 Srinivas Yadav // Copyright (c) 2014 Grant Mercer // Copyright (c) 2022 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,8 +9,8 @@ #pragma once -#include #include +#include #include #include #include @@ -102,8 +103,8 @@ void test_find_explicit_sender_direct(Policy l, ExPolicy&& policy, IteratorTag) template void test_find_explicit_sender(Policy l, ExPolicy&& policy, IteratorTag) { - static_assert(hpx::is_execution_policy_v, - "hpx::is_execution_policy_v"); + static_assert(hpx::is_async_execution_policy_v, + "hpx::is_async_execution_policy_v"); typedef std::vector::iterator base_iterator; typedef test::test_iterator iterator; @@ -158,8 +159,8 @@ void test_find_async(ExPolicy&& p, IteratorTag) template void test_find_explicit_sender_direct_async(Policy l, ExPolicy&& p, IteratorTag) { - static_assert(hpx::is_execution_policy_v, - "hpx::is_execution_policy_v"); + static_assert(hpx::is_async_execution_policy_v, + "hpx::is_async_execution_policy_v"); typedef std::vector::iterator base_iterator; typedef test::test_iterator iterator; @@ -176,13 +177,14 @@ void test_find_explicit_sender_direct_async(Policy l, ExPolicy&& p, IteratorTag) auto exec = ex::explicit_scheduler_executor(scheduler_t(l)); - auto result = tt::sync_wait(hpx::find( + auto snd_result = tt::sync_wait(hpx::find( p.on(exec), iterator(std::begin(c)), iterator(std::end(c)), int(1))); + auto result = hpx::get<0>(*snd_result); // create iterator at position of value to be found base_iterator test_index = std::begin(c) + c.size() / 2; - HPX_TEST(hpx::get<0>(*result) == iterator(test_index)); + HPX_TEST(result == iterator(test_index)); } #endif diff --git a/libs/core/algorithms/tests/unit/algorithms/findend_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/findend_tests.hpp index bdc8d54daa16..82fd100de54a 100644 --- a/libs/core/algorithms/tests/unit/algorithms/findend_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/findend_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2021 Srinivas Yadav -// copyright (c) 2014 Grant Mercer +// Copyright (c) 2014 Grant Mercer +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,6 +9,7 @@ #pragma once #include +#include #include #include @@ -105,31 +107,43 @@ void test_find_end1_sender( auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - auto snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), - std::begin(h), std::end(h)) | - hpx::find_end(ex_policy.on(exec))); + { + auto snd_result = + tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), + std::begin(h), std::end(h)) | + hpx::find_end(ex_policy.on(exec))); - iterator index = hpx::get<0>(*snd_result); + iterator index = hpx::get<0>(*snd_result); - iterator test_index = std::find_end(iterator(std::begin(c)), - iterator(std::end(c)), std::begin(h), std::end(h)); + iterator test_index = std::find_end(iterator(std::begin(c)), + iterator(std::end(c)), std::begin(h), std::end(h)); - HPX_TEST(index == test_index); + HPX_TEST(index == test_index); + } - // 1st edge case: first2 == end2 - snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), - std::begin(h), std::begin(h)) | - hpx::find_end(ex_policy.on(exec))); - HPX_TEST(iterator(std::end(c)) == hpx::get<0>(*snd_result)); + { + // edge case: first2 == end2 - // 2nd edge case: distance(first2, end2) > distance(first1, end1) - snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::begin(c)), - std::begin(h), std::end(h)) | - hpx::find_end(ex_policy.on(exec))); - HPX_TEST(iterator(std::begin(c)) == hpx::get<0>(*snd_result)); + auto snd_result = + tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), + std::begin(h), std::begin(h)) | + hpx::find_end(ex_policy.on(exec))); + auto result = hpx::get<0>(*snd_result); + + HPX_TEST(iterator(std::end(c)) == result); + } + + { + // edge case: distance(first2, end2) > distance(first1, end1) + + auto snd_result = + tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::begin(c)), + std::begin(h), std::end(h)) | + hpx::find_end(ex_policy.on(exec))); + auto result = hpx::get<0>(*snd_result); + + HPX_TEST(iterator(std::begin(c)) == result); + } } #endif @@ -245,7 +259,6 @@ void test_find_end2_sender( tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), std::begin(h), std::end(h)) | hpx::find_end(ex_policy.on(exec))); - iterator index = hpx::get<0>(*snd_result); iterator test_index = std::find_end(iterator(std::begin(c)), diff --git a/libs/core/algorithms/tests/unit/algorithms/findfirstof_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/findfirstof_tests.hpp index 21b6139223ed..97cff1921a5f 100644 --- a/libs/core/algorithms/tests/unit/algorithms/findfirstof_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/findfirstof_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2021 Srinivas Yadav // copyright (c) 2014 Grant Mercer +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,6 +9,7 @@ #pragma once #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/findif_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/findif_tests.hpp index 678d9ad7294b..bea933478008 100644 --- a/libs/core/algorithms/tests/unit/algorithms/findif_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/findif_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2021 Srinivas Yadav // copyright (c) 2014 Grant Mercer +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,6 +9,7 @@ #pragma once #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/findifnot_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/findifnot_tests.hpp index 6cacbf3b0a08..2607e4cd9bf6 100644 --- a/libs/core/algorithms/tests/unit/algorithms/findifnot_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/findifnot_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2021 Srinivas Yadav // copyright (c) 2014 Grant Mercer +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,6 +9,7 @@ #pragma once #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/foreach_scheduler.cpp b/libs/core/algorithms/tests/unit/algorithms/foreach_scheduler.cpp index 15b6a98541a0..7590baff761e 100644 --- a/libs/core/algorithms/tests/unit/algorithms/foreach_scheduler.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/foreach_scheduler.cpp @@ -95,10 +95,12 @@ void test_for_each_execute_on_async(Policy l, ExPolicy&& policy, IteratorTag) using scheduler_t = ex::thread_pool_policy_scheduler; - auto result = tt::sync_wait(hpx::for_each( + auto snd_result = tt::sync_wait(hpx::for_each( ex::execute_on(scheduler_t(l), std::forward(policy)), iterator(std::begin(c)), iterator(std::end(c)), f)); - HPX_TEST(hpx::get<0>(*result) == iterator(std::end(c))); + auto result = hpx::get<0>(*snd_result); + + HPX_TEST(result == iterator(std::end(c))); // verify values std::size_t count = 0; @@ -129,11 +131,13 @@ void test_for_each_execute_on_sender(Policy l, ExPolicy&& policy, IteratorTag) using scheduler_t = ex::thread_pool_policy_scheduler; - auto result = tt::sync_wait( + auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::end(c)), f) | hpx::for_each( ex::execute_on(scheduler_t(l), std::forward(policy)))); - HPX_TEST(hpx::get<0>(*result) == iterator(std::end(c))); + auto result = hpx::get<0>(*result); + + HPX_TEST(result == iterator(std::end(c))); // verify values std::size_t count = 0; diff --git a/libs/core/algorithms/tests/unit/algorithms/foreach_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/foreach_sender.cpp index 64c9cef83225..2944aeb5e5c5 100644 --- a/libs/core/algorithms/tests/unit/algorithms/foreach_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/foreach_sender.cpp @@ -74,10 +74,11 @@ void test_for_each_explicit_sender_direct_async( auto exec = ex::explicit_scheduler_executor(scheduler_t(l)); - auto result = tt::sync_wait(hpx::for_each( + auto snd_result = tt::sync_wait(hpx::for_each( policy.on(exec), iterator(std::begin(c)), iterator(std::end(c)), f)); + auto result = hpx::get<0>(*snd_result); - HPX_TEST(hpx::get<0>(*result) == iterator(std::end(c))); + HPX_TEST(result == iterator(std::end(c))); // verify values std::size_t count = 0; @@ -110,11 +111,12 @@ void test_for_each_explicit_sender(Policy l, ExPolicy&& policy, IteratorTag) auto exec = ex::explicit_scheduler_executor(scheduler_t(l)); - auto result = tt::sync_wait( + auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::end(c)), f) | hpx::for_each(policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - HPX_TEST(hpx::get<0>(*result) == iterator(std::end(c))); + HPX_TEST(result == iterator(std::end(c))); // verify values std::size_t count = 0; diff --git a/libs/core/algorithms/tests/unit/algorithms/foreach_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/foreach_tests.hpp index a919f8e83547..3ef773baa1aa 100644 --- a/libs/core/algorithms/tests/unit/algorithms/foreach_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/foreach_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2023 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,8 +7,8 @@ #pragma once -#include #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/generate_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/generate_tests.hpp index 083d4b9c736d..cac72cba3056 100644 --- a/libs/core/algorithms/tests/unit/algorithms/generate_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/generate_tests.hpp @@ -1,6 +1,7 @@ // Copyright (c) 2014 Grant Mercer // Copyright (c) 2020 Hartmut Kaiser // Copyright (c) 2021 Srinivas Yadav +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,8 +9,9 @@ #pragma once -#include #include +#include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/generaten_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/generaten_tests.hpp index 493dd4ec76ae..d4b18cddb0ec 100644 --- a/libs/core/algorithms/tests/unit/algorithms/generaten_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/generaten_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2014 Grant Mercer // Copyright (c) 2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,8 +8,9 @@ #pragma once -#include #include +#include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/includes_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/includes_sender.cpp index 9f92afdb8d75..1727a9bfdb9b 100644 --- a/libs/core/algorithms/tests/unit/algorithms/includes_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/includes_sender.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2014-2020 Hartmut Kaiser // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 diff --git a/libs/core/algorithms/tests/unit/algorithms/is_heap_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/is_heap_tests.hpp index f73212399556..5dba32d5834b 100644 --- a/libs/core/algorithms/tests/unit/algorithms/is_heap_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/is_heap_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2017 Taeguk Kwon // Copyright (c) 2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,6 +9,7 @@ #pragma once #include +#include #include #include @@ -154,6 +156,7 @@ void test_is_heap_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) namespace ex = hpx::execution::experimental; namespace tt = hpx::this_thread::experimental; using scheduler_t = ex::thread_pool_policy_scheduler; + auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); std::vector c(10007); @@ -218,6 +221,7 @@ void test_is_heap_until_sender( namespace ex = hpx::execution::experimental; namespace tt = hpx::this_thread::experimental; using scheduler_t = ex::thread_pool_policy_scheduler; + auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); std::vector c(10007); diff --git a/libs/core/algorithms/tests/unit/algorithms/is_partitioned_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/is_partitioned_sender.cpp index 3e323d9d4c44..2deafe196fa1 100644 --- a/libs/core/algorithms/tests/unit/algorithms/is_partitioned_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/is_partitioned_sender.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2015 Daniel Bourgeois // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 @@ -5,6 +6,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include @@ -56,7 +58,7 @@ void test_is_partitioned_sender( } { - // 1st edge case: first == last + // edge case: empty range auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::begin(c)), [](std::size_t) { return true; }) | @@ -68,7 +70,7 @@ void test_is_partitioned_sender( } { - // 2nd edge case: first + 1 == last + // edge case: range of length 1 auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(++std::begin(c)), [](std::size_t) { return true; }) | diff --git a/libs/core/algorithms/tests/unit/algorithms/is_sorted_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/is_sorted_tests.hpp index 88b0bc64a30e..f62cf44ed611 100644 --- a/libs/core/algorithms/tests/unit/algorithms/is_sorted_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/is_sorted_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2015 Daniel Bourgeois +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,8 +7,8 @@ #pragma once -#include #include +#include #include #include @@ -454,7 +455,7 @@ void test_is_sorted_sender( } { - // 1st edge case: first == last + // edge case: empty range auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::begin(c))) | hpx::is_sorted(ex_policy.on(exec))); @@ -465,7 +466,7 @@ void test_is_sorted_sender( } { - // 2nd edge case: first + 1 == last + // edge case: range of size 1 auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(++std::begin(c))) | hpx::is_sorted(ex_policy.on(exec))); diff --git a/libs/core/algorithms/tests/unit/algorithms/is_sorted_until_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/is_sorted_until_sender.cpp index 58ae91a05c13..1b8110561a50 100644 --- a/libs/core/algorithms/tests/unit/algorithms/is_sorted_until_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/is_sorted_until_sender.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2015 Daniel Bourgeois // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 @@ -5,6 +6,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include @@ -53,7 +55,7 @@ void test_is_sorted_until_sender( } { - // 1st edge case: first == last + // edge case: empty range auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::begin(c))) | hpx::is_sorted_until(ex_policy.on(exec))); @@ -64,7 +66,7 @@ void test_is_sorted_until_sender( } { - // 2nd edge case: first + 1 == last + // edge case: range of size 1 auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(++std::begin(c))) | hpx::is_sorted_until(ex_policy.on(exec))); diff --git a/libs/core/algorithms/tests/unit/algorithms/lexicographical_compare_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/lexicographical_compare_sender.cpp index 97bbcc3377df..41ae80004357 100644 --- a/libs/core/algorithms/tests/unit/algorithms/lexicographical_compare_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/lexicographical_compare_sender.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2014 Grant Mercer // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 @@ -5,6 +6,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include @@ -57,39 +59,39 @@ void test_lexicographical_compare_sender( } { - // edge case: first1 == end1 && first2 != end2 + // edge case: only first range is empty + auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::begin(c)), std::begin(d), std::end(d)) | hpx::lexicographical_compare(ex_policy.on(exec))); + bool result = hpx::get<0>(*snd_result); - bool res = hpx::get<0>(*snd_result); - - HPX_TEST(res); + HPX_TEST(result); } { - // edge case: first1 != end1 && first2 == end2 + // edge case: only second range is empty + auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::end(c)), std::begin(d), std::begin(d)) | hpx::lexicographical_compare(ex_policy.on(exec))); + bool result = hpx::get<0>(*snd_result); - bool res = hpx::get<0>(*snd_result); - - HPX_TEST(!res); + HPX_TEST(!result); } { - // edge case: first1 == end1 && first2 == end2 + // edge case: both ranges are empty + auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::begin(c)), std::begin(d), std::begin(d)) | hpx::lexicographical_compare(ex_policy.on(exec))); + bool result = hpx::get<0>(*snd_result); - bool res = hpx::get<0>(*snd_result); - - HPX_TEST(!res); + HPX_TEST(!result); } } diff --git a/libs/core/algorithms/tests/unit/algorithms/max_element_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/max_element_sender.cpp index 124143f99479..215a2170ab72 100644 --- a/libs/core/algorithms/tests/unit/algorithms/max_element_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/max_element_sender.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2014 Hartmut Kaiser // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 @@ -5,6 +6,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include @@ -39,36 +41,44 @@ void test_max_element_sender( auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - auto snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(end), - std::less()) | - hpx::max_element(ex_policy.on(exec))); + { + auto snd_result = + tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(end), + std::less()) | + hpx::max_element(ex_policy.on(exec))); + iterator result = hpx::get<0>(*snd_result); - iterator r = hpx::get<0>(*snd_result); - HPX_TEST(r != end); + HPX_TEST(result != end); - base_iterator ref = - std::max_element(std::begin(c), std::end(c), std::less()); - HPX_TEST(ref != ref_end); - HPX_TEST_EQ(*ref, *r); + base_iterator ref = + std::max_element(std::begin(c), std::end(c), std::less()); + HPX_TEST(ref != ref_end); + HPX_TEST_EQ(*ref, *result); + } - snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c))) | - hpx::max_element(ex_policy.on(exec))); + { + auto snd_result = + tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c))) | + hpx::max_element(ex_policy.on(exec))); + auto result = hpx::get<0>(*snd_result); + + HPX_TEST(result != end); - r = hpx::get<0>(*snd_result); - HPX_TEST(r != end); + auto ref = std::max_element(std::begin(c), std::end(c)); + HPX_TEST(ref != ref_end); + HPX_TEST_EQ(*ref, *result); + } - ref = std::max_element(std::begin(c), std::end(c)); - HPX_TEST(ref != ref_end); - HPX_TEST_EQ(*ref, *r); + { + // edge case: empty range + + auto snd_result = tt::sync_wait( + ex::just(iterator(std::begin(c)), iterator(std::begin(c))) | + hpx::max_element(ex_policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - // edge case: empty range - snd_result = tt::sync_wait( - ex::just(iterator(std::begin(c)), iterator(std::begin(c))) | - hpx::max_element(ex_policy.on(exec))); - r = hpx::get<0>(*snd_result); - HPX_TEST(r == iterator(std::begin(c))); + HPX_TEST(result == iterator(std::begin(c))); + } } template diff --git a/libs/core/algorithms/tests/unit/algorithms/min_element_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/min_element_sender.cpp index 8966e6a0a0d2..0b27863b7e7a 100644 --- a/libs/core/algorithms/tests/unit/algorithms/min_element_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/min_element_sender.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2014 Hartmut Kaiser // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 @@ -5,6 +6,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include @@ -40,36 +42,45 @@ void test_min_element_sender( auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - auto snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(end), - std::less()) | - hpx::min_element(ex_policy.on(exec))); + { + auto snd_result = + tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(end), + std::less()) | + hpx::min_element(ex_policy.on(exec))); + iterator result = hpx::get<0>(*snd_result); - iterator r = hpx::get<0>(*snd_result); - HPX_TEST(r != end); + HPX_TEST(result != end); - base_iterator ref = - std::min_element(std::begin(c), std::end(c), std::less()); - HPX_TEST(ref != ref_end); - HPX_TEST_EQ(*ref, *r); - snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c))) | - hpx::min_element(ex_policy.on(exec))); + base_iterator ref = + std::min_element(std::begin(c), std::end(c), std::less()); + HPX_TEST(ref != ref_end); + HPX_TEST_EQ(*ref, *result); + } + + { + auto snd_result = + tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c))) | + hpx::min_element(ex_policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - r = hpx::get<0>(*snd_result); - HPX_TEST(r != end); + HPX_TEST(result != end); - ref = std::min_element(std::begin(c), std::end(c)); - HPX_TEST(ref != ref_end); - HPX_TEST_EQ(*ref, *r); + auto ref = std::min_element(std::begin(c), std::end(c)); + HPX_TEST(ref != ref_end); + HPX_TEST_EQ(*ref, *result); + } + + { + // edge case: empty range + + auto snd_result = tt::sync_wait( + ex::just(iterator(std::begin(c)), iterator(std::begin(c))) | + hpx::min_element(ex_policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - // edge case: empty range - snd_result = tt::sync_wait( - ex::just(iterator(std::begin(c)), iterator(std::begin(c))) | - hpx::min_element(ex_policy.on(exec))); - r = hpx::get<0>(*snd_result); - HPX_TEST(r == iterator(std::begin(c))); + HPX_TEST(result == iterator(std::begin(c))); + } } template diff --git a/libs/core/algorithms/tests/unit/algorithms/minmax_element_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/minmax_element_sender.cpp index ddb949b4ba86..ab73df6abb4e 100644 --- a/libs/core/algorithms/tests/unit/algorithms/minmax_element_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/minmax_element_sender.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2014-2016 Hartmut Kaiser // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 @@ -5,6 +6,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include @@ -41,42 +43,49 @@ void test_minmax_element_sender( auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); - auto snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(end), - std::less()) | - hpx::minmax_element(ex_policy.on(exec))); + { + auto snd_result = + tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(end), + std::less()) | + hpx::minmax_element(ex_policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - auto r = hpx::get<0>(*snd_result); - HPX_TEST(r.min != end && r.max != end); + HPX_TEST(result.min != end && result.max != end); - auto ref = std::minmax_element( - std::begin(c), std::end(c), std::less()); - HPX_TEST(ref.first != ref_end && ref.second != ref_end); + auto ref = std::minmax_element( + std::begin(c), std::end(c), std::less()); + HPX_TEST(ref.first != ref_end && ref.second != ref_end); - HPX_TEST_EQ(*ref.first, *r.min); - HPX_TEST_EQ(*ref.second, *r.max); + HPX_TEST_EQ(*ref.first, *result.min); + HPX_TEST_EQ(*ref.second, *result.max); + } - snd_result = - tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c))) | - hpx::minmax_element(ex_policy.on(exec))); + { + auto snd_result = + tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c))) | + hpx::minmax_element(ex_policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - r = hpx::get<0>(*snd_result); - HPX_TEST(r.min != end && r.max != end); + HPX_TEST(result.min != end && result.max != end); - ref = std::minmax_element(std::begin(c), std::end(c)); - HPX_TEST(ref.first != ref_end && ref.second != ref_end); + auto ref = std::minmax_element(std::begin(c), std::end(c)); + HPX_TEST(ref.first != ref_end && ref.second != ref_end); - HPX_TEST_EQ(*ref.first, *r.min); - HPX_TEST_EQ(*ref.second, *r.max); + HPX_TEST_EQ(*ref.first, *result.min); + HPX_TEST_EQ(*ref.second, *result.max); + } - // edge case: empty range - snd_result = tt::sync_wait( - ex::just(iterator(std::begin(c)), iterator(std::begin(c))) | - hpx::minmax_element(ex_policy.on(exec))); + { + // edge case: empty range + + auto snd_result = tt::sync_wait( + ex::just(iterator(std::begin(c)), iterator(std::begin(c))) | + hpx::minmax_element(ex_policy.on(exec))); + auto result = hpx::get<0>(*snd_result); - r = hpx::get<0>(*snd_result); - HPX_TEST( - r.min == iterator(std::begin(c)) && r.max == iterator(std::begin(c))); + HPX_TEST( + result.min == iterator(std::begin(c)) && result.max == iterator(std::begin(c))); + } } template diff --git a/libs/core/algorithms/tests/unit/algorithms/mismatch_binary_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/mismatch_binary_tests.hpp index f1f8ef044ba1..10e5fd4b99a7 100644 --- a/libs/core/algorithms/tests/unit/algorithms/mismatch_binary_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/mismatch_binary_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -512,7 +513,6 @@ void test_mismatch_binary1_sender( auto snd_result = tt::sync_wait(ex::just(begin1, end1, std::begin(c2), std::end(c2)) | hpx::mismatch(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); // verify values @@ -529,7 +529,6 @@ void test_mismatch_binary1_sender( auto snd_result = tt::sync_wait(ex::just(begin1, end1, std::begin(c2), std::end(c2)) | hpx::mismatch(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); // verify values @@ -569,7 +568,6 @@ void test_mismatch_binary2_sender( auto snd_result = tt::sync_wait(ex::just(begin1, end1, std::begin(c2), std::end(c2), std::equal_to<>()) | hpx::mismatch(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); // verify values @@ -586,7 +584,6 @@ void test_mismatch_binary2_sender( auto snd_result = tt::sync_wait(ex::just(begin1, end1, std::begin(c2), std::end(c2), std::equal_to<>()) | hpx::mismatch(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); // verify values @@ -603,7 +600,6 @@ void test_mismatch_binary2_sender( ex::just(iterator(std::begin(c1)), iterator(std::begin(c1)), std::begin(c2), std::end(c2), std::equal_to<>()) | hpx::mismatch(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); // verify values diff --git a/libs/core/algorithms/tests/unit/algorithms/mismatch_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/mismatch_tests.hpp index 306babdce10c..d8c342a2b613 100644 --- a/libs/core/algorithms/tests/unit/algorithms/mismatch_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/mismatch_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,6 +8,7 @@ #pragma once #include +#include #include #include @@ -508,7 +510,6 @@ void test_mismatch_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) { auto snd_result = tt::sync_wait(ex::just(begin1, end1, std::begin(c2)) | hpx::mismatch(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); // verify values @@ -526,7 +527,6 @@ void test_mismatch_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) auto snd_result = tt::sync_wait(ex::just(begin1, end1, std::begin(c2)) | hpx::mismatch(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); // verify values @@ -545,7 +545,6 @@ void test_mismatch_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) tt::sync_wait(ex::just(iterator(std::begin(c1)), iterator(std::begin(c1)), std::begin(c2)) | hpx::mismatch(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); // verify values diff --git a/libs/core/algorithms/tests/unit/algorithms/move_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/move_sender.cpp index 42e12f190987..b7bd0a9e086a 100644 --- a/libs/core/algorithms/tests/unit/algorithms/move_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/move_sender.cpp @@ -5,6 +5,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/none_of_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/none_of_sender.cpp index ffa6587ded64..6e54a1c19fa6 100644 --- a/libs/core/algorithms/tests/unit/algorithms/none_of_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/none_of_sender.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2024 Tobias Wukovitsch +// // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) diff --git a/libs/core/algorithms/tests/unit/algorithms/none_of_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/none_of_tests.hpp index 1a4f33b9eaf1..facf3b58a36a 100644 --- a/libs/core/algorithms/tests/unit/algorithms/none_of_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/none_of_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,6 +8,7 @@ #pragma once #include +#include #include #include #include @@ -93,7 +95,6 @@ void test_none_of_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) ex::just(iterator(std::begin(c)), iterator(std::end(c)), [](auto v) { return v != 0; }) | hpx::none_of(ex_policy.on(exec))); - bool result = hpx::get<0>(*snd_result); // verify values diff --git a/libs/core/algorithms/tests/unit/algorithms/reduce_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/reduce_tests.hpp index 3419c3bc8b52..d1c7c3b60bb1 100644 --- a/libs/core/algorithms/tests/unit/algorithms/reduce_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/reduce_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,6 +8,7 @@ #pragma once #include +#include #include #include @@ -369,21 +371,20 @@ void test_reduce_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::end(c)), val, op) | hpx::reduce(ex_policy.on(exec))); - - int r1 = hpx::get<0>(*snd_result); + int result = hpx::get<0>(*snd_result); // verify values - int r2 = std::accumulate(std::begin(c), std::end(c), val, op); - HPX_TEST_EQ(r1, r2); + int expected = std::accumulate(std::begin(c), std::end(c), val, op); + HPX_TEST_EQ(result, expected); } { auto snd_result = tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::begin(c)), val, op) | hpx::reduce(ex_policy.on(exec))); + int result = hpx::get<0>(*snd_result); - int res = hpx::get<0>(*snd_result); - HPX_TEST_EQ(res, val); + HPX_TEST_EQ(result, val); } } #endif diff --git a/libs/core/algorithms/tests/unit/algorithms/remove_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/remove_tests.hpp index 9a9d0edcdaac..a4d8e9dcb2a5 100644 --- a/libs/core/algorithms/tests/unit/algorithms/remove_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/remove_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2017-2018 Taeguk Kwon +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,6 +8,7 @@ #pragma once #include +#include #include #include #include @@ -757,8 +759,8 @@ void test_remove_if_sender( auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::end(c)), pred) | hpx::remove_if(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); + auto solution = std::remove_if(std::begin(d), std::end(d), pred); bool equality = diff --git a/libs/core/algorithms/tests/unit/algorithms/replace_copy_if_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/replace_copy_if_sender.cpp index 73af83532155..10df61881dcd 100644 --- a/libs/core/algorithms/tests/unit/algorithms/replace_copy_if_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/replace_copy_if_sender.cpp @@ -1,10 +1,13 @@ -// Copyright (c) 2024 Tobias Wukovitsch +// Copyright (c) 2014-2017 Hartmut Kaiser +// Copyright (c) 2021 Giannis Gonidelis +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/replace_copy_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/replace_copy_sender.cpp index e9a2a1bb4021..a46f960d8885 100644 --- a/libs/core/algorithms/tests/unit/algorithms/replace_copy_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/replace_copy_sender.cpp @@ -1,10 +1,13 @@ -// Copyright (c) 2024 Tobias Wukovitsch +// Copyright (c) 2014-2017 Hartmut Kaiser +// Copyright (c) 2021 Giannis Gonidelis +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/replace_if.cpp b/libs/core/algorithms/tests/unit/algorithms/replace_if.cpp index 0799cb82814a..e18e2818fa57 100644 --- a/libs/core/algorithms/tests/unit/algorithms/replace_if.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/replace_if.cpp @@ -1,5 +1,5 @@ // Copyright (c) 2014-2017 Hartmut Kaiser -// Copyright (c) 2921 Giannis Gonidelis +// Copyright (c) 2021 Giannis Gonidelis // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying diff --git a/libs/core/algorithms/tests/unit/algorithms/replace_if_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/replace_if_sender.cpp index a4c1401686cf..f5dd2b234433 100644 --- a/libs/core/algorithms/tests/unit/algorithms/replace_if_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/replace_if_sender.cpp @@ -1,10 +1,13 @@ -// Copyright (c) 2024 Tobias Wukovitsch +// Copyright (c) 2014-2017 Hartmut Kaiser +// Copyright (c) 2021 Giannis Gonidelis +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/replace_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/replace_sender.cpp index bf90519c3ebd..d29956744d72 100644 --- a/libs/core/algorithms/tests/unit/algorithms/replace_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/replace_sender.cpp @@ -1,10 +1,13 @@ -// Copyright (c) 2024 Tobias Wukovitsch +// Copyright (c) 2014-2017 Hartmut Kaiser +// Copyright (c) 2021 Giannis Gonidelis +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/reverse_copy_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/reverse_copy_sender.cpp index a37fc0384eda..4ff131840484 100644 --- a/libs/core/algorithms/tests/unit/algorithms/reverse_copy_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/reverse_copy_sender.cpp @@ -1,10 +1,13 @@ -// Copyright (c) 2024 Tobias Wukovitsch +// Copyright (c) 2007-2017 Hartmut Kaiser +// Copyright (c) 2021 Giannis Gonidelis +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/rotate_copy_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/rotate_copy_sender.cpp index 0875633ae701..0d57a6bb1e6a 100644 --- a/libs/core/algorithms/tests/unit/algorithms/rotate_copy_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/rotate_copy_sender.cpp @@ -1,3 +1,5 @@ +// Copyright (c) 2007-2014 Hartmut Kaiser +// Copyright (c) 2021 Chuanqiu He // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 diff --git a/libs/core/algorithms/tests/unit/algorithms/search_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/search_sender.cpp index c56a0b0b29f0..3c1f31b2919e 100644 --- a/libs/core/algorithms/tests/unit/algorithms/search_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/search_sender.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2014 Grant Mercer // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 @@ -5,6 +6,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include @@ -29,6 +31,7 @@ void test_search_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) namespace ex = hpx::execution::experimental; namespace tt = hpx::this_thread::experimental; using scheduler_t = ex::thread_pool_policy_scheduler; + auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); std::vector c(10007); @@ -45,7 +48,6 @@ void test_search_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) ex::just(iterator(std::begin(c)), iterator(std::end(c)), std::begin(h), std::end(h)) | hpx::search(ex_policy.on(exec))); - iterator index = hpx::get<0>(*snd_result); base_iterator test_index = std::begin(c) + c.size() / 2; @@ -55,12 +57,13 @@ void test_search_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) { // edge case: only second range is empty + auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::end(c)), std::begin(h), std::begin(h)) | hpx::search(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); + auto expected = std::search(iterator(std::begin(c)), iterator(std::end(c)), std::begin(h), std::begin(h)); @@ -70,12 +73,13 @@ void test_search_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) { // edge case: both ranges are empty + auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::begin(c)), std::begin(h), std::begin(h)) | hpx::search(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); + auto expected = std::search(iterator(std::begin(c)), iterator(std::begin(c)), std::begin(h), std::begin(h)); @@ -85,12 +89,13 @@ void test_search_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) { // edge case: second range is larger than the first range + auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(h)), iterator(std::end(h)), std::begin(c), std::end(c)) | hpx::search(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); + auto expected = std::search(iterator(std::begin(h)), iterator(std::end(h)), std::begin(c), std::end(c)); diff --git a/libs/core/algorithms/tests/unit/algorithms/starts_with_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/starts_with_sender.cpp index 14fccfdb020a..0d4dad175b7b 100644 --- a/libs/core/algorithms/tests/unit/algorithms/starts_with_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/starts_with_sender.cpp @@ -1,3 +1,5 @@ +// Copyright (c) 2018 Christopher Ogle +// Copyright (c) 2020 Hartmut Kaiser // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 @@ -5,6 +7,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include @@ -56,8 +59,8 @@ void test_starts_with_sender( iterator(std::begin(some_more_ints)), iterator(std::end(some_more_ints))) | hpx::starts_with(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); + HPX_TEST_EQ(result, true); } @@ -70,8 +73,8 @@ void test_starts_with_sender( iterator(std::begin(some_wrong_ints)), iterator(std::end(some_wrong_ints))) | hpx::starts_with(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); + HPX_TEST_EQ(result, false); } } diff --git a/libs/core/algorithms/tests/unit/algorithms/swapranges_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/swapranges_sender.cpp index e9fe00b21d94..c886af750eea 100644 --- a/libs/core/algorithms/tests/unit/algorithms/swapranges_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/swapranges_sender.cpp @@ -1,3 +1,4 @@ +// Copyright (c) 2014 Grant Mercer // Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 @@ -5,6 +6,7 @@ // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include diff --git a/libs/core/algorithms/tests/unit/algorithms/transform_binary2_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/transform_binary2_tests.hpp index f6bf88159b0c..56ab761f3e52 100644 --- a/libs/core/algorithms/tests/unit/algorithms/transform_binary2_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/transform_binary2_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2014-2016 Hartmut Kaiser // Copyright (c) 2021 Giannis Gonidelis +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -364,8 +365,8 @@ void test_transform_binary2_sender( namespace ex = hpx::execution::experimental; namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; + auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); std::vector c1(10007); @@ -380,7 +381,6 @@ void test_transform_binary2_sender( tt::sync_wait(ex::just(iterator(std::begin(c1)), iterator(std::end(c1)), std::begin(c2), std::end(c2), std::begin(d1), add()) | hpx::ranges::transform(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); HPX_TEST(result.in1 == iterator(std::end(c1))); diff --git a/libs/core/algorithms/tests/unit/algorithms/transform_binary_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/transform_binary_tests.hpp index bcfef1ae9674..6911ace4a7ee 100644 --- a/libs/core/algorithms/tests/unit/algorithms/transform_binary_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/transform_binary_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2014-2016 Hartmut Kaiser // Copyright (c) 2021 Giannis Gonidelis +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -353,8 +354,8 @@ void test_transform_binary_sender( namespace ex = hpx::execution::experimental; namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; + auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); std::vector c1(10007); @@ -369,7 +370,6 @@ void test_transform_binary_sender( tt::sync_wait(ex::just(iterator(std::begin(c1)), iterator(std::end(c1)), std::begin(c2), std::begin(d1), add()) | hpx::transform(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); HPX_TEST(result == std::end(d1)); diff --git a/libs/core/algorithms/tests/unit/algorithms/transform_reduce_binary_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/transform_reduce_binary_tests.hpp index be43be75c4c6..ba9272b90350 100644 --- a/libs/core/algorithms/tests/unit/algorithms/transform_reduce_binary_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/transform_reduce_binary_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -6,8 +7,8 @@ #pragma once -#include #include +#include #include #include #include @@ -99,6 +100,7 @@ void test_transform_reduce_binary_sender( namespace ex = hpx::execution::experimental; namespace tt = hpx::this_thread::experimental; using scheduler_t = ex::thread_pool_policy_scheduler; + auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); std::vector c = test::random_iota(1007); @@ -110,10 +112,9 @@ void test_transform_reduce_binary_sender( tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), std::begin(d), init) | hpx::transform_reduce(ex_policy.on(exec))); + int result = hpx::get<0>(*snd_result); - int r = hpx::get<0>(*snd_result); - - HPX_TEST_EQ(r, + HPX_TEST_EQ(result, std::inner_product( std::begin(c), std::end(c), std::begin(d), init)); } @@ -125,11 +126,10 @@ void test_transform_reduce_binary_sender( tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::begin(c)), std::begin(d), init) | hpx::transform_reduce(ex_policy.on(exec))); + int result = hpx::get<0>(*snd_result); - int r = hpx::get<0>(*snd_result); - - HPX_TEST_EQ(init, r); - HPX_TEST_EQ(r, + HPX_TEST_EQ(init, result); + HPX_TEST_EQ(result, std::inner_product( std::begin(c), std::begin(c), std::begin(d), init)); } diff --git a/libs/core/algorithms/tests/unit/algorithms/transform_reduce_sender.cpp b/libs/core/algorithms/tests/unit/algorithms/transform_reduce_sender.cpp index b88a6824da50..2d0c6860aa1a 100644 --- a/libs/core/algorithms/tests/unit/algorithms/transform_reduce_sender.cpp +++ b/libs/core/algorithms/tests/unit/algorithms/transform_reduce_sender.cpp @@ -1,10 +1,12 @@ -// Copyright (c) 2024 Tobias Wukovitsch +// Copyright (c) 2014-2020 Hartmut Kaiser +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include +#include #include #include #include @@ -58,17 +60,16 @@ void test_transform_reduce_sender( ex::just(iterator(std::begin(c)), iterator(std::end(c)), init, reduce_op, convert_op) | hpx::transform_reduce(ex_policy.on(exec))); - - result_type r1 = hpx::get<0>(*snd_result); + result_type result = hpx::get<0>(*snd_result); // verify values - result_type r2 = std::accumulate(std::begin(c), std::end(c), init, + result_type expected = std::accumulate(std::begin(c), std::end(c), init, [&reduce_op, &convert_op](result_type res, std::size_t val) { return reduce_op(res, convert_op(val)); }); - HPX_TEST_EQ(get<0>(r1), get<0>(r2)); - HPX_TEST_EQ(get<1>(r1), get<1>(r2)); + HPX_TEST_EQ(get<0>(result), get<0>(expected)); + HPX_TEST_EQ(get<1>(result), get<1>(expected)); } { @@ -78,18 +79,17 @@ void test_transform_reduce_sender( ex::just(iterator(std::begin(c)), iterator(std::begin(c)), init, reduce_op, convert_op) | hpx::transform_reduce(ex_policy.on(exec))); - - result_type r1 = hpx::get<0>(*snd_result); + result_type result = hpx::get<0>(*snd_result); // verify values - result_type r2 = std::accumulate(std::begin(c), std::begin(c), init, + result_type expected = std::accumulate(std::begin(c), std::begin(c), init, [&reduce_op, &convert_op](result_type res, std::size_t val) { return reduce_op(res, convert_op(val)); }); - HPX_TEST(r1 == init); - HPX_TEST_EQ(get<0>(r1), get<0>(r2)); - HPX_TEST_EQ(get<1>(r1), get<1>(r2)); + HPX_TEST(result == init); + HPX_TEST_EQ(get<0>(result), get<0>(expected)); + HPX_TEST_EQ(get<1>(result), get<1>(expected)); } } diff --git a/libs/core/algorithms/tests/unit/algorithms/transform_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/transform_tests.hpp index a45edbd2ce5e..d78c061dbadb 100644 --- a/libs/core/algorithms/tests/unit/algorithms/transform_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/transform_tests.hpp @@ -1,5 +1,6 @@ // Copyright (c) 2014-2016 Hartmut Kaiser // Copyright (c) 2021 Giannis Gonidelis +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -8,6 +9,7 @@ #pragma once #include +#include #include #include @@ -327,7 +329,6 @@ void test_transform_sender( tt::sync_wait(ex::just(iterator(std::begin(c)), iterator(std::end(c)), std::begin(d), add_one()) | hpx::transform(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); HPX_TEST(result == std::end(d)); diff --git a/libs/core/algorithms/tests/unit/algorithms/unique_tests.hpp b/libs/core/algorithms/tests/unit/algorithms/unique_tests.hpp index 83a594d7ada1..b8639a196093 100644 --- a/libs/core/algorithms/tests/unit/algorithms/unique_tests.hpp +++ b/libs/core/algorithms/tests/unit/algorithms/unique_tests.hpp @@ -1,4 +1,5 @@ // Copyright (c) 2017-2018 Taeguk Kwon +// Copyright (c) 2024 Tobias Wukovitsch // // SPDX-License-Identifier: BSL-1.0 // Distributed under the Boost Software License, Version 1.0. (See accompanying @@ -7,6 +8,7 @@ #pragma once #include +#include #include #include #include @@ -516,8 +518,8 @@ void test_unique_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) namespace ex = hpx::execution::experimental; namespace tt = hpx::this_thread::experimental; - using scheduler_t = ex::thread_pool_policy_scheduler; + auto exec = ex::explicit_scheduler_executor(scheduler_t(ln_policy)); const int rand_base = std::rand(); @@ -533,8 +535,8 @@ void test_unique_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::end(c)), pred) | hpx::unique(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); + auto solution = std::unique(std::begin(d), std::end(d), pred); bool equality = @@ -545,11 +547,12 @@ void test_unique_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) { // edge case: empty range + auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(std::begin(c)), pred) | hpx::unique(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); + auto solution = std::unique(std::begin(d), std::begin(d), pred); bool equality = @@ -560,11 +563,12 @@ void test_unique_sender(LnPolicy ln_policy, ExPolicy&& ex_policy, IteratorTag) { // edge case: one element + auto snd_result = tt::sync_wait( ex::just(iterator(std::begin(c)), iterator(++std::begin(c)), pred) | hpx::unique(ex_policy.on(exec))); - auto result = hpx::get<0>(*snd_result); + auto solution = std::unique(std::begin(d), ++std::begin(d), pred); bool equality =