diff --git a/CMakeLists.txt b/CMakeLists.txt index 3aa4f53..2a9d0d9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -51,15 +51,15 @@ if (COPPER_ENABLE_TESTS) 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