From 88eab1aa23843e30244760d48969de49a6f739a7 Mon Sep 17 00:00:00 2001 From: Andreas Tollk?tter Date: Sat, 15 Jul 2023 02:01:49 +0200 Subject: [PATCH 1/2] Added potential regression test. --- CMakeLists.txt | 11 ++++++----- tests/channels/test_special_cases.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 tests/channels/test_special_cases.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3aa4f53..1898fa9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,20 +46,21 @@ if (COPPER_ENABLE_TESTS) tests/select/test_select.cpp tests/select/test_vselect.cpp tests/select/test_void_select.cpp - tests/select/test_void_vselect.cpp) + tests/select/test_void_vselect.cpp + tests/channels/test_special_cases.cpp) target_link_libraries(copper_tests PRIVATE Catch2 copper Threads::Threads) target_compile_features(copper_tests PRIVATE cxx_std_20) if (NOT COPPER_ENABLE_FLAKY_TESTS) target_compile_definitions(copper_tests PRIVATE "COPPER_DISABLE_FLAKY_TESTS") - endif() + endif () if (COPPER_COLLECT_TEST_COVERAGE) target_compile_options(copper_tests PRIVATE "--coverage") target_link_options(copper_tests PRIVATE "--coverage") - endif() + endif () if (MSVC) target_compile_options(copper_tests PRIVATE "/bigobj") - endif() + endif () enable_testing() add_test(copper_tests copper_tests) -endif() +endif () diff --git a/tests/channels/test_special_cases.cpp b/tests/channels/test_special_cases.cpp new file mode 100644 index 0000000..40cee73 --- /dev/null +++ b/tests/channels/test_special_cases.cpp @@ -0,0 +1,24 @@ +/** + * Tests for special cases, e.g. regression tests for former bugs. + */ + +#include "../util.h" +#include +#include + +CHANNEL_TEST_CASE("GitHub Issue #23", "[copper]") { + { + copper::buffered_channel channel; + std::vector ths; + for (size_t i = 0; i < 5; i++) { + ths.push_back(new std::thread([&]() { + for (auto& item : channel) { + } + })); + } + channel.close(); + for (auto item : ths) { + item->join(); + } + } +} \ No newline at end of file From 6850675edf6dd8b553a4272b8162d0998b989868 Mon Sep 17 00:00:00 2001 From: Andreas Tollk?tter Date: Sat, 15 Jul 2023 02:11:16 +0200 Subject: [PATCH 2/2] removed new test temporarily --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1898fa9..2a9d0d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,8 +46,7 @@ if (COPPER_ENABLE_TESTS) tests/select/test_select.cpp tests/select/test_vselect.cpp tests/select/test_void_select.cpp - tests/select/test_void_vselect.cpp - tests/channels/test_special_cases.cpp) + tests/select/test_void_vselect.cpp) target_link_libraries(copper_tests PRIVATE Catch2 copper Threads::Threads) target_compile_features(copper_tests PRIVATE cxx_std_20) if (NOT COPPER_ENABLE_FLAKY_TESTS)