From 2b4b1f74d5867d6a079c281397eb02371cef8a61 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Tue, 1 Oct 2024 00:16:05 +0300 Subject: [PATCH 1/8] move to doctest --- .clang-format | 2 +- CMakeLists.txt | 4 +- Readme.md | 2 +- cmake/dependencies.cmake | 2 +- conanfile.py | 2 +- sonar-project.properties | 2 +- src/tests/CMakeLists.txt | 4 +- src/tests/rpp/test_buffer.cpp | 25 ++-- src/tests/rpp/test_combine_latest.cpp | 15 ++- src/tests/rpp/test_concat.cpp | 39 +++--- src/tests/rpp/test_connectable_observable.cpp | 107 ++++++++-------- src/tests/rpp/test_debounce.cpp | 33 +++-- src/tests/rpp/test_defer.cpp | 13 +- src/tests/rpp/test_delay.cpp | 59 +++++---- src/tests/rpp/test_disposables.cpp | 77 ++++++------ src/tests/rpp/test_distinct.cpp | 7 +- src/tests/rpp/test_distinct_until_changed.cpp | 9 +- src/tests/rpp/test_element_at.cpp | 23 ++-- src/tests/rpp/test_filter.cpp | 13 +- src/tests/rpp/test_finally.cpp | 27 ++-- src/tests/rpp/test_first.cpp | 15 ++- src/tests/rpp/test_flat_map.cpp | 39 +++--- src/tests/rpp/test_from.cpp | 119 +++++++++--------- src/tests/rpp/test_group_by.cpp | 53 ++++---- src/tests/rpp/test_interval.cpp | 39 +++--- src/tests/rpp/test_last.cpp | 15 ++- src/tests/rpp/test_map.cpp | 11 +- src/tests/rpp/test_merge.cpp | 83 ++++++------ src/tests/rpp/test_observables.cpp | 65 +++++----- src/tests/rpp/test_observers.cpp | 53 ++++---- src/tests/rpp/test_on_error_resume_next.cpp | 41 +++--- src/tests/rpp/test_reduce.cpp | 29 +++-- src/tests/rpp/test_repeat.cpp | 35 +++--- src/tests/rpp/test_retry.cpp | 39 +++--- src/tests/rpp/test_retry_when.cpp | 37 +++--- src/tests/rpp/test_scan.cpp | 39 +++--- src/tests/rpp/test_scheduler.cpp | 95 +++++++------- src/tests/rpp/test_skip.cpp | 25 ++-- src/tests/rpp/test_start_with.cpp | 15 ++- src/tests/rpp/test_subjects.cpp | 119 +++++++++--------- src/tests/rpp/test_subscribe.cpp | 55 ++++---- src/tests/rpp/test_subscribe_on.cpp | 19 ++- src/tests/rpp/test_switch_on_next.cpp | 71 ++++++----- src/tests/rpp/test_take.cpp | 11 +- src/tests/rpp/test_take_last.cpp | 51 ++++---- src/tests/rpp/test_take_until.cpp | 43 ++++--- src/tests/rpp/test_take_while.cpp | 15 ++- src/tests/rpp/test_tap.cpp | 15 ++- src/tests/rpp/test_throttle.cpp | 17 ++- src/tests/rpp/test_timeout.cpp | 17 ++- src/tests/rpp/test_timer.cpp | 21 ++-- src/tests/rpp/test_window.cpp | 49 ++++---- src/tests/rpp/test_window_toggle.cpp | 25 ++-- src/tests/rpp/test_with_latest_from.cpp | 51 ++++---- src/tests/rpp/test_zip.cpp | 23 ++-- src/tests/rppasio/test_rppasio_scheduler.cpp | 2 +- src/tests/rppgrpc/test_async_client.cpp | 44 +++---- src/tests/rppgrpc/test_async_server.cpp | 18 +-- src/tests/rppqt/test_from_signal.cpp | 31 +++-- .../rppqt/test_main_thread_scheduler.cpp | 17 ++- src/tests/utils/copy_count_tracker.hpp | 7 +- src/tests/utils/disposable_observable.hpp | 29 +++-- src/tests/utils/rpp_trompeloil.hpp | 28 +---- 63 files changed, 1007 insertions(+), 1083 deletions(-) diff --git a/.clang-format b/.clang-format index b246583c7..8e2eaca4e 100644 --- a/.clang-format +++ b/.clang-format @@ -68,7 +68,7 @@ RequiresExpressionIndentation: OuterScope FixNamespaceComments: true IncludeBlocks: Regroup IncludeCategories: - - Regex: '^<(catch|nanobench).*>' + - Regex: '^<(doctest|nanobench).*>' Priority: 1 SortPriority: 1 - Regex: '^' diff --git a/CMakeLists.txt b/CMakeLists.txt index ddf38e2b1..4afedadc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,9 +52,9 @@ if (RPP_BUILD_TESTS OR RPP_BUILD_BENCHMARKS) macro(add_test_with_coverage TARGET) if (RPP_ENABLE_COVERAGE) - add_test(NAME ${TARGET} COMMAND ${CMAKE_COMMAND} -E env LLVM_PROFILE_FILE=${RPP_TEST_RESULTS_DIR}/${TARGET}.profraw $ -v high) + add_test(NAME ${TARGET} COMMAND ${CMAKE_COMMAND} -E env LLVM_PROFILE_FILE=${RPP_TEST_RESULTS_DIR}/${TARGET}.profraw $ -s) else() - add_test(NAME ${TARGET} COMMAND $ -v high -s) + add_test(NAME ${TARGET} COMMAND $ -s) endif() endmacro() endif() diff --git a/Readme.md b/Readme.md index 99f3a3396..6c580294a 100644 --- a/Readme.md +++ b/Readme.md @@ -145,7 +145,7 @@ DEALINGS IN THE SOFTWARE. # Credits: ReactivePlusPlus library uses: - [PVS-Studio](https://pvs-studio.com/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) - static analyzer for C, C++, C#, and Java code. -- [catch](https://github.com/catchorg/Catch2) for unit testing only, fetched automatically in case of `RPP_BUILD_TESTS` enabled +- [doctest](https://github.com/doctest/doctest) for unit testing only, fetched automatically in case of `RPP_BUILD_TESTS` enabled - [trompeloeil](https://github.com/rollbear/trompeloeil) for mocking in unit testing only, fetched automatically in case of `RPP_BUILD_TESTS` enabled - [nanobench](https://github.com/martinus/nanobench) for benchmarking only, fetched automatically in case of `RPP_BUILD_BENCHMARKS` enabled - [RxCpp](https://github.com/ReactiveX/RxCpp) only for comparison of performance between RPP and RxCpp in CI benchmarks. Used as cmake dependency under option diff --git a/cmake/dependencies.cmake b/cmake/dependencies.cmake index 4e957a3e0..bdfb62880 100644 --- a/cmake/dependencies.cmake +++ b/cmake/dependencies.cmake @@ -115,7 +115,7 @@ endif() # ===================== Tests =================== if (RPP_BUILD_TESTS) - rpp_fetch_library(Catch2 https://github.com/catchorg/Catch2.git v3.6.0) + rpp_fetch_library(doctest https://github.com/doctest/doctest.git v2.4.11) rpp_fetch_library(trompeloeil https://github.com/rollbear/trompeloeil.git main) endif() diff --git a/conanfile.py b/conanfile.py index a65b223f4..67937cd5a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -26,7 +26,7 @@ class RppConan(ConanFile): def requirements(self): if self.options.with_tests: self.requires("trompeloeil/47") - self.requires("catch2/3.6.0") + self.requires("doctest/2.4.11") if self.options.with_benchmarks: self.requires("nanobench/4.3.11") diff --git a/sonar-project.properties b/sonar-project.properties index 9df2d58bc..4c722cdfb 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,4 +8,4 @@ sonar.cfamily.llvm-cov.reportPath=build/test_results/coverage.txt sonar.coverage.exclusions=src/tests/**/* sonar.cpd.exclusions=src/tests/**/* sonar.issue.ignore.allfile=a1 -sonar.issue.ignore.allfile.a1.fileRegexp=#include.*catch +sonar.issue.ignore.allfile.a1.fileRegexp=#include.*doctest diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 97b750c67..b71df7fd7 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -14,8 +14,8 @@ macro(add_test_target target_name module files) set(TARGET ${target_name}) add_executable(${TARGET} ${files}) - target_link_libraries(${TARGET} PRIVATE Catch2::Catch2WithMain trompeloeil::trompeloeil rpp_tests_utils ${module}) - target_compile_definitions(${TARGET} PRIVATE "CATCH_CONFIG_FAST_COMPILE") + target_link_libraries(${TARGET} PRIVATE doctest trompeloeil::trompeloeil rpp_tests_utils ${module}) + target_compile_definitions(${TARGET} PRIVATE "DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN") set_target_properties(${TARGET} PROPERTIES FOLDER Tests/Suites/${module}) add_test_with_coverage(${TARGET}) diff --git a/src/tests/rpp/test_buffer.cpp b/src/tests/rpp/test_buffer.cpp index a045ce13c..2805c2fc2 100644 --- a/src/tests/rpp/test_buffer.cpp +++ b/src/tests/rpp/test_buffer.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -25,10 +24,10 @@ TEST_CASE("buffer bundles items") trompeloeil::sequence s{}; auto mock = mock_observer>{}; - SECTION("observable of -1-2-3-|") + SUBCASE("observable of -1-2-3-|") { auto obs = rpp::source::just(1, 2, 3); - SECTION("buffer(0) - shall see -{1}-{2}-{3}-|") + SUBCASE("buffer(0) - shall see -{1}-{2}-{3}-|") { REQUIRE_CALL(*mock, on_next_rvalue(std::vector{1})).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_next_rvalue(std::vector{2})).IN_SEQUENCE(s); @@ -37,7 +36,7 @@ TEST_CASE("buffer bundles items") obs | rpp::ops::buffer(0) | rpp::ops::subscribe(mock); } - SECTION("buffer(1) - shall see -{1}-{2}-{3}-|") + SUBCASE("buffer(1) - shall see -{1}-{2}-{3}-|") { REQUIRE_CALL(*mock, on_next_rvalue(std::vector{1})).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_next_rvalue(std::vector{2})).IN_SEQUENCE(s); @@ -47,7 +46,7 @@ TEST_CASE("buffer bundles items") obs | rpp::ops::buffer(1) | rpp::ops::subscribe(mock); } - SECTION("buffer(2) - shall see -{1,2}-{3}|") + SUBCASE("buffer(2) - shall see -{1,2}-{3}|") { REQUIRE_CALL(*mock, on_next_rvalue(std::vector{1, 2})).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_next_rvalue(std::vector{3})).IN_SEQUENCE(s); @@ -56,7 +55,7 @@ TEST_CASE("buffer bundles items") obs | rpp::ops::buffer(2) | rpp::ops::subscribe(mock); } - SECTION("buffer(3) - shall see -{1,2,3}-|") + SUBCASE("buffer(3) - shall see -{1,2,3}-|") { REQUIRE_CALL(*mock, on_next_rvalue(std::vector{1, 2, 3})).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(s); @@ -64,7 +63,7 @@ TEST_CASE("buffer bundles items") obs | rpp::ops::buffer(3) | rpp::ops::subscribe(mock); } - SECTION("buffer(4) - shall see -{1,2,3}-|") + SUBCASE("buffer(4) - shall see -{1,2,3}-|") { REQUIRE_CALL(*mock, on_next_rvalue(std::vector{1, 2, 3})).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(s); @@ -74,13 +73,13 @@ TEST_CASE("buffer bundles items") } } - SECTION("observable of -1-x-2-|, which error is raised in the middle") + SUBCASE("observable of -1-x-2-|, which error is raised in the middle") { auto obs = rpp::source::just(rpp::source::just(1).as_dynamic(), rpp::source::error(std::make_exception_ptr(std::runtime_error{""})).as_dynamic(), rpp::source::just(2).as_dynamic()) | rpp::ops::merge(); - SECTION("buffer(0) - shall see -{1}-x, which means error event is through") + SUBCASE("buffer(0) - shall see -{1}-x, which means error event is through") { REQUIRE_CALL(*mock, on_next_rvalue(std::vector{1})).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); @@ -88,7 +87,7 @@ TEST_CASE("buffer bundles items") obs | rpp::ops::buffer(0) | rpp::ops::subscribe(mock); } - SECTION("buffer(1) - shall see -{1}-x, which means error event is through") + SUBCASE("buffer(1) - shall see -{1}-x, which means error event is through") { REQUIRE_CALL(*mock, on_next_rvalue(std::vector{1})).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); @@ -96,7 +95,7 @@ TEST_CASE("buffer bundles items") obs | rpp::ops::buffer(1) | rpp::ops::subscribe(mock); } - SECTION("buffer(2) - shall see --x, which means error event is through") + SUBCASE("buffer(2) - shall see --x, which means error event is through") { REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); @@ -104,7 +103,7 @@ TEST_CASE("buffer bundles items") | rpp::ops::subscribe(mock); } } - SECTION("accept by moving") + SUBCASE("accept by moving") { REQUIRE_CALL(*mock, on_next_rvalue(std::vector{1, 2})).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_next_rvalue(std::vector{3, 4})).IN_SEQUENCE(s); diff --git a/src/tests/rpp/test_combine_latest.cpp b/src/tests/rpp/test_combine_latest.cpp index a395bfd70..6ab894dce 100644 --- a/src/tests/rpp/test_combine_latest.cpp +++ b/src/tests/rpp/test_combine_latest.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -26,7 +25,7 @@ TEST_CASE("combine_latest bundles items") { - SECTION("observable of -1-2-3-| combines with -4-5-6-| on immediate scheduler") + SUBCASE("observable of -1-2-3-| combines with -4-5-6-| on immediate scheduler") { auto mock = mock_observer>{}; trompeloeil::sequence seq; @@ -41,7 +40,7 @@ TEST_CASE("combine_latest bundles items") | rpp::ops::subscribe(mock); } - SECTION("observable of -1-2-3-| combines with -4-5-6-| on current_thread") + SUBCASE("observable of -1-2-3-| combines with -4-5-6-| on current_thread") { auto mock = mock_observer>{}; trompeloeil::sequence seq; @@ -62,7 +61,7 @@ TEST_CASE("combine_latest bundles items") // source 2: -4---5---6-| } - SECTION("observable of -1-2-3-| combines with two other sources on current_thread") + SUBCASE("observable of -1-2-3-| combines with two other sources on current_thread") { auto mock = mock_observer>{}; trompeloeil::sequence seq; @@ -91,7 +90,7 @@ TEST_CASE("combine_latest bundles items") TEST_CASE("combine_latest defers completed event") { - SECTION("observable of -1-2-3-| and never") + SUBCASE("observable of -1-2-3-| and never") { auto mock = mock_observer>{}; @@ -103,7 +102,7 @@ TEST_CASE("combine_latest defers completed event") TEST_CASE("combine_latest forwards errors") { - SECTION("observable of -1-2-3-| combines with error") + SUBCASE("observable of -1-2-3-| combines with error") { auto mock = mock_observer>{}; REQUIRE_CALL(*mock, on_error(trompeloeil::_)); @@ -115,7 +114,7 @@ TEST_CASE("combine_latest forwards errors") TEST_CASE("combine_latest handles race condition") { - SECTION("suscribe on source observable in current thread pairs with error in other thread - on_error can't interleave with on_next") + SUBCASE("suscribe on source observable in current thread pairs with error in other thread - on_error can't interleave with on_next") { auto subject = rpp::subjects::publish_subject{}; auto mock = mock_observer>{}; diff --git a/src/tests/rpp/test_concat.cpp b/src/tests/rpp/test_concat.cpp index 655b80e1e..c8a20cc92 100644 --- a/src/tests/rpp/test_concat.cpp +++ b/src/tests/rpp/test_concat.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -69,12 +68,12 @@ struct my_container_with_error_on_increment rpp::dynamic_observable m_obs = rpp::source::just(1).as_dynamic(); }; -TEMPLATE_TEST_CASE("concat", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("concat", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { mock_observer mock{}; trompeloeil::sequence s{}; auto test = [&](const auto& make_concat) { - SECTION("concat of solo observable") + SUBCASE("concat of solo observable") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_next_lvalue(2)).IN_SEQUENCE(s); @@ -83,7 +82,7 @@ TEMPLATE_TEST_CASE("concat", "", rpp::memory_model::use_stack, rpp::memory_model auto observable = make_concat(rpp::source::just(1, 2)); observable.subscribe(mock); } - SECTION("concat of multiple same observables") + SUBCASE("concat of multiple same observables") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_next_lvalue(2)).IN_SEQUENCE(s); @@ -94,7 +93,7 @@ TEMPLATE_TEST_CASE("concat", "", rpp::memory_model::use_stack, rpp::memory_model auto observable = make_concat(rpp::source::just(1, 2), rpp::source::just(1, 2)); observable.subscribe(mock); } - SECTION("concat of multiple different observables") + SUBCASE("concat of multiple different observables") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_next_lvalue(2)).IN_SEQUENCE(s); @@ -104,7 +103,7 @@ TEMPLATE_TEST_CASE("concat", "", rpp::memory_model::use_stack, rpp::memory_model auto observable = make_concat(rpp::source::just(1, 2), rpp::source::just(1)); observable.subscribe(mock); } - SECTION("concat stop if no completion") + SUBCASE("concat stop if no completion") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_next_lvalue(2)).IN_SEQUENCE(s); @@ -115,27 +114,27 @@ TEMPLATE_TEST_CASE("concat", "", rpp::memory_model::use_stack, rpp::memory_model REQUIRE(observer.has_value()); - SECTION("send completion later") + SUBCASE("send completion later") { REQUIRE_CALL(*mock, on_next_lvalue(3)).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(s); observer->on_completed(); } - SECTION("send emission later") + SUBCASE("send emission later") { REQUIRE_CALL(*mock, on_next_rvalue(10)).IN_SEQUENCE(s); observer->on_next(10); } - SECTION("send error later") + SUBCASE("send error later") { REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); observer->on_error({}); } } - SECTION("concat stoped if disposed") + SUBCASE("concat stoped if disposed") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(s); @@ -148,7 +147,7 @@ TEMPLATE_TEST_CASE("concat", "", rpp::memory_model::use_stack, rpp::memory_model observable.subscribe(rpp::composite_disposable_wrapper{d}, mock); } - SECTION("concat tracks actual upstream") + SUBCASE("concat tracks actual upstream") { auto d = rpp::composite_disposable_wrapper::make(); auto d1 = rpp::composite_disposable_wrapper::make(); @@ -167,7 +166,7 @@ TEMPLATE_TEST_CASE("concat", "", rpp::memory_model::use_stack, rpp::memory_model observable.subscribe(rpp::composite_disposable_wrapper{d}, mock); } - SECTION("concat tracks actual upstream for 2 upstreams") + SUBCASE("concat tracks actual upstream for 2 upstreams") { auto d = rpp::composite_disposable_wrapper::make(); auto d1 = rpp::composite_disposable_wrapper::make(); @@ -192,12 +191,12 @@ TEMPLATE_TEST_CASE("concat", "", rpp::memory_model::use_stack, rpp::memory_model } }; - SECTION("concat as source") + SUBCASE("concat as source") { test([](auto&&... vals) { return rpp::source::concat(std::forward(vals)...); }); - SECTION("concat of array of different observables") + SUBCASE("concat of array of different observables") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(s); REQUIRE_CALL(*mock, on_next_lvalue(2)).IN_SEQUENCE(s); @@ -208,21 +207,21 @@ TEMPLATE_TEST_CASE("concat", "", rpp::memory_model::use_stack, rpp::memory_model auto observable = rpp::source::concat(std::array{rpp::source::just(1, 2), rpp::source::just(1, 1)}); observable.subscribe(mock); } - SECTION("container with error on begin") + SUBCASE("container with error on begin") { REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); rpp::source::concat(my_container_with_error{}).subscribe(mock); } - SECTION("container with error on increment") + SUBCASE("container with error on increment") { REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); rpp::source::concat(my_container_with_error_on_increment{}).subscribe(mock); } } - SECTION("concat as operator") + SUBCASE("concat as operator") { test([](auto&&... vals) { return rpp::source::just(std::forward(vals).as_dynamic()...) | rpp::ops::concat(); @@ -270,7 +269,7 @@ TEST_CASE("concat doesn't produce extra copies") auto initial_copy = tracker.get_copy_count(); auto initial_move = tracker.get_move_count(); - SECTION("pass source via copy") + SUBCASE("pass source via copy") { rpp::source::concat(source) | rpp::ops::subscribe([](const copy_count_tracker&) {}); CHECK(tracker.get_copy_count() - initial_copy == 2); // 1 copy to observable + 1 copy to observer @@ -285,7 +284,7 @@ TEST_CASE("concat of iterable doesn't produce extra copies") auto initial_copy = tracker.get_copy_count(); auto initial_move = tracker.get_move_count(); - SECTION("pass source via copy") + SUBCASE("pass source via copy") { rpp::source::concat(source) | rpp::ops::subscribe([](const copy_count_tracker&) {}); CHECK(tracker.get_copy_count() - initial_copy == 2); // 1 copy to observable + 1 copy to observer diff --git a/src/tests/rpp/test_connectable_observable.cpp b/src/tests/rpp/test_connectable_observable.cpp index 435ac1127..e7371939d 100644 --- a/src/tests/rpp/test_connectable_observable.cpp +++ b/src/tests/rpp/test_connectable_observable.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -23,24 +22,24 @@ TEST_CASE("connectable observable") auto mock = mock_observer_strategy{}; auto d = rpp::composite_disposable_wrapper::make(); - SECTION("source and connectable observable from it") + SUBCASE("source and connectable observable from it") { auto source = rpp::source::just(1); auto test = [&](auto&& connectable) { - SECTION("subscribe on connectable") + SUBCASE("subscribe on connectable") { connectable.subscribe(mock.get_observer(d)); - SECTION("nothing happens") + SUBCASE("nothing happens") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); CHECK(!d.is_disposed()); } - SECTION("call connect") + SUBCASE("call connect") { auto sub_connectable = connectable.connect(); - SECTION("observer obtains values") + SUBCASE("observer obtains values") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_error_count() == 0); @@ -49,11 +48,11 @@ TEST_CASE("connectable observable") CHECK(sub_connectable.is_disposed()); } } - SECTION("call connect multiple times") + SUBCASE("call connect multiple times") { auto sub_connectable = connectable.connect(); connectable.connect(); - SECTION("observer obtains values") + SUBCASE("observer obtains values") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_error_count() == 0); @@ -63,11 +62,11 @@ TEST_CASE("connectable observable") } } } - SECTION("subscribe on connecatble via map and connect") + SUBCASE("subscribe on connecatble via map and connect") { connectable | rpp::ops::map([](int val) { return val * 10; }) | rpp::ops::subscribe(mock.get_observer(d)); auto sub_connectable = connectable.connect(); - SECTION("observer obtains modified values") + SUBCASE("observer obtains modified values") { CHECK(mock.get_received_values() == std::vector{10}); CHECK(mock.get_on_error_count() == 0); @@ -77,27 +76,27 @@ TEST_CASE("connectable observable") } } }; - SECTION("connectable created manually") + SUBCASE("connectable created manually") test(rpp::connectable_observable{source, rpp::subjects::publish_subject{}}); - SECTION("connectable created via multicast") + SUBCASE("connectable created via multicast") test(source | rpp::ops::multicast(rpp::subjects::publish_subject{})); - SECTION("connectable created via templated multicast") + SUBCASE("connectable created via templated multicast") test(source | rpp::ops::multicast()); } - SECTION("subject as source and connectable observable from it") + SUBCASE("subject as source and connectable observable from it") { auto source = rpp::subjects::publish_subject(); auto test = [&](auto&& connectable) { - SECTION("subscribe on connectable and connect") + SUBCASE("subscribe on connectable and connect") { connectable.subscribe(mock.get_observer(d)); auto sub_connectable = connectable.connect(); - SECTION("call connect again and send value") + SUBCASE("call connect again and send value") { auto new_sub_connectable = connectable.connect(); source.get_observer().on_next(1); - SECTION("observer obtains values only once") + SUBCASE("observer obtains values only once") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_error_count() == 0); @@ -106,11 +105,11 @@ TEST_CASE("connectable observable") CHECK(!sub_connectable.is_disposed()); } } - SECTION("unsubscribe connected subscription before any values from source") + SUBCASE("unsubscribe connected subscription before any values from source") { sub_connectable.dispose(); source.get_observer().on_next(1); - SECTION("subscriber obtains nothing") + SUBCASE("subscriber obtains nothing") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); @@ -119,12 +118,12 @@ TEST_CASE("connectable observable") CHECK(sub_connectable.is_disposed()); CHECK(!source.get_disposable().is_disposed()); } - SECTION("connect again and send values") + SUBCASE("connect again and send values") { auto new_sub_connectable = connectable.connect(); source.get_observer().on_next(1); - SECTION("subscriber obtains values") + SUBCASE("subscriber obtains values") { CHECK(mock.get_total_on_next_count() == 1); CHECK(mock.get_on_error_count() == 0); @@ -135,10 +134,10 @@ TEST_CASE("connectable observable") } } } - SECTION("obtain on_completed") + SUBCASE("obtain on_completed") { source.get_observer().on_completed(); - SECTION("subscribe obtains on_completed and unsubscribe initiated") + SUBCASE("subscribe obtains on_completed and unsubscribe initiated") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); @@ -146,11 +145,11 @@ TEST_CASE("connectable observable") CHECK(d.is_disposed()); CHECK(sub_connectable.is_disposed()); } - SECTION("connect again and send values") + SUBCASE("connect again and send values") { auto new_sub_connectable = connectable.connect(); source.get_observer().on_next(1); - SECTION("subscriber obtains nothing") + SUBCASE("subscriber obtains nothing") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); @@ -163,36 +162,36 @@ TEST_CASE("connectable observable") } } }; - SECTION("connectable created manually") + SUBCASE("connectable created manually") test(rpp::connectable_observable{source.get_observable(), rpp::subjects::publish_subject{}}); - SECTION("connectable created via multicast") + SUBCASE("connectable created via multicast") test(source.get_observable() | rpp::ops::multicast(rpp::subjects::publish_subject{})); - SECTION("connectable created via templated multicast") + SUBCASE("connectable created via templated multicast") test(source.get_observable() | rpp::ops::multicast()); } - SECTION("observable") + SUBCASE("observable") { auto source = rpp::source::just(1); - // SECTION("call publish on it") + // SUBCASE("call publish on it") // { // auto published = source.publish(); - // SECTION("published observable is same as Connectable with publish_subject") + // SUBCASE("published observable is same as Connectable with publish_subject") // { // static_assert(rpp::constraint::decayed_same_as, decltype(source)>>); // } // } - SECTION("call multicast on it with publish_subject") + SUBCASE("call multicast on it with publish_subject") { auto published = source | rpp::ops::multicast(rpp::subjects::publish_subject{}); - SECTION("published observable is same as Connectable with publish_subject") + SUBCASE("published observable is same as Connectable with publish_subject") { static_assert(rpp::constraint::decayed_same_as>>); } } - SECTION("call template multicast on it with publish_subject") + SUBCASE("call template multicast on it with publish_subject") { auto published = source | rpp::ops::multicast(); - SECTION("published observable is same as Connectable with publish_subject") + SUBCASE("published observable is same as Connectable with publish_subject") { static_assert(rpp::constraint::decayed_same_as>>); } @@ -204,23 +203,23 @@ TEST_CASE("ref_count") { auto observer_1 = mock_observer_strategy{}; auto observer_2 = mock_observer_strategy{}; - SECTION("connectable observable from just") + SUBCASE("connectable observable from just") { auto observable = rpp::source::just(1) | rpp::ops::multicast(); - SECTION("subscribe on it without ref_count") + SUBCASE("subscribe on it without ref_count") { observable.subscribe(observer_1); - SECTION("nothing happens") + SUBCASE("nothing happens") { CHECK(observer_1.get_total_on_next_count() == 0); CHECK(observer_1.get_on_error_count() == 0); CHECK(observer_1.get_on_completed_count() == 0); } - SECTION("subscribe on it another observer with ref_count") + SUBCASE("subscribe on it another observer with ref_count") { observable.ref_count().subscribe(observer_2); - SECTION("both observers obtain values") + SUBCASE("both observers obtain values") { auto validate = [](auto observer) { CHECK(observer.get_received_values() == std::vector{1}); @@ -234,20 +233,20 @@ TEST_CASE("ref_count") } } } - SECTION("connectable observable from subject") + SUBCASE("connectable observable from subject") { auto subj = rpp::subjects::publish_subject{}; auto observable = subj.get_observable() | rpp::ops::multicast(); - SECTION("subscribe on it without ref_count and with ref_count") + SUBCASE("subscribe on it without ref_count and with ref_count") { observable.subscribe(observer_1); auto sub = rpp::composite_disposable_wrapper::make(); observable.ref_count().subscribe(rpp::composite_disposable_wrapper{sub}, observer_2); - SECTION("send value") + SUBCASE("send value") { subj.get_observer().on_next(1); - SECTION("both observers obtain values") + SUBCASE("both observers obtain values") { auto validate = [](auto observer) { CHECK(observer.get_received_values() == std::vector{1}); @@ -259,11 +258,11 @@ TEST_CASE("ref_count") validate(observer_2); } } - SECTION("unsubscribe observer with ref_count and send value") + SUBCASE("unsubscribe observer with ref_count and send value") { sub.dispose(); subj.get_observer().on_next(1); - SECTION("no observers obtain values") + SUBCASE("no observers obtain values") { auto validate = [](auto observer) { CHECK(observer.get_total_on_next_count() == 0); @@ -273,12 +272,12 @@ TEST_CASE("ref_count") validate(observer_1); validate(observer_2); } - SECTION("subscribe via ref_count again and send value") + SUBCASE("subscribe via ref_count again and send value") { sub = rpp::composite_disposable_wrapper::make(); observable.ref_count().subscribe(rpp::composite_disposable_wrapper{sub}, observer_2); subj.get_observer().on_next(1); - SECTION("both observers obtain values") + SUBCASE("both observers obtain values") { auto validate = [](auto observer) { CHECK(observer.get_received_values() == std::vector{1}); @@ -292,15 +291,15 @@ TEST_CASE("ref_count") } } } - SECTION("subscribe both with ref_count") + SUBCASE("subscribe both with ref_count") { observable.ref_count().subscribe(observer_1); auto sub = rpp::composite_disposable_wrapper::make(); observable.ref_count().subscribe(rpp::composite_disposable_wrapper{sub}, observer_2); - SECTION("send value") + SUBCASE("send value") { subj.get_observer().on_next(1); - SECTION("both observers obtain values") + SUBCASE("both observers obtain values") { auto validate = [](auto observer) { CHECK(observer.get_received_values() == std::vector{1}); @@ -312,11 +311,11 @@ TEST_CASE("ref_count") validate(observer_2); } } - SECTION("unsubscribe 1 observer with ref_count and send value") + SUBCASE("unsubscribe 1 observer with ref_count and send value") { sub.dispose(); subj.get_observer().on_next(1); - SECTION("first observer obtains values") + SUBCASE("first observer obtains values") { CHECK(observer_1.get_received_values() == std::vector{1}); CHECK(observer_1.get_total_on_next_count() == 1); diff --git a/src/tests/rpp/test_debounce.cpp b/src/tests/rpp/test_debounce.cpp index 4aa9e8474..c3ad94788 100644 --- a/src/tests/rpp/test_debounce.cpp +++ b/src/tests/rpp/test_debounce.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -26,16 +25,16 @@ TEST_CASE("debounce emit only items where timeout reached") rpp::schedulers::test_scheduler scheduler{}; auto start = rpp::schedulers::test_scheduler::s_current_time; - SECTION("subject of items and subscriber subscribed on it via debounce") + SUBCASE("subject of items and subscriber subscribed on it via debounce") { auto mock = mock_observer_strategy{}; std::optional> optional_subj{rpp::subjects::publish_subject{}}; auto& subj = optional_subj.value(); subj.get_observable() | rpp::ops::debounce(debounce_delay, scheduler) | rpp::ops::subscribe(mock); - SECTION("emit value") + SUBCASE("emit value") { subj.get_observer().on_next(1); - SECTION("delay scheduled action to track period") + SUBCASE("delay scheduled action to track period") { CHECK(scheduler.get_schedulings() == std::vector{start + debounce_delay}); CHECK(scheduler.get_executions().empty()); @@ -43,10 +42,10 @@ TEST_CASE("debounce emit only items where timeout reached") CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("scheduler reached delayed time") + SUBCASE("scheduler reached delayed time") { scheduler.time_advance(debounce_delay); - SECTION("emission reached mock") + SUBCASE("emission reached mock") { CHECK(scheduler.get_schedulings() == std::vector{start + debounce_delay}); CHECK(scheduler.get_executions() == std::vector{start + debounce_delay}); @@ -55,10 +54,10 @@ TEST_CASE("debounce emit only items where timeout reached") CHECK(mock.get_on_completed_count() == 0); } } - SECTION("emit on completed") + SUBCASE("emit on completed") { subj.get_observer().on_completed(); - SECTION("emission reached mock with on completed without schedulable exection") + SUBCASE("emission reached mock with on completed without schedulable exection") { CHECK(scheduler.get_schedulings() == std::vector{start + debounce_delay}); CHECK(scheduler.get_executions().empty()); @@ -67,11 +66,11 @@ TEST_CASE("debounce emit only items where timeout reached") CHECK(mock.get_on_completed_count() == 1); } } - SECTION("new value emitted before scheduler reached requested time") + SUBCASE("new value emitted before scheduler reached requested time") { scheduler.time_advance(debounce_delay / 2); subj.get_observer().on_next(2); - SECTION("nothing changed immediately") + SUBCASE("nothing changed immediately") { CHECK(scheduler.get_schedulings() == std::vector{start + debounce_delay}); CHECK(scheduler.get_executions().empty()); @@ -79,10 +78,10 @@ TEST_CASE("debounce emit only items where timeout reached") CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("scheduler reached originally requested time") + SUBCASE("scheduler reached originally requested time") { scheduler.time_advance(debounce_delay / 2); - SECTION("delay re-schedule schedulable to new delay timepoint") + SUBCASE("delay re-schedule schedulable to new delay timepoint") { CHECK(scheduler.get_schedulings() == std::vector{start + debounce_delay, start + debounce_delay / 2 + debounce_delay}); CHECK(scheduler.get_executions() == std::vector{start + debounce_delay}); @@ -90,10 +89,10 @@ TEST_CASE("debounce emit only items where timeout reached") CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("scheduler reached delayed time") + SUBCASE("scheduler reached delayed time") { scheduler.time_advance(debounce_delay / 2); - SECTION("emission reached mock") + SUBCASE("emission reached mock") { CHECK(scheduler.get_schedulings() == std::vector{start + debounce_delay, start + debounce_delay / 2 + debounce_delay}); CHECK(scheduler.get_executions() == std::vector{start + debounce_delay, start + debounce_delay / 2 + debounce_delay}); @@ -104,11 +103,11 @@ TEST_CASE("debounce emit only items where timeout reached") } } } - SECTION("subject destoryed and then schedulable reaches schedulable") + SUBCASE("subject destoryed and then schedulable reaches schedulable") { optional_subj.reset(); scheduler.time_advance(debounce_delay); - SECTION("emission reached mock") + SUBCASE("emission reached mock") { CHECK(scheduler.get_schedulings() == std::vector{start + debounce_delay}); CHECK(scheduler.get_executions() == std::vector{start + debounce_delay}); diff --git a/src/tests/rpp/test_defer.cpp b/src/tests/rpp/test_defer.cpp index 0f841597f..22c4fd7b4 100644 --- a/src/tests/rpp/test_defer.cpp +++ b/src/tests/rpp/test_defer.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -23,7 +22,7 @@ TEST_CASE("defer on different sources") { auto mock = mock_observer_strategy{}; - SECTION("just") + SUBCASE("just") { auto obs = rpp::source::defer([] { return rpp::source::just(1); }); obs.subscribe(mock); @@ -33,7 +32,7 @@ TEST_CASE("defer on different sources") CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } - SECTION("error") + SUBCASE("error") { auto obs = rpp::source::defer([] { return rpp::source::error(std::make_exception_ptr(std::runtime_error{"error"})); }); obs.subscribe(mock); @@ -42,7 +41,7 @@ TEST_CASE("defer on different sources") CHECK(mock.get_on_error_count() == 1); CHECK(mock.get_on_completed_count() == 0); } - SECTION("empty") + SUBCASE("empty") { auto obs = rpp::source::defer([] { return rpp::source::empty(); }); obs.subscribe(mock); @@ -51,7 +50,7 @@ TEST_CASE("defer on different sources") CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } - SECTION("never") + SUBCASE("never") { auto obs = rpp::source::defer([] { return rpp::source::never(); }); obs.subscribe(mock); @@ -73,7 +72,7 @@ TEST_CASE("defer on mutable sources") return inner_obs; }); - SECTION("defer returns same value on multiple subscriptions") + SUBCASE("defer returns same value on multiple subscriptions") { auto mock1 = mock_observer_strategy{}; auto mock2 = mock_observer_strategy{}; diff --git a/src/tests/rpp/test_delay.cpp b/src/tests/rpp/test_delay.cpp index 432b8e683..cafbbab05 100644 --- a/src/tests/rpp/test_delay.cpp +++ b/src/tests/rpp/test_delay.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -60,32 +59,32 @@ TEST_CASE("delay delays observable's emissions") const auto now = get_now(); return rpp::ops::subscribe( [&, now, get_now](const auto& v) { - SECTION("should see event after the delay") + SUBCASE("should see event after the delay") CHECK(get_now() >= now + delay_duration); mock.on_next(v); }, [&, now, get_now](const std::exception_ptr& err) { - SECTION("should see event after the delay") + SUBCASE("should see event after the delay") CHECK(get_now() >= now + delay_duration); mock.on_error(err); }, [&, now, get_now]() { - SECTION("should see event after the delay") + SUBCASE("should see event after the delay") CHECK(get_now() >= now + delay_duration); mock.on_completed(); }); }; - SECTION("observable of -1-|") + SUBCASE("observable of -1-|") { rpp::source::just(1) | rpp::ops::delay(delay_duration, rpp::schedulers::current_thread{}) | rpp::ops::as_blocking() | subscribe_with_delay([]() { return rpp::schedulers::clock_type::now(); }); - SECTION("should see -1-|") + SUBCASE("should see -1-|") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_completed_count() == 1); @@ -93,14 +92,14 @@ TEST_CASE("delay delays observable's emissions") } } - SECTION("observable of -x") + SUBCASE("observable of -x") { rpp::source::error(std::make_exception_ptr(std::runtime_error{""})) | rpp::ops::delay(delay_duration, rpp::schedulers::current_thread{}) | rpp::ops::as_blocking() | subscribe_with_delay([]() { return rpp::schedulers::clock_type::now(); }); - SECTION("should see -x after the delay") + SUBCASE("should see -x after the delay") { CHECK(mock.get_received_values().empty()); CHECK(mock.get_on_completed_count() == 0); @@ -108,14 +107,14 @@ TEST_CASE("delay delays observable's emissions") } } - SECTION("observable of -|") + SUBCASE("observable of -|") { rpp::source::empty() | rpp::ops::delay(delay_duration, rpp::schedulers::current_thread{}) | rpp::ops::as_blocking() | subscribe_with_delay([]() { return rpp::schedulers::clock_type::now(); }); - SECTION("should see -|") + SUBCASE("should see -|") { CHECK(mock.get_received_values().empty()); CHECK(mock.get_on_completed_count() == 1); @@ -123,13 +122,13 @@ TEST_CASE("delay delays observable's emissions") } } - SECTION("subject with items") + SUBCASE("subject with items") { auto subj = rpp::subjects::publish_subject{}; - SECTION("subscribe on subject via delay and doing recursive submit from another thread") + SUBCASE("subscribe on subject via delay and doing recursive submit from another thread") { - SECTION("all values obtained in the same thread") + SUBCASE("all values obtained in the same thread") { auto current_thread = std::this_thread::get_id(); @@ -146,7 +145,7 @@ TEST_CASE("delay delays observable's emissions") subj.get_observer().on_next(2); }}.join(); - SECTION("no recursive on_next calls") + SUBCASE("no recursive on_next calls") { CHECK(mock.get_received_values() == std::vector{1}); } @@ -155,13 +154,13 @@ TEST_CASE("delay delays observable's emissions") subj.get_observer().on_next(1); - SECTION("all values obtained") + SUBCASE("all values obtained") { CHECK(mock.get_received_values() == std::vector{1, 2}); } } } - SECTION("subscribe on subject via delay via test_scheduler, sent value") + SUBCASE("subscribe on subject via delay via test_scheduler, sent value") { subj.get_observable() | rpp::ops::delay(std::chrono::seconds{30000}, manual_scheduler{}) @@ -169,7 +168,7 @@ TEST_CASE("delay delays observable's emissions") subj.get_observer().on_next(1); - SECTION("no memory leak") + SUBCASE("no memory leak") { manual_scheduler::worker_strategy::s_test_queue = rpp::schedulers::details::schedulables_queue{}; // checked via sanitizer @@ -177,20 +176,20 @@ TEST_CASE("delay delays observable's emissions") } } - SECTION("observable of -1-| but with invoking schedulable after subscription") + SUBCASE("observable of -1-| but with invoking schedulable after subscription") { rpp::source::just(1) | rpp::ops::delay(delay_duration, scheduler) | subscribe_with_delay([]() { return rpp::schedulers::test_scheduler::worker_strategy::now(); }); - SECTION("shouldn't see anything before manual invoking") + SUBCASE("shouldn't see anything before manual invoking") { CHECK(mock.get_received_values() == std::vector{}); CHECK(mock.get_on_completed_count() == 0); CHECK(mock.get_on_error_count() == 0); } - SECTION("should see nothing before reaching of time") + SUBCASE("should see nothing before reaching of time") { CHECK(mock.get_received_values() == std::vector{}); CHECK(mock.get_on_completed_count() == 0); @@ -199,14 +198,14 @@ TEST_CASE("delay delays observable's emissions") scheduler.time_advance(delay_duration); - SECTION("should see -1-|") + SUBCASE("should see -1-|") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_completed_count() == 1); CHECK(mock.get_on_error_count() == 0); } } - SECTION("observable of -1-x but with invoking schedulable after subscription") + SUBCASE("observable of -1-x but with invoking schedulable after subscription") { rpp::source::create([](const auto& obs) { obs.on_next(1); @@ -215,7 +214,7 @@ TEST_CASE("delay delays observable's emissions") | rpp::ops::delay(delay_duration, scheduler) | subscribe_with_delay([]() { return rpp::schedulers::test_scheduler::worker_strategy::now(); }); - SECTION("shouldn't see anything before manual invoking") + SUBCASE("shouldn't see anything before manual invoking") { CHECK(mock.get_received_values() == std::vector{}); CHECK(mock.get_on_completed_count() == 0); @@ -224,7 +223,7 @@ TEST_CASE("delay delays observable's emissions") scheduler.time_advance(delay_duration); - SECTION("should see --1-x") + SUBCASE("should see --1-x") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_completed_count() == 0); @@ -248,25 +247,25 @@ TEST_CASE("observe_on forward error immediately") const auto now = get_now(); return rpp::ops::subscribe( [&, now, get_now](const auto& v) { - SECTION("should see event after the delay") + SUBCASE("should see event after the delay") CHECK(get_now() >= now + delay_duration); mock.on_next(v); }, [&, now, get_now](const std::exception_ptr& err) { - SECTION("should see event after the delay") + SUBCASE("should see event after the delay") CHECK(get_now() == now); mock.on_error(err); }, [&, now, get_now]() { - SECTION("should see event after the delay") + SUBCASE("should see event after the delay") CHECK(get_now() >= now + delay_duration); mock.on_completed(); }); }; - SECTION("observable of -1-x but with invoking schedulable after subscription") + SUBCASE("observable of -1-x but with invoking schedulable after subscription") { const auto now = rpp::schedulers::test_scheduler::worker_strategy::now(); rpp::source::create([](const auto& obs) { @@ -276,7 +275,7 @@ TEST_CASE("observe_on forward error immediately") | rpp::ops::observe_on(scheduler, delay_duration) | subscribe_with_delay([]() { return rpp::schedulers::test_scheduler::worker_strategy::now(); }); - SECTION("should see on_error immediately") + SUBCASE("should see on_error immediately") { CHECK(mock.get_received_values() == std::vector{}); CHECK(mock.get_on_completed_count() == 0); diff --git a/src/tests/rpp/test_disposables.cpp b/src/tests/rpp/test_disposables.cpp index 7c60fc64e..5a659bdf7 100644 --- a/src/tests/rpp/test_disposables.cpp +++ b/src/tests/rpp/test_disposables.cpp @@ -7,8 +7,7 @@ // // Project home: https://github.com/victimsnino/ReactivePlusPlus -#include -#include +#include #include #include @@ -28,20 +27,20 @@ namespace }; } // namespace -TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dynamic_disposables_container<0>, rpp::details::disposables::static_disposables_container<1>) +TEST_CASE_TEMPLATE("disposable keeps state", TestType, rpp::details::disposables::dynamic_disposables_container<0>, rpp::details::disposables::static_disposables_container<1>) { auto d = rpp::composite_disposable_wrapper::make>(); CHECK(!d.is_disposed()); - SECTION("dispose marks disposable as disposed") + SUBCASE("dispose marks disposable as disposed") { d.dispose(); CHECK(d.is_disposed()); } - SECTION("dispose on copy of disposable marks both disposable as disposed") + SUBCASE("dispose on copy of disposable marks both disposable as disposed") { auto copy = d; // NOLINT(performance-unnecessary-copy-initialization) copy.dispose(); @@ -49,19 +48,19 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna CHECK(d.is_disposed()); } - SECTION("add other disposable") + SUBCASE("add other disposable") { auto other = rpp::composite_disposable_wrapper::make(); CHECK(!other.is_disposed()); d.add(other); - SECTION("calling dispose on original disposable forces both of them to be disposed") + SUBCASE("calling dispose on original disposable forces both of them to be disposed") { d.dispose(); CHECK(other.is_disposed()); CHECK(d.is_disposed()); } - SECTION("calling clear on original disposable forces inner to be disposed") + SUBCASE("calling clear on original disposable forces inner to be disposed") { d.clear(); CHECK(other.is_disposed()); @@ -77,7 +76,7 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna CHECK(!d.is_disposed()); } - SECTION("calling clear on disposed disposable") + SUBCASE("calling clear on disposed disposable") { d.dispose(); CHECK(other.is_disposed()); @@ -85,7 +84,7 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna d.clear(); } - SECTION("calling remove + dispose on original disposable forces only original to be disposed") + SUBCASE("calling remove + dispose on original disposable forces only original to be disposed") { d.remove(other); d.dispose(); @@ -93,7 +92,7 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna CHECK(d.is_disposed()); } - SECTION("calling dispose on other disposable forces only other to be disposed") + SUBCASE("calling dispose on other disposable forces only other to be disposed") { other.dispose(); CHECK(other.is_disposed()); @@ -101,7 +100,7 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna } } - SECTION("add disposed disposable") + SUBCASE("add disposed disposable") { auto other = rpp::composite_disposable_wrapper::make(); other.dispose(); @@ -110,11 +109,11 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna CHECK(!d.is_disposed()); } - SECTION("disposed disposable") + SUBCASE("disposed disposable") { d.dispose(); - SECTION("adding non disposed disposable to empty forces it to be disposed") + SUBCASE("adding non disposed disposable to empty forces it to be disposed") { auto other = rpp::composite_disposable_wrapper::make(); CHECK(!other.is_disposed()); @@ -123,13 +122,13 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna } } - SECTION("empty disposable") + SUBCASE("empty disposable") { d = rpp::composite_disposable_wrapper::empty(); CHECK(d.is_disposed()); d.dispose(); - SECTION("adding non disposed disposable to empty forces it to be disposed") + SUBCASE("adding non disposed disposable to empty forces it to be disposed") { auto other = rpp::composite_disposable_wrapper::make(); CHECK(!other.is_disposed()); @@ -137,7 +136,7 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna CHECK(other.is_disposed()); } } - SECTION("disposable dispose on destruction") + SUBCASE("disposable dispose on destruction") { { auto other = rpp::composite_disposable_wrapper::make(); @@ -150,7 +149,7 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna CHECK(d.is_disposed()); } - SECTION("add callback_disposable") + SUBCASE("add callback_disposable") { size_t invoked_count{}; d.add([&invoked_count]() noexcept { @@ -161,7 +160,7 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna CHECK(invoked_count == 1); } - SECTION("add callback_disposable to disposed disposable") + SUBCASE("add callback_disposable to disposed disposable") { d.dispose(); @@ -172,18 +171,18 @@ TEMPLATE_TEST_CASE("disposable keeps state", "", rpp::details::disposables::dyna CHECK(invoked_count == 1); } - SECTION("add self") + SUBCASE("add self") { d.add(d); CHECK(!d.is_disposed()); - SECTION("dispose self") + SUBCASE("dispose self") { d.dispose(); CHECK(d.is_disposed()); } } - SECTION("call dispose twice") + SUBCASE("call dispose twice") { d.dispose(); CHECK(d.is_disposed()); @@ -204,7 +203,7 @@ TEST_CASE("refcount disposable dispose underlying in case of reaching zero") CHECK(!refcounted.is_disposed()); CHECK(!refcount.is_disposed()); - SECTION("disposing refcounted as is disposes underlying") + SUBCASE("disposing refcounted as is disposes underlying") { refcounted.dispose(); @@ -212,14 +211,14 @@ TEST_CASE("refcount disposable dispose underlying in case of reaching zero") CHECK(refcounted.is_disposed()); CHECK(refcount.is_disposed()); - SECTION("additional disposing does nothing") + SUBCASE("additional disposing does nothing") { refcounted.dispose(); CHECK(underlying.lock()->dispose_count == 1); CHECK(refcounted.is_disposed()); CHECK(refcount.is_disposed()); } - SECTION("addref and disposing does nothing") + SUBCASE("addref and disposing does nothing") { auto d = refcount.lock()->add_ref(); CHECK(d.is_disposed()); @@ -231,7 +230,7 @@ TEST_CASE("refcount disposable dispose underlying in case of reaching zero") } } - SECTION("disposing added to underlying not disposes refcount") + SUBCASE("disposing added to underlying not disposes refcount") { underlying.dispose(); @@ -240,7 +239,7 @@ TEST_CASE("refcount disposable dispose underlying in case of reaching zero") CHECK(!refcounted.is_disposed()); } - SECTION("add_ref prevents immediate disposing") + SUBCASE("add_ref prevents immediate disposing") { size_t count = 5; std::vector disposables{}; @@ -290,7 +289,7 @@ TEST_CASE("static_disposable_container works as expected") auto d1 = rpp::composite_disposable_wrapper::make(); auto d2 = rpp::composite_disposable_wrapper::make(); - SECTION("dispose empty") + SUBCASE("dispose empty") { container.dispose(); } @@ -298,20 +297,20 @@ TEST_CASE("static_disposable_container works as expected") container.push_back(d1); container.push_back(d2); - SECTION("dispose with added disposable") + SUBCASE("dispose with added disposable") { container.dispose(); CHECK(d1.is_disposed()); CHECK(d2.is_disposed()); } - SECTION("clear with added disposable") + SUBCASE("clear with added disposable") { container.clear(); container.dispose(); CHECK(!d1.is_disposed()); CHECK(!d2.is_disposed()); - SECTION("add cleared and dispose") + SUBCASE("add cleared and dispose") { container.push_back(d1); CHECK(!d1.is_disposed()); @@ -321,13 +320,13 @@ TEST_CASE("static_disposable_container works as expected") } } - SECTION("remove with added disposable") + SUBCASE("remove with added disposable") { container.remove(d1); container.dispose(); CHECK(!d1.is_disposed()); CHECK(d2.is_disposed()); - SECTION("add removed and dispose") + SUBCASE("add removed and dispose") { container.push_back(d1); CHECK(!d1.is_disposed()); @@ -336,33 +335,33 @@ TEST_CASE("static_disposable_container works as expected") } } - SECTION("move container") + SUBCASE("move container") { auto other = std::move(container); - SECTION("dispose original") + SUBCASE("dispose original") { container.dispose(); // NOLINT CHECK(!d1.is_disposed()); CHECK(!d2.is_disposed()); } - SECTION("dispose copied") + SUBCASE("dispose copied") { other.dispose(); CHECK(d1.is_disposed()); CHECK(d2.is_disposed()); } - SECTION("move back") + SUBCASE("move back") { container = std::move(other); - SECTION("dispose copied") + SUBCASE("dispose copied") { other.dispose(); // NOLINT CHECK(!d1.is_disposed()); CHECK(!d2.is_disposed()); } - SECTION("dispose original") + SUBCASE("dispose original") { container.dispose(); CHECK(d1.is_disposed()); diff --git a/src/tests/rpp/test_distinct.cpp b/src/tests/rpp/test_distinct.cpp index 223c9fd9f..fbd46baa9 100644 --- a/src/tests/rpp/test_distinct.cpp +++ b/src/tests/rpp/test_distinct.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -20,12 +19,12 @@ #include "copy_count_tracker.hpp" #include "disposable_observable.hpp" -TEMPLATE_TEST_CASE("distinct filters out repeated values and emit only items that have not already been emitted", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("distinct filters out repeated values and emit only items that have not already been emitted", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto mock = mock_observer_strategy{}; auto obs = rpp::source::just(1, 1, 2, 2, 3, 4, 4, 2, 2, 1, 3); - SECTION("WHEN subscribe on observable with duplicates via distinct THEN subscriber obtains values without duplicates") + SUBCASE("WHEN subscribe on observable with duplicates via distinct THEN subscriber obtains values without duplicates") { obs | rpp::ops::distinct() | rpp::ops::subscribe(mock); CHECK(mock.get_received_values() == std::vector{1, 2, 3, 4}); diff --git a/src/tests/rpp/test_distinct_until_changed.cpp b/src/tests/rpp/test_distinct_until_changed.cpp index 74e8a4377..ffc124a30 100644 --- a/src/tests/rpp/test_distinct_until_changed.cpp +++ b/src/tests/rpp/test_distinct_until_changed.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -21,18 +20,18 @@ #include "disposable_observable.hpp" -TEMPLATE_TEST_CASE("distinct_until_changed filters out consecutive duplicates and send first value from duplicates", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("distinct_until_changed filters out consecutive duplicates and send first value from duplicates", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto mock = mock_observer_strategy{}; auto obs = rpp::source::just(1, 1, 2, 2, 3, 2, 2, 1); - SECTION("WHEN subscribe on observable with duplicates via distinct_until_changed THEN subscriber obtains values without consecutive duplicates") + SUBCASE("WHEN subscribe on observable with duplicates via distinct_until_changed THEN subscriber obtains values without consecutive duplicates") { obs | rpp::ops::distinct_until_changed() | rpp::ops::subscribe(mock); CHECK(mock.get_received_values() == std::vector{1, 2, 3, 2, 1}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } - SECTION("WHEN subscribe on observable with duplicates via distinct_until_changed with custom comparator THEN subscriber obtains values without consecutive duplicates") + SUBCASE("WHEN subscribe on observable with duplicates via distinct_until_changed with custom comparator THEN subscriber obtains values without consecutive duplicates") { auto op = rpp::ops::distinct_until_changed([](int old_value, int new_value) { return old_value % 2 != new_value % 2; }); obs | op | rpp::ops::subscribe(mock); diff --git a/src/tests/rpp/test_element_at.cpp b/src/tests/rpp/test_element_at.cpp index 57c08317e..45d580e11 100644 --- a/src/tests/rpp/test_element_at.cpp +++ b/src/tests/rpp/test_element_at.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -24,11 +23,11 @@ TEST_CASE("element_at emits element at provided index") { mock_observer_strategy mock{}; - SECTION("sequence of values") + SUBCASE("sequence of values") { auto obs = rpp::source::just(1, 2, 3); - SECTION("subscribe via element_at(2)") + SUBCASE("subscribe via element_at(2)") { (obs | rpp::operators::element_at(2)).subscribe(mock); @@ -38,7 +37,7 @@ TEST_CASE("element_at emits element at provided index") } - SECTION("subscribe via element_at(1)") + SUBCASE("subscribe via element_at(1)") { (obs | rpp::operators::element_at(1)).subscribe(mock); @@ -47,7 +46,7 @@ TEST_CASE("element_at emits element at provided index") CHECK(mock.get_on_completed_count() == 1); } - SECTION("subscribe via element_at(0)") + SUBCASE("subscribe via element_at(0)") { (obs | rpp::operators::element_at(0)).subscribe(mock); @@ -56,7 +55,7 @@ TEST_CASE("element_at emits element at provided index") CHECK(mock.get_on_completed_count() == 1); } - SECTION("subscribe via element_at(3)") + SUBCASE("subscribe via element_at(3)") { (obs | rpp::operators::element_at(3)).subscribe(mock); @@ -66,13 +65,13 @@ TEST_CASE("element_at emits element at provided index") } } - SECTION("empty sequence") + SUBCASE("empty sequence") { auto obs = rpp::source::create([](auto&& obs) { obs.on_completed(); }); - SECTION("subscribe via element_at(0)") + SUBCASE("subscribe via element_at(0)") { (obs | rpp::operators::element_at(0)).subscribe(mock); @@ -82,13 +81,13 @@ TEST_CASE("element_at emits element at provided index") } } - SECTION("error sequence") + SUBCASE("error sequence") { auto obs = rpp::source::create([](auto&& obs) { obs.on_error({}); }); - SECTION("subscribe via element_at(0)") + SUBCASE("subscribe via element_at(0)") { (obs | rpp::operators::element_at(0)).subscribe(mock); @@ -101,7 +100,7 @@ TEST_CASE("element_at emits element at provided index") TEST_CASE("element_at doesn't produce extra copies") { - SECTION("element_at(1)") + SUBCASE("element_at(1)") { copy_count_tracker::test_operator(rpp::ops::element_at(1), { diff --git a/src/tests/rpp/test_filter.cpp b/src/tests/rpp/test_filter.cpp index d0387a91e..4ae035d6e 100644 --- a/src/tests/rpp/test_filter.cpp +++ b/src/tests/rpp/test_filter.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -21,13 +20,13 @@ #include #include -TEMPLATE_TEST_CASE("filter", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("filter", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { mock_observer_strategy mock{}; auto obs = rpp::source::just(1, 2, 3, 4); - SECTION("filter emits only satisfying values") + SUBCASE("filter emits only satisfying values") { auto filter = rpp::operators::filter([](auto v) { return v % 2 == 0; }); obs | filter | rpp::operators::subscribe(mock); @@ -38,7 +37,7 @@ TEMPLATE_TEST_CASE("filter", "", rpp::memory_model::use_stack, rpp::memory_model } - SECTION("filter with exception value") + SUBCASE("filter with exception value") { obs | rpp::operators::filter([](int) -> bool { throw std::runtime_error{""}; }) | rpp::operators::subscribe(mock); // NOLINT @@ -50,7 +49,7 @@ TEMPLATE_TEST_CASE("filter", "", rpp::memory_model::use_stack, rpp::memory_model TEST_CASE("filter doesn't produce extra copies") { - SECTION("filter([](copy_count_tracker){return true;})") + SUBCASE("filter([](copy_count_tracker){return true;})") { copy_count_tracker::test_operator(rpp::ops::filter([](copy_count_tracker) { return true; }), // NOLINT { @@ -61,7 +60,7 @@ TEST_CASE("filter doesn't produce extra copies") }); } - SECTION("filter([](const copy_count_tracker&){return false;})") + SUBCASE("filter([](const copy_count_tracker&){return false;})") { copy_count_tracker::test_operator(rpp::ops::filter([](const copy_count_tracker&) { return false; }), {.send_by_copy = {.copy_count = 0, diff --git a/src/tests/rpp/test_finally.cpp b/src/tests/rpp/test_finally.cpp index 4c4c66f4b..1f2814ead 100644 --- a/src/tests/rpp/test_finally.cpp +++ b/src/tests/rpp/test_finally.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -20,16 +19,16 @@ TEST_CASE("finally executes only at the end") { auto mock = mock_observer_strategy(); - SECTION("observable with no emissions") + SUBCASE("observable with no emissions") { auto obs = rpp::source::create([](const auto&) { }); size_t invoked = 0; - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::operators::finally([&]() noexcept { ++invoked; }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from observable") + SUBCASE("observer obtains values from observable") { CHECK(invoked == 1); CHECK(mock.get_total_on_next_count() == 0); @@ -39,17 +38,17 @@ TEST_CASE("finally executes only at the end") } } - SECTION("observable with on_completed emission") + SUBCASE("observable with on_completed emission") { auto obs = rpp::source::create([](const auto& sub) { sub.on_completed(); }); size_t invoked = 0; - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::operators::finally([&]() noexcept { ++invoked; }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from observable") + SUBCASE("observer obtains values from observable") { CHECK(invoked == 1); CHECK(mock.get_total_on_next_count() == 0); @@ -59,18 +58,18 @@ TEST_CASE("finally executes only at the end") } } - SECTION("observable with on_next emission") + SUBCASE("observable with on_next emission") { auto obs = rpp::source::create([](const auto& sub) { sub.on_next(1); sub.on_completed(); }); size_t invoked = 0; - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::operators::finally([&]() noexcept { ++invoked; }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from observable") + SUBCASE("observer obtains values from observable") { CHECK(invoked == 1); CHECK(mock.get_total_on_next_count() == 1); @@ -80,18 +79,18 @@ TEST_CASE("finally executes only at the end") } } - SECTION("observable with on_error emission") + SUBCASE("observable with on_error emission") { auto obs = rpp::source::create([](const auto& sub) { sub.on_next(1); sub.on_error(std::make_exception_ptr(std::runtime_error{""})); }); size_t invoked = 0; - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::operators::finally([&]() noexcept { ++invoked; }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from observable") + SUBCASE("observer obtains values from observable") { CHECK(invoked == 1); CHECK(mock.get_total_on_next_count() == 1); diff --git a/src/tests/rpp/test_first.cpp b/src/tests/rpp/test_first.cpp index f41ee9b00..e0c5ae792 100644 --- a/src/tests/rpp/test_first.cpp +++ b/src/tests/rpp/test_first.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -26,7 +25,7 @@ TEST_CASE("first only emits once") { auto mock = mock_observer_strategy{}; - SECTION("observable of -1-| - shall see -1-|") + SUBCASE("observable of -1-| - shall see -1-|") { auto obs = rpp::source::just(1); obs | rpp::ops::first() @@ -37,7 +36,7 @@ TEST_CASE("first only emits once") CHECK(mock.get_on_error_count() == 0); } - SECTION("observable of -1-2-3-| - shall see -1-|") + SUBCASE("observable of -1-2-3-| - shall see -1-|") { auto obs = rpp::source::just(1, 2, 3); obs | rpp::ops::first() @@ -47,7 +46,7 @@ TEST_CASE("first only emits once") CHECK(mock.get_on_error_count() == 0); } - SECTION("observable of never - shall not see neither completed nor error event") + SUBCASE("observable of never - shall not see neither completed nor error event") { auto obs = rpp::source::never(); obs | rpp::ops::first() @@ -57,7 +56,7 @@ TEST_CASE("first only emits once") CHECK(mock.get_on_error_count() == 0); } - SECTION("observable of x-| - shall see error and no-completed event") + SUBCASE("observable of x-| - shall see error and no-completed event") { auto obs = rpp::source::error(std::make_exception_ptr(std::runtime_error{""})); obs | rpp::ops::first() @@ -68,7 +67,7 @@ TEST_CASE("first only emits once") CHECK(mock.get_on_error_count() == 1); } - SECTION("observable of ---| - shall see -x") + SUBCASE("observable of ---| - shall see -x") { auto obs = rpp::source::empty(); obs | rpp::ops::first() @@ -81,7 +80,7 @@ TEST_CASE("first only emits once") TEST_CASE("first doesn't produce extra copies") { - SECTION("first()") + SUBCASE("first()") { copy_count_tracker::test_operator(rpp::ops::first(), { diff --git a/src/tests/rpp/test_flat_map.cpp b/src/tests/rpp/test_flat_map.cpp index a267db021..7ed7cec8b 100644 --- a/src/tests/rpp/test_flat_map.cpp +++ b/src/tests/rpp/test_flat_map.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -27,70 +26,70 @@ #include #include -TEMPLATE_TEST_CASE("flat_map", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("flat_map", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto mock = mock_observer_strategy(); - SECTION("observable of items") + SUBCASE("observable of items") { auto obs = rpp::source::just(rpp::schedulers::immediate{}, 1, 2, 3); - SECTION("subscribe using flat_map with templated lambda") + SUBCASE("subscribe using flat_map with templated lambda") { obs | rpp::operators::flat_map([](auto v) { return rpp::source::just(v * 2); }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from underlying observables") + SUBCASE("observer obtains values from underlying observables") { CHECK(mock.get_received_values() == std::vector{2, 4, 6}); CHECK(mock.get_on_completed_count() == 1); CHECK(mock.get_on_error_count() == 0); } } - SECTION("subscribe using flat_map with templated lambda and pass operator by variable") + SUBCASE("subscribe using flat_map with templated lambda and pass operator by variable") { const auto multiply_by_two = rpp::operators::flat_map([](auto v) { return rpp::source::just(v * 2); }); obs | multiply_by_two | rpp::ops::subscribe(mock); - SECTION("observer obtains values from underlying observables") + SUBCASE("observer obtains values from underlying observables") { CHECK(mock.get_received_values() == std::vector{2, 4, 6}); CHECK(mock.get_on_completed_count() == 1); CHECK(mock.get_on_error_count() == 0); } } - SECTION("subscribe using flat_map with error") + SUBCASE("subscribe using flat_map with error") { obs | rpp::operators::flat_map([](int) { return rpp::source::error(std::make_exception_ptr(std::runtime_error{""})); }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from underlying observables") + SUBCASE("observer obtains values from underlying observables") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_completed_count() == 0); CHECK(mock.get_on_error_count() == 1); } } - SECTION("subscribe using flat_map with empty") + SUBCASE("subscribe using flat_map with empty") { obs | rpp::operators::flat_map([](int) { return rpp::source::empty(); }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from underlying observables") + SUBCASE("observer obtains values from underlying observables") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_completed_count() == 1); CHECK(mock.get_on_error_count() == 0); } } - SECTION("subscribe using flat_map with never") + SUBCASE("subscribe using flat_map with never") { obs | rpp::operators::flat_map([](int) { return rpp::source::never(); }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from underlying observables") + SUBCASE("observer obtains values from underlying observables") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_completed_count() == 0); CHECK(mock.get_on_error_count() == 0); } } - SECTION("subscribe using flat_map with empty in middle") + SUBCASE("subscribe using flat_map with empty in middle") { obs | rpp::operators::flat_map([](int v) { if (v == 2) @@ -98,14 +97,14 @@ TEMPLATE_TEST_CASE("flat_map", "", rpp::memory_model::use_stack, rpp::memory_mod return rpp::source::just(v).as_dynamic(); }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from underlying observables") + SUBCASE("observer obtains values from underlying observables") { CHECK(mock.get_received_values() == std::vector{1, 3}); CHECK(mock.get_on_completed_count() == 1); CHECK(mock.get_on_error_count() == 0); } } - SECTION("subscribe using flat_map with never in middle") + SUBCASE("subscribe using flat_map with never in middle") { obs | rpp::operators::flat_map([](int v) { if (v == 2) @@ -113,14 +112,14 @@ TEMPLATE_TEST_CASE("flat_map", "", rpp::memory_model::use_stack, rpp::memory_mod return rpp::source::just(v).as_dynamic(); }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from underlying observables") + SUBCASE("observer obtains values from underlying observables") { CHECK(mock.get_received_values() == std::vector{1, 3}); CHECK(mock.get_on_completed_count() == 0); CHECK(mock.get_on_error_count() == 0); } } - SECTION("subscribe using flat_map with error in middle") + SUBCASE("subscribe using flat_map with error in middle") { obs | rpp::operators::flat_map([](int v) { if (v == 2) @@ -128,7 +127,7 @@ TEMPLATE_TEST_CASE("flat_map", "", rpp::memory_model::use_stack, rpp::memory_mod return rpp::source::just(v).as_dynamic(); }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from underlying observables") + SUBCASE("observer obtains values from underlying observables") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_completed_count() == 0); diff --git a/src/tests/rpp/test_from.cpp b/src/tests/rpp/test_from.cpp index f058c0f93..b66149837 100644 --- a/src/tests/rpp/test_from.cpp +++ b/src/tests/rpp/test_from.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -55,17 +54,17 @@ struct infinite_container }; -TEMPLATE_TEST_CASE("from iterable emit items from container", - "", - (std::pair), - (std::pair), - (std::pair), - (std::pair)) +TEST_CASE_TEMPLATE("from iterable emit items from container", + TestType, + std::pair, + std::pair, + std::pair, + std::pair) { using memory_model = std::tuple_element_t<1, TestType>; using scheduler = std::tuple_element_t<0, TestType>; auto mock = mock_observer_strategy(); - SECTION("observable created from vector emits items to observer in the same order") + SUBCASE("observable created from vector emits items to observer in the same order") { auto vals = std::vector{1, 2, 3, 4, 5, 6}; auto obs = rpp::source::from_iterable(vals, scheduler{}); @@ -74,7 +73,7 @@ TEMPLATE_TEST_CASE("from iterable emit items from container", CHECK(mock.get_on_completed_count() == 1); } - SECTION("observable created from empty vector emits only on_completed") + SUBCASE("observable created from empty vector emits only on_completed") { auto vals = std::vector{}; auto obs = rpp::source::from_iterable(vals, scheduler{}); @@ -83,7 +82,7 @@ TEMPLATE_TEST_CASE("from iterable emit items from container", CHECK(mock.get_on_completed_count() == 1); } - SECTION("subscribe via take(1) to observable created from infinite container") + SUBCASE("subscribe via take(1) to observable created from infinite container") { rpp::source::from_iterable(infinite_container{}, scheduler{}) | rpp::operators::take(1) | rpp::operators::subscribe(mock); @@ -92,34 +91,34 @@ TEMPLATE_TEST_CASE("from iterable emit items from container", CHECK(mock.get_on_completed_count() == 1); } - // SECTION("observable from iterable with scheduler") + // SUBCASE("observable from iterable with scheduler") // { // auto vals = std::vector{1, 2, 3, 4, 5, 6}; // auto run_loop = rpp::schedulers::run_loop{}; // auto obs = rpp::source::from_iterable(vals, run_loop); - // SECTION("subscribe on it and dispatch once") + // SUBCASE("subscribe on it and dispatch once") // { // obs.subscribe(mock); // run_loop.dispatch(); - // SECTION("observer obtains first value") + // SUBCASE("observer obtains first value") // { // CHECK(mock.get_received_values() == std::vector{1}); // CHECK(mock.get_on_error_count() == 0); // CHECK(mock.get_on_completed_count() == 0); // } - // AND_SECTION("dispatch till no events") + // AND_SUBCASE("dispatch till no events") // { // while (!run_loop.is_empty()) // run_loop.dispatch(); - // SECTION("observer obtains values in the same order") + // SUBCASE("observer obtains values in the same order") // { // CHECK(mock.get_received_values() == vals); // CHECK(mock.get_on_completed_count() == 1); // } // } // } - // SECTION("subscribe on it, unsubscribe on first on next and dispatch till not empty") + // SUBCASE("subscribe on it, unsubscribe on first on next and dispatch till not empty") // { // rpp::composite_subscription sub{}; // obs.subscribe(sub, @@ -136,7 +135,7 @@ TEMPLATE_TEST_CASE("from iterable emit items from container", // run_loop.dispatch(); // } - // SECTION("observer obtains first value") + // SUBCASE("observer obtains first value") // { // CHECK(mock.get_received_values() == std::vector{ 1 }); // CHECK(mock.get_on_error_count() == 0); @@ -146,13 +145,13 @@ TEMPLATE_TEST_CASE("from iterable emit items from container", // } // } // } - SECTION("observable from iterable with exceiption on begin") + SUBCASE("observable from iterable with exceiption on begin") { const auto obs = rpp::source::from_iterable(my_container_with_error{}, scheduler{}); - SECTION("subscribe on it and dispatch once") + SUBCASE("subscribe on it and dispatch once") { obs.subscribe(mock); - SECTION("observer obtains error") + SUBCASE("observer obtains error") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); @@ -162,11 +161,11 @@ TEMPLATE_TEST_CASE("from iterable emit items from container", } } -TEMPLATE_TEST_CASE("from iterable with different schedulers", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("from iterable with different schedulers", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto mock = mock_observer_strategy(); - SECTION("observable created from vector with scheduler emits values via provided scheduler") + SUBCASE("observable created from vector with scheduler emits values via provided scheduler") { auto obs_immediate = rpp::source::from_iterable(std::vector{1, 1, 1}, rpp::schedulers::immediate{}); auto obs_default = rpp::source::from_iterable(std::vector{2, 2, 2}); @@ -191,21 +190,21 @@ TEMPLATE_TEST_CASE("from iterable with different schedulers", "", rpp::memory_mo } } -TEMPLATE_TEST_CASE("from iterable doesn't provides extra copies", "", rpp::schedulers::current_thread, rpp::schedulers::immediate) +TEST_CASE_TEMPLATE("from iterable doesn't provides extra copies", TestType, rpp::schedulers::current_thread, rpp::schedulers::immediate) { copy_count_tracker tracker{}; auto vals = std::array{tracker}; auto initial_copy = tracker.get_copy_count(); auto initial_move = tracker.get_move_count(); - SECTION("observable from copied iterable doesn't provide extra copies") + SUBCASE("observable from copied iterable doesn't provide extra copies") { auto obs = rpp::source::from_iterable(vals, TestType{}); obs.subscribe([](const auto&) {}, [](const auto&) {}, []() {}); CHECK(tracker.get_copy_count() - initial_copy == 1); // 1 copy to observable CHECK(tracker.get_move_count() - initial_move == 0); } - SECTION("observable from moved iterable doesn't provide extra copies") + SUBCASE("observable from moved iterable doesn't provide extra copies") { auto obs = rpp::source::from_iterable(std::move(vals), TestType{}); obs.subscribe([](const auto&) {}, [](const auto&) {}, []() {}); @@ -213,14 +212,14 @@ TEMPLATE_TEST_CASE("from iterable doesn't provides extra copies", "", rpp::sched CHECK(tracker.get_move_count() - initial_move == 1); // 1 move to observable } - SECTION("observable from copied iterable with shared memory model doesn't provide extra copies") + SUBCASE("observable from copied iterable with shared memory model doesn't provide extra copies") { auto obs = rpp::source::from_iterable(vals, TestType{}); // NOLINT obs.subscribe([](const auto&) {}, [](const auto&) {}, []() {}); CHECK(tracker.get_copy_count() - initial_copy == 1); // 1 copy to shared_ptr CHECK(tracker.get_move_count() - initial_move == 0); } - SECTION("observable from moved iterable doesn't provide extra copies") + SUBCASE("observable from moved iterable doesn't provide extra copies") { auto obs = rpp::source::from_iterable(std::move(vals), TestType{}); // NOLINT obs.subscribe([](const auto&) {}, [](const auto&) {}, []() {}); @@ -233,7 +232,7 @@ TEST_CASE("from callable") { auto mock = mock_observer_strategy{}; - SECTION("observable from callable") + SUBCASE("observable from callable") { size_t count_of_calls{}; auto callable = [&count_of_calls]() -> int { @@ -241,10 +240,10 @@ TEST_CASE("from callable") }; auto observable = rpp::source::from_callable(callable); - SECTION("subscribe on this observable") + SUBCASE("subscribe on this observable") { observable.subscribe(mock); - SECTION("callable called only once and observable returns value of this function") + SUBCASE("callable called only once and observable returns value of this function") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_completed_count() == 1); @@ -252,7 +251,7 @@ TEST_CASE("from callable") } } } - SECTION("observable from callable with void") + SUBCASE("observable from callable with void") { size_t count_of_calls{}; auto callable = [&count_of_calls]() -> void { @@ -262,10 +261,10 @@ TEST_CASE("from callable") auto observable = rpp::source::from_callable(callable); auto none_mock = mock_observer_strategy{}; - SECTION("subscribe on this observable") + SUBCASE("subscribe on this observable") { observable.subscribe(none_mock); - SECTION("callable called only once and observable returns value of this function") + SUBCASE("callable called only once and observable returns value of this function") { CHECK(none_mock.get_received_values().size() == 1); CHECK(none_mock.get_on_completed_count() == 1); @@ -273,7 +272,7 @@ TEST_CASE("from callable") } } } - SECTION("observable from callable with error") + SUBCASE("observable from callable with error") { volatile bool none{true}; auto callable = [&]() -> int { @@ -281,10 +280,10 @@ TEST_CASE("from callable") return 0; }; auto observable = rpp::source::from_callable(callable); - SECTION("subscribe on this observable") + SUBCASE("subscribe on this observable") { observable.subscribe(mock); - SECTION("observer obtains error") + SUBCASE("observer obtains error") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); @@ -298,14 +297,14 @@ TEST_CASE("just") { mock_observer_strategy mock{false}; - SECTION("observable with copied item") + SUBCASE("observable with copied item") { copy_count_tracker v{}; auto obs = rpp::source::just(v); - SECTION("subscribe on this observable") + SUBCASE("subscribe on this observable") { obs.subscribe(mock); - SECTION("value obtained") + SUBCASE("value obtained") { CHECK(mock.get_on_next_const_ref_count() == 1); CHECK(mock.get_on_next_move_count() == 0); @@ -315,14 +314,14 @@ TEST_CASE("just") } } } - SECTION("observable with moved item") + SUBCASE("observable with moved item") { copy_count_tracker v{}; auto obs = rpp::source::just(std::move(v)); - SECTION("subscribe on this observable") + SUBCASE("subscribe on this observable") { obs.subscribe(mock); - SECTION("value obtained") + SUBCASE("value obtained") { CHECK(mock.get_on_next_const_ref_count() == 1); CHECK(mock.get_on_next_move_count() == 0); @@ -332,14 +331,14 @@ TEST_CASE("just") } } } - SECTION("observable with copied item + use_shared") + SUBCASE("observable with copied item + use_shared") { copy_count_tracker v{}; auto obs = rpp::source::just(v); - SECTION("subscribe on this observable") + SUBCASE("subscribe on this observable") { obs.subscribe(mock); - SECTION("value obtained") + SUBCASE("value obtained") { CHECK(mock.get_on_next_const_ref_count() == 1); CHECK(mock.get_on_next_move_count() == 0); @@ -349,14 +348,14 @@ TEST_CASE("just") } } } - SECTION("observable with moved item + use_shared") + SUBCASE("observable with moved item + use_shared") { copy_count_tracker v{}; auto obs = rpp::source::just(std::move(v)); - SECTION("subscribe on this observable") + SUBCASE("subscribe on this observable") { obs.subscribe(mock); - SECTION("value obtained") + SUBCASE("value obtained") { CHECK(mock.get_on_next_const_ref_count() == 1); CHECK(mock.get_on_next_move_count() == 0); @@ -368,34 +367,34 @@ TEST_CASE("just") } } -TEMPLATE_TEST_CASE("just variadic", - "", - (std::pair), - (std::pair), - (std::pair), - (std::pair)) +TEST_CASE_TEMPLATE("just variadic", + TestType, + std::pair, + std::pair, + std::pair, + std::pair) { using memory_model = std::tuple_element_t<1, TestType>; using scheduler = std::tuple_element_t<0, TestType>; auto mock = mock_observer_strategy(); - SECTION("observable just variadic") + SUBCASE("observable just variadic") { auto obs = rpp::source::just(scheduler{}, 1, 2, 3, 4, 5, 6); - SECTION("subscribe on it") + SUBCASE("subscribe on it") { obs.subscribe(mock); - SECTION("observer obtains values in the same order") + SUBCASE("observer obtains values in the same order") { CHECK(mock.get_received_values() == std::vector{1, 2, 3, 4, 5, 6}); CHECK(mock.get_on_completed_count() == 1); } - SECTION("subscribe twice on same observer") + SUBCASE("subscribe twice on same observer") { obs.subscribe(mock); - SECTION("observer obtains values in the same order twice") + SUBCASE("observer obtains values in the same order twice") { CHECK(mock.get_received_values() == std::vector{1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6}); CHECK(mock.get_on_completed_count() == 2); diff --git a/src/tests/rpp/test_group_by.cpp b/src/tests/rpp/test_group_by.cpp index 76d5c43b1..5badc3665 100644 --- a/src/tests/rpp/test_group_by.cpp +++ b/src/tests/rpp/test_group_by.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -26,20 +25,20 @@ #include -TEST_CASE("group_by emits grouped seqences of values with identity key selector", "[group_by]") +TEST_CASE("group_by emits grouped seqences of values with identity key selector") { auto obs = mock_observer_strategy>{}; std::map> grouped_mocks{}; auto observable = rpp::source::just(1, 2, 3, 4, 4, 3, 2, 1) | rpp::operators::group_by(std::identity{}); - SECTION("Obtained same amount of grouped observables as amount of unique values") + SUBCASE("Obtained same amount of grouped observables as amount of unique values") { observable.subscribe(obs); REQUIRE(obs.get_total_on_next_count() == 4); REQUIRE(obs.get_on_error_count() == 0); REQUIRE(obs.get_on_completed_count() == 1); } - SECTION("each grouped observable emits only same values") + SUBCASE("each grouped observable emits only same values") { observable.subscribe([&](const auto& grouped) { REQUIRE(grouped_mocks.contains(grouped.get_key()) == false); @@ -55,7 +54,7 @@ TEST_CASE("group_by emits grouped seqences of values with identity key selector" REQUIRE(observer.get_on_completed_count() == 1); } } - SECTION("grouped observables with key 4 unsubscribed early") + SUBCASE("grouped observables with key 4 unsubscribed early") { observable.subscribe([&](const auto& grouped) { auto key = grouped.get_key(); @@ -67,7 +66,7 @@ TEST_CASE("group_by emits grouped seqences of values with identity key selector" grouped.subscribe(grouped_mocks[key]); }); - SECTION("all except of key 4 obtains as before, but key 4 obtained once") + SUBCASE("all except of key 4 obtains as before, but key 4 obtained once") { REQUIRE(grouped_mocks.size() == 4); for (const auto& [key, observer] : grouped_mocks) @@ -82,12 +81,12 @@ TEST_CASE("group_by emits grouped seqences of values with identity key selector" } } } - SECTION("subscribe only on one grouped observable and unsubcribe from root") + SUBCASE("subscribe only on one grouped observable and unsubcribe from root") { observable | rpp::ops::take(1) | rpp::ops::subscribe([&](const auto& grouped) { grouped.subscribe(grouped_mocks[grouped.get_key()]); }); - SECTION("values for such a observable are still obtainable") + SUBCASE("values for such a observable are still obtainable") { REQUIRE(grouped_mocks.size() == 1); @@ -145,19 +144,19 @@ TEST_CASE("group_by keeps subscription till anyone subscribed") REQUIRE(!observable_upstream.is_disposed()); REQUIRE(disposables.size() == 2); REQUIRE(rpp::utils::all_of(disposables, [](const auto& d) { return !d.is_disposed(); })); - SECTION("dispose root") + SUBCASE("dispose root") { d.dispose(); REQUIRE(rpp::utils::all_of(disposables, [](const auto& d) { return !d.is_disposed(); })); REQUIRE(!observable_upstream.is_disposed()); } - SECTION("disposing other disposables") + SUBCASE("disposing other disposables") { rpp::utils::for_each(disposables, std::mem_fn(&rpp::composite_disposable_wrapper::dispose)); REQUIRE(!d.is_disposed()); REQUIRE(!observable_upstream.is_disposed()); } - SECTION("dispose all") + SUBCASE("dispose all") { d.dispose(); rpp::utils::for_each(disposables, std::mem_fn(&rpp::composite_disposable_wrapper::dispose)); @@ -165,7 +164,7 @@ TEST_CASE("group_by keeps subscription till anyone subscribed") REQUIRE(d.is_disposed()); REQUIRE(rpp::utils::all_of(disposables, [](const auto& d) { return d.is_disposed(); })); } - SECTION("send on_error") + SUBCASE("send on_error") { extracted->on_error(std::make_exception_ptr(std::runtime_error{""})); REQUIRE(d.is_disposed()); @@ -173,7 +172,7 @@ TEST_CASE("group_by keeps subscription till anyone subscribed") REQUIRE(rpp::utils::all_of(disposables, [](const auto& d) { return d.is_disposed(); })); REQUIRE(on_error_count == disposables.size() + 1); } - SECTION("send on_completed") + SUBCASE("send on_completed") { extracted->on_completed(); REQUIRE(d.is_disposed()); @@ -183,10 +182,10 @@ TEST_CASE("group_by keeps subscription till anyone subscribed") } } -TEST_CASE("group_by selectors affects types", "[group_by]") +TEST_CASE("group_by selectors affects types") { auto obs = rpp::source::just(1, 2, 3, 1, 2, 3); - SECTION("subscribe on observable via group_by with const key selector") + SUBCASE("subscribe on observable via group_by with const key selector") { std::vector keys{}; obs | rpp::ops::group_by([](int) { return 1; }) @@ -194,12 +193,12 @@ TEST_CASE("group_by selectors affects types", "[group_by]") keys.push_back(grouped.get_key()); }); - SECTION("only one unique key obtained") + SUBCASE("only one unique key obtained") { REQUIRE(keys == std::vector{1}); } } - SECTION("subscribe on observable via group_by with identity key selector") + SUBCASE("subscribe on observable via group_by with identity key selector") { std::vector keys{}; obs | rpp::ops::group_by(std::identity{}) @@ -207,12 +206,12 @@ TEST_CASE("group_by selectors affects types", "[group_by]") keys.push_back(grouped.get_key()); }); - SECTION("all values obtained as keys") + SUBCASE("all values obtained as keys") { REQUIRE(keys == std::vector{1, 2, 3}); } } - SECTION("subscribe on observable via group_by with value selector") + SUBCASE("subscribe on observable via group_by with value selector") { auto mock = mock_observer_strategy{}; obs | rpp::ops::group_by(std::identity{}, [](int v) { return std::to_string(v); }) @@ -220,14 +219,14 @@ TEST_CASE("group_by selectors affects types", "[group_by]") grouped.subscribe(mock); }); - SECTION("grouped observables provides modified values") + SUBCASE("grouped observables provides modified values") { using namespace std::string_literals; REQUIRE(mock.get_received_values() == std::vector{"1"s, "2"s, "3"s, "1"s, "2"s, "3"s}); } } - SECTION("subscribe on observable via group_by with custom comparator") + SUBCASE("subscribe on observable via group_by with custom comparator") { std::vector keys{}; obs | rpp::ops::group_by(std::identity{}, std::identity{}, [](int f, int s) { @@ -236,18 +235,18 @@ TEST_CASE("group_by selectors affects types", "[group_by]") keys.push_back(grouped.get_key()); }); - SECTION("only 2 types of keys interpreted as unique") + SUBCASE("only 2 types of keys interpreted as unique") { REQUIRE(keys == std::vector{1, 2}); } } auto mock = mock_observer_strategy>{}; - SECTION("subscribe on observable via group_by with key selector with exception") + SUBCASE("subscribe on observable via group_by with key selector with exception") { obs | rpp::ops::group_by([](int) -> int { throw std::runtime_error{""}; }) | rpp::ops::subscribe(mock); - SECTION("on_error obtained once") + SUBCASE("on_error obtained once") { REQUIRE(mock.get_total_on_next_count() == 0); REQUIRE(mock.get_on_error_count() == 1); @@ -255,11 +254,11 @@ TEST_CASE("group_by selectors affects types", "[group_by]") } } - SECTION("subscribe on observable via group_by with value selector with exception") + SUBCASE("subscribe on observable via group_by with value selector with exception") { obs | rpp::ops::group_by(std::identity{}, [](int) -> int { throw std::runtime_error{""}; }) | rpp::ops::subscribe(mock); - SECTION("on_error obtained once") + SUBCASE("on_error obtained once") { REQUIRE(mock.get_total_on_next_count() == 1); REQUIRE(mock.get_on_error_count() == 1); diff --git a/src/tests/rpp/test_interval.cpp b/src/tests/rpp/test_interval.cpp index 8f8c1d126..08ee6e991 100644 --- a/src/tests/rpp/test_interval.cpp +++ b/src/tests/rpp/test_interval.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -28,17 +27,17 @@ TEST_CASE("interval emit values with provided interval") auto scheduler = rpp::schedulers::test_scheduler{}; auto mock = mock_observer_strategy{}; - SECTION("interval observable") + SUBCASE("interval observable") { auto interval = std::chrono::seconds{1}; auto obs = rpp::source::interval(interval, scheduler); auto initial_time = rpp::schedulers::test_scheduler::worker_strategy::now(); - SECTION("subscribe on it via take 3") + SUBCASE("subscribe on it via take 3") { obs | rpp::ops::take(3) | rpp::ops::subscribe(mock); - SECTION("nothing happens immediately till scheduler advanced") + SUBCASE("nothing happens immediately till scheduler advanced") { CHECK(mock.get_received_values() == std::vector{}); CHECK(mock.get_on_error_count() == 0); @@ -47,37 +46,37 @@ TEST_CASE("interval emit values with provided interval") CHECK(scheduler.get_executions().empty()); } - SECTION("move time in advance on interval once") + SUBCASE("move time in advance on interval once") { scheduler.time_advance(interval); - SECTION("observer obtains first value") + SUBCASE("observer obtains first value") { CHECK(mock.get_received_values() == std::vector{0}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("interval schedules schedulable with provided interval") + SUBCASE("interval schedules schedulable with provided interval") { CHECK(scheduler.get_schedulings() == std::vector{initial_time + interval, initial_time + 2 * interval}); CHECK(scheduler.get_executions() == std::vector{initial_time + interval}); } } - SECTION("move time in advance on interval enough amount of time") + SUBCASE("move time in advance on interval enough amount of time") { for (size_t i = 0; i < 5; ++i) scheduler.time_advance(interval); - SECTION("observer obtains sequence of values") + SUBCASE("observer obtains sequence of values") { CHECK(mock.get_received_values() == std::vector{0, 1, 2}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } - SECTION("interval schedules schedulable with provided interval") + SUBCASE("interval schedules schedulable with provided interval") { CHECK(scheduler.get_executions() == std::vector{initial_time + interval, initial_time + 2 * interval, initial_time + 3 * interval}); CHECK(scheduler.get_schedulings() == std::vector{initial_time + interval, initial_time + 2 * interval, initial_time + 3 * interval}); @@ -86,18 +85,18 @@ TEST_CASE("interval emit values with provided interval") } } - SECTION("interval observable with initial delay duration") + SUBCASE("interval observable with initial delay duration") { auto initial_delay = std::chrono::seconds{2}; auto interval = std::chrono::seconds{1}; auto obs = rpp::source::interval(initial_delay, interval, scheduler); auto initial_time = rpp::schedulers::test_scheduler::worker_strategy::now(); - SECTION("subscribe on it via take 3") + SUBCASE("subscribe on it via take 3") { obs | rpp::ops::take(3) | rpp::ops::subscribe(mock); - SECTION("nothing happens immediately till scheduler advanced") + SUBCASE("nothing happens immediately till scheduler advanced") { CHECK(mock.get_received_values() == std::vector{}); CHECK(mock.get_on_error_count() == 0); @@ -106,20 +105,20 @@ TEST_CASE("interval emit values with provided interval") CHECK(scheduler.get_executions().empty()); } - SECTION("move time in advance on interval enough amount of time") + SUBCASE("move time in advance on interval enough amount of time") { for (size_t i = 0; i < 5; ++i) scheduler.time_advance(interval); scheduler.time_advance(interval); - SECTION("observer obtains sequence of values") + SUBCASE("observer obtains sequence of values") { CHECK(mock.get_received_values() == std::vector{0, 1, 2}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } - SECTION("interval schedules schedulable with provided interval") + SUBCASE("interval schedules schedulable with provided interval") { CHECK(scheduler.get_schedulings() == std::vector{initial_time + initial_delay, initial_time + initial_delay + interval, initial_time + initial_delay + 2 * interval}); CHECK(scheduler.get_executions() == std::vector{initial_time + initial_delay, initial_time + initial_delay + interval, initial_time + initial_delay + 2 * interval}); @@ -128,19 +127,19 @@ TEST_CASE("interval emit values with provided interval") } } - SECTION("interval observable with initial delay time_point") + SUBCASE("interval observable with initial delay time_point") { auto when = std::chrono::seconds{2}; auto initial_delay = scheduler.now() + when; auto interval = std::chrono::seconds{1}; auto obs = rpp::source::interval(initial_delay, interval, scheduler); - SECTION("subscribe") + SUBCASE("subscribe") { scheduler.time_advance(when * 2); obs | rpp::ops::take(1) | rpp::ops::subscribe(mock); - SECTION("expect value as initial_delay time_point is in the past") + SUBCASE("expect value as initial_delay time_point is in the past") { CHECK(mock.get_received_values() == std::vector{0}); CHECK(mock.get_on_error_count() == 0); diff --git a/src/tests/rpp/test_last.cpp b/src/tests/rpp/test_last.cpp index 21a110f5b..a219066d9 100644 --- a/src/tests/rpp/test_last.cpp +++ b/src/tests/rpp/test_last.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -26,7 +25,7 @@ TEST_CASE("last only emits once") { auto mock = mock_observer_strategy{}; - SECTION("observable of -1-| - shall see -1-|") + SUBCASE("observable of -1-| - shall see -1-|") { rpp::source::just(1) | rpp::ops::last() @@ -37,7 +36,7 @@ TEST_CASE("last only emits once") CHECK(mock.get_on_error_count() == 0); } - SECTION("observable of -1-2-3-| - shall see -3-|") + SUBCASE("observable of -1-2-3-| - shall see -3-|") { rpp::source::just(1, 2, 3) | rpp::ops::last() @@ -48,7 +47,7 @@ TEST_CASE("last only emits once") CHECK(mock.get_on_error_count() == 0); } - SECTION("observable of never - shall not see neither completed nor error event") + SUBCASE("observable of never - shall not see neither completed nor error event") { rpp::source::never() | rpp::ops::last() @@ -59,7 +58,7 @@ TEST_CASE("last only emits once") CHECK(mock.get_on_error_count() == 0); } - SECTION("observable of x-| - shall see error and no-completed event") + SUBCASE("observable of x-| - shall see error and no-completed event") { rpp::source::error(std::make_exception_ptr(std::runtime_error{""})) | rpp::ops::last() @@ -70,7 +69,7 @@ TEST_CASE("last only emits once") CHECK(mock.get_on_error_count() == 1); } - SECTION("observable of ---| - shall see -x") + SUBCASE("observable of ---| - shall see -x") { rpp::source::empty() | rpp::ops::last() @@ -84,7 +83,7 @@ TEST_CASE("last only emits once") TEST_CASE("last doesn't produce extra copies") { - SECTION("last()") + SUBCASE("last()") { copy_count_tracker::test_operator(rpp::ops::last(), { diff --git a/src/tests/rpp/test_map.cpp b/src/tests/rpp/test_map.cpp index 23a9824be..e2207092d 100644 --- a/src/tests/rpp/test_map.cpp +++ b/src/tests/rpp/test_map.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -21,11 +20,11 @@ #include #include -TEMPLATE_TEST_CASE("map modifies values and forward errors/completions", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("map modifies values and forward errors/completions", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto obs = rpp::source::just(1, 2); - SECTION("map changes value") + SUBCASE("map changes value") { mock_observer mock{}; trompeloeil::sequence seq; @@ -38,7 +37,7 @@ TEMPLATE_TEST_CASE("map modifies values and forward errors/completions", "", rpp } - SECTION("map with exception value") + SUBCASE("map with exception value") { mock_observer mock{}; trompeloeil::sequence seq; @@ -54,7 +53,7 @@ TEMPLATE_TEST_CASE("map modifies values and forward errors/completions", "", rpp TEST_CASE("map doesn't produce extra copies") { - SECTION("map([](auto&& v){return std::forward(v);})") + SUBCASE("map([](auto&& v){return std::forward(v);})") { copy_count_tracker::test_operator(rpp::ops::map([](auto&& v) { return std::forward(v); }), { diff --git a/src/tests/rpp/test_merge.cpp b/src/tests/rpp/test_merge.cpp index 0ee6c65ec..1df94ad63 100644 --- a/src/tests/rpp/test_merge.cpp +++ b/src/tests/rpp/test_merge.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -28,17 +27,17 @@ #include #include -TEMPLATE_TEST_CASE("merge for observable of observables", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("merge for observable of observables", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto mock = mock_observer_strategy(); - SECTION("observable of observables") + SUBCASE("observable of observables") { auto obs = rpp::source::just(rpp::schedulers::immediate{}, rpp::source::just(rpp::schedulers::immediate{}, 1), rpp::source::just(rpp::schedulers::immediate{}, 2)); - SECTION("subscribe on merge of observable") + SUBCASE("subscribe on merge of observable") { obs | rpp::operators::merge() | rpp::ops::subscribe(mock); - SECTION("observer obtains values FROM underlying observables") + SUBCASE("observer obtains values FROM underlying observables") { CHECK(mock.get_received_values() == std::vector{1, 2}); CHECK(mock.get_on_completed_count() == 1); @@ -46,38 +45,38 @@ TEMPLATE_TEST_CASE("merge for observable of observables", "", rpp::memory_model: } } - SECTION("observable of observables with first never") + SUBCASE("observable of observables with first never") { auto obs = rpp::source::just(rpp::source::never().as_dynamic(), rpp::source::just(2).as_dynamic()); - SECTION("subscribe on merge of observable") + SUBCASE("subscribe on merge of observable") { obs | rpp::ops::merge() | rpp::ops::subscribe(mock); - SECTION("observer obtains values from second observable even if first emits nothing") + SUBCASE("observer obtains values from second observable even if first emits nothing") { CHECK(mock.get_received_values() == std::vector{2}); CHECK(mock.get_on_completed_count() == 0); // no complete due to first observable sends nothing } } } - SECTION("observable of observables without complete") + SUBCASE("observable of observables without complete") { auto obs = rpp::source::create>([](const auto& sub) { sub.on_next(rpp::source::just(1).as_dynamic()); sub.on_next(rpp::source::just(2).as_dynamic()); }); - SECTION("subscribe on merge of observable") + SUBCASE("subscribe on merge of observable") { obs | rpp::ops::merge() | rpp::ops::subscribe(mock); - SECTION("observer obtains values from second observable even if first emits nothing") + SUBCASE("observer obtains values from second observable even if first emits nothing") { CHECK(mock.get_received_values() == std::vector{1, 2}); CHECK(mock.get_on_completed_count() == 0); // no complete due to root observable is not completed } } } - SECTION("observable of observables with error") + SUBCASE("observable of observables with error") { auto obs = rpp::source::create>([](const auto& sub) { sub.on_next(rpp::source::just(rpp::schedulers::immediate{}, 1).as_dynamic()); @@ -85,10 +84,10 @@ TEMPLATE_TEST_CASE("merge for observable of observables", "", rpp::memory_model: sub.on_next(rpp::source::just(rpp::schedulers::immediate{}, 2).as_dynamic()); }); - SECTION("subscribe on merge of observable") + SUBCASE("subscribe on merge of observable") { obs | rpp::ops::merge() | rpp::ops::subscribe(mock); - SECTION("observer obtains values from second observable even if first emits nothing") + SUBCASE("observer obtains values from second observable even if first emits nothing") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_error_count() == 1); @@ -96,17 +95,17 @@ TEMPLATE_TEST_CASE("merge for observable of observables", "", rpp::memory_model: } } } - SECTION("observable of observables with error") + SUBCASE("observable of observables with error") { auto obs = rpp::source::create>([](const auto& sub) { sub.on_error(std::make_exception_ptr(std::runtime_error{""})); sub.on_next(rpp::source::just(1).as_dynamic()); }); - SECTION("subscribe on merge of observable") + SUBCASE("subscribe on merge of observable") { obs | rpp::ops::merge() | rpp::ops::subscribe(mock); - SECTION("observer obtains values from second observable even if first emits nothing") + SUBCASE("observer obtains values from second observable even if first emits nothing") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); @@ -116,18 +115,18 @@ TEMPLATE_TEST_CASE("merge for observable of observables", "", rpp::memory_model: } } -TEMPLATE_TEST_CASE("merge_with", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("merge_with", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto mock = mock_observer_strategy(); - SECTION("2 observables") + SUBCASE("2 observables") { auto obs_1 = rpp::source::just(1); auto obs_2 = rpp::source::just(2); - SECTION("subscribe on merge of this observables") + SUBCASE("subscribe on merge of this observables") { obs_1 | rpp::ops::merge_with(obs_2) | rpp::ops::subscribe(mock); - SECTION("observer obtains values FROM both observables") + SUBCASE("observer obtains values FROM both observables") { CHECK(mock.get_received_values() == std::vector{1, 2}); CHECK(mock.get_on_completed_count() == 1); @@ -135,26 +134,26 @@ TEMPLATE_TEST_CASE("merge_with", "", rpp::memory_model::use_stack, rpp::memory_m } } - SECTION("never observable with just observable") + SUBCASE("never observable with just observable") { auto obs_1 = rpp::source::never(); auto obs_2 = rpp::source::just(2); - SECTION("subscribe on merge of this observables") + SUBCASE("subscribe on merge of this observables") { auto op = rpp::ops::merge_with(obs_2); obs_1 | op | rpp::ops::subscribe(mock); - SECTION("observer obtains values FROM both observables") + SUBCASE("observer obtains values FROM both observables") { CHECK(mock.get_received_values() == std::vector{2}); CHECK(mock.get_on_completed_count() == 0); // first observable never completes } } - SECTION("subscribe on merge of this observables in reverse oreder") + SUBCASE("subscribe on merge of this observables in reverse oreder") { obs_2 | rpp::ops::merge_with(obs_1) | rpp::ops::subscribe(mock); - SECTION("observer obtains values FROM both observables") + SUBCASE("observer obtains values FROM both observables") { CHECK(mock.get_received_values() == std::vector{2}); CHECK(mock.get_on_completed_count() == 0); // first observable never completes @@ -162,15 +161,15 @@ TEMPLATE_TEST_CASE("merge_with", "", rpp::memory_model::use_stack, rpp::memory_m } } - SECTION("error observable with just observable") + SUBCASE("error observable with just observable") { auto obs_1 = rpp::source::error(std::make_exception_ptr(std::runtime_error{""})); auto obs_2 = rpp::source::just(2); - SECTION("subscribe on merge of this observables") + SUBCASE("subscribe on merge of this observables") { obs_1 | rpp::ops::merge_with(obs_2) | rpp::ops::subscribe(mock); - SECTION("observer obtains values FROM both observables") + SUBCASE("observer obtains values FROM both observables") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); @@ -180,15 +179,15 @@ TEMPLATE_TEST_CASE("merge_with", "", rpp::memory_model::use_stack, rpp::memory_m } } -TEMPLATE_TEST_CASE("merge serializes emissions", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("merge serializes emissions", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { - SECTION("observables from different threads") + SUBCASE("observables from different threads") { auto s1 = rpp::source::just(rpp::schedulers::new_thread{}, 1); auto s2 = rpp::source::just(rpp::schedulers::new_thread{}, 2); - SECTION("subscribe on merge of this observables") + SUBCASE("subscribe on merge of this observables") { - SECTION("resulting observable emits items sequentially") + SUBCASE("resulting observable emits items sequentially") { std::atomic_size_t counter{}; size_t max_value = 0; @@ -207,9 +206,9 @@ TEMPLATE_TEST_CASE("merge serializes emissions", "", rpp::memory_model::use_stac } } -TEMPLATE_TEST_CASE("merge handles race condition", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("merge handles race condition", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { - SECTION("source observable in current thread pairs with error in other thread") + SUBCASE("source observable in current thread pairs with error in other thread") { std::atomic_bool on_error_called{false}; std::optional> extracted_obs{}; @@ -218,9 +217,9 @@ TEMPLATE_TEST_CASE("merge handles race condition", "", rpp::memory_model::use_st }); auto test = [&](auto source) { - SECTION("subscribe on it") + SUBCASE("subscribe on it") { - SECTION("on_error can't interleave with on_next") + SUBCASE("on_error can't interleave with on_next") { source | rpp::ops::as_blocking() @@ -239,10 +238,10 @@ TEMPLATE_TEST_CASE("merge handles race condition", "", rpp::memory_model::use_st } } }; - SECTION("just + merge_with") + SUBCASE("just + merge_with") test(rpp::source::just(1, 1, 1) | rpp::ops::merge_with(delayed_obs)); - SECTION("just(just) + merge") + SUBCASE("just(just) + merge") test(rpp::source::just(rpp::schedulers::immediate{}, rpp::source::just(1, 1, 1).as_dynamic(), delayed_obs.as_dynamic()) | rpp::ops::merge()); } } @@ -261,7 +260,7 @@ TEST_CASE("merge dispose inner_disposable immediately") TEST_CASE("merge doesn't produce extra copies") { - SECTION("send value by copy") + SUBCASE("send value by copy") { copy_count_tracker verifier{}; auto obs = rpp::source::just(verifier.get_observable()) | rpp::ops::merge(); @@ -270,7 +269,7 @@ TEST_CASE("merge doesn't produce extra copies") REQUIRE(verifier.get_move_count() == 0); } - SECTION("send value by move") + SUBCASE("send value by move") { copy_count_tracker verifier{}; auto obs = rpp::source::just(verifier.get_observable_for_move()) | rpp::ops::merge(); diff --git a/src/tests/rpp/test_observables.cpp b/src/tests/rpp/test_observables.cpp index 2aeb295b3..a205308f4 100644 --- a/src/tests/rpp/test_observables.cpp +++ b/src/tests/rpp/test_observables.cpp @@ -7,8 +7,7 @@ // // Project home: https://github.com/victimsnino/ReactivePlusPlus -#include -#include +#include #include #include @@ -37,7 +36,7 @@ TEST_CASE("create observable works properly as observable") }); auto test = [&](auto&& observable) { - SECTION("subscribe valid observer") + SUBCASE("subscribe valid observer") { std::vector on_next_vals{}; size_t on_error{}; @@ -53,7 +52,7 @@ TEST_CASE("create observable works properly as observable") CHECK(on_completed == 1u); } - SECTION("subscribe disposed callbacks") + SUBCASE("subscribe disposed callbacks") { observable.subscribe( rpp::composite_disposable_wrapper::empty(), @@ -64,14 +63,14 @@ TEST_CASE("create observable works properly as observable") CHECK(on_subscribe_called == 0u); } - SECTION("subscribe disposed observer") + SUBCASE("subscribe disposed observer") { observable.subscribe(rpp::composite_disposable_wrapper::empty(), rpp::make_lambda_observer([](int) {}, [](const std::exception_ptr&) {}, []() {})); CHECK(on_subscribe_called == 0u); } - SECTION("subscribe non-disposed callbacks") + SUBCASE("subscribe non-disposed callbacks") { observable.subscribe( rpp::composite_disposable_wrapper::make(), @@ -82,7 +81,7 @@ TEST_CASE("create observable works properly as observable") CHECK(on_subscribe_called == 1u); } - SECTION("subscribe non-disposed observer") + SUBCASE("subscribe non-disposed observer") { observable.subscribe(rpp::composite_disposable_wrapper::make(), rpp::make_lambda_observer([](int) {}, [](const std::exception_ptr&) {}, []() {})); @@ -90,17 +89,17 @@ TEST_CASE("create observable works properly as observable") } }; - SECTION("original observable") + SUBCASE("original observable") { test(observable); } - SECTION("dynamic observable") + SUBCASE("dynamic observable") { test(observable.as_dynamic()); } - SECTION("dynamic observable via move") + SUBCASE("dynamic observable via move") { test(std::move(observable).as_dynamic()); // NOLINT } @@ -109,7 +108,7 @@ TEST_CASE("create observable works properly as observable") TEST_CASE("blocking_observable blocks subscribe call") { mock_observer_strategy mock{}; - SECTION("on_completed inside observable") + SUBCASE("on_completed inside observable") { rpp::source::create([](auto&& observer) { std::thread( @@ -124,7 +123,7 @@ TEST_CASE("blocking_observable blocks subscribe call") CHECK(mock.get_on_completed_count() == 1); } - SECTION("on_error inside observable") + SUBCASE("on_error inside observable") { auto op = rpp::operators::as_blocking(); auto obs = rpp::source::create([](auto&& observer) { @@ -142,7 +141,7 @@ TEST_CASE("blocking_observable blocks subscribe call") CHECK(mock.get_on_error_count() == 1); } - SECTION("as_blocking + take(1)") + SUBCASE("as_blocking + take(1)") { rpp::source::create([](const auto& obs) { obs.on_next(1); @@ -160,13 +159,13 @@ TEST_CASE("base observables") { mock_observer_strategy mock{}; - SECTION("empty") + SUBCASE("empty") { auto observable = rpp::source::empty(); - SECTION("subscribe on this observable") + SUBCASE("subscribe on this observable") { observable.subscribe(mock); - SECTION("only on_completed called") + SUBCASE("only on_completed called") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); @@ -174,13 +173,13 @@ TEST_CASE("base observables") } } } - SECTION("never") + SUBCASE("never") { auto observable = rpp::source::never(); - SECTION("subscribe on this observable") + SUBCASE("subscribe on this observable") { observable.subscribe(mock); - SECTION("no any callbacks") + SUBCASE("no any callbacks") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); @@ -188,13 +187,13 @@ TEST_CASE("base observables") } } } - SECTION("error") + SUBCASE("error") { auto observable = rpp::source::error(std::make_exception_ptr(std::runtime_error{"MY EXCEPTION"})); - SECTION("subscribe on this observable") + SUBCASE("subscribe on this observable") { observable.subscribe(mock); - SECTION("only on_error callback once") + SUBCASE("only on_error callback once") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); @@ -206,7 +205,7 @@ TEST_CASE("base observables") TEST_CASE("pipe observable works properly as observable") { - SECTION("using const& variant") + SUBCASE("using const& variant") { auto observable = rpp::source::create([](auto&& observer) { observer.on_next(1); @@ -223,7 +222,7 @@ TEST_CASE("pipe observable works properly as observable") CHECK(pipe_operator_observer.get_on_error_count() == pipe_function_observer.get_on_error_count()); CHECK(pipe_operator_observer.get_on_completed_count() == pipe_function_observer.get_on_completed_count()); } - SECTION("using && variant") + SUBCASE("using && variant") { mock_observer_strategy pipe_operator_observer{}; mock_observer_strategy pipe_function_observer{}; @@ -244,21 +243,21 @@ TEST_CASE("pipe observable works properly as observable") } } -TEMPLATE_TEST_CASE( +TEST_CASE_TEMPLATE( "observable has type traits defined", - "", - (rpp::empty_observable), - (rpp::dynamic_observable), - (rpp::blocking_observable>), - (rpp::connectable_observable, rpp::subjects::replay_subject>), - (rpp::grouped_observable>)) + TestType, + rpp::empty_observable, + rpp::dynamic_observable, + rpp::blocking_observable>, + rpp::connectable_observable, rpp::subjects::replay_subject>, + rpp::grouped_observable>) { - SECTION("value_type defined") + SUBCASE("value_type defined") { CHECK(requires { typename TestType::value_type; }); CHECK(std::is_same_v); } - SECTION("strategy_type defined") + SUBCASE("strategy_type defined") { CHECK(requires { typename TestType::strategy_type; }); } diff --git a/src/tests/rpp/test_observers.cpp b/src/tests/rpp/test_observers.cpp index 11d890cab..e632d58b4 100644 --- a/src/tests/rpp/test_observers.cpp +++ b/src/tests/rpp/test_observers.cpp @@ -7,8 +7,7 @@ // // Project home: https://github.com/victimsnino/ReactivePlusPlus -#include -#include +#include #include @@ -34,7 +33,7 @@ TEST_CASE("lambda observer works properly as base observer") obs.on_next(v); CHECK(on_next_vals == std::vector{1, 2}); - SECTION("send on_error first") + SUBCASE("send on_error first") { CHECK(!obs.is_disposed()); @@ -47,7 +46,7 @@ TEST_CASE("lambda observer works properly as base observer") CHECK(obs.is_disposed()); } - SECTION("send on_completed first") + SUBCASE("send on_completed first") { CHECK(!obs.is_disposed()); @@ -61,13 +60,13 @@ TEST_CASE("lambda observer works properly as base observer") } }; - SECTION("lambda observer obtains callbacks") + SUBCASE("lambda observer obtains callbacks") { static_assert(!std::is_copy_constructible_v, "lambda observer shouldn't be copy constructible"); test_observer(observer); } - SECTION("lambda observer obtains callbacks via cast to dynamic_observer") + SUBCASE("lambda observer obtains callbacks via cast to dynamic_observer") { auto dynamic_observer = std::move(observer).as_dynamic(); static_assert(std::is_copy_constructible_v, "dynamic observer should be copy constructible"); @@ -78,14 +77,14 @@ TEST_CASE("lambda observer works properly as base observer") TEST_CASE("as_dynamic keeps disposing") { auto check = [&](auto&& observer) { - SECTION("dispose and convert to dynamic") + SUBCASE("dispose and convert to dynamic") { observer.on_completed(); auto dynamic = std::forward(observer).as_dynamic(); CHECK(dynamic.is_disposed()); } - SECTION("set upstream, convert to dynamic and dispose") + SUBCASE("set upstream, convert to dynamic and dispose") { auto d = rpp::composite_disposable_wrapper::make(); observer.set_upstream(rpp::disposable_wrapper{d}); @@ -94,7 +93,7 @@ TEST_CASE("as_dynamic keeps disposing") CHECK(d.is_disposed()); } - SECTION("convert to dynamic, copy and dispose") + SUBCASE("convert to dynamic, copy and dispose") { auto dynamic = std::forward(observer).as_dynamic(); auto copy_of_dynamic = dynamic; // NOLINT @@ -103,11 +102,11 @@ TEST_CASE("as_dynamic keeps disposing") } }; - SECTION("observer") + SUBCASE("observer") { check(rpp::make_lambda_observer([](int) {}, [](const std::exception_ptr&) {}, []() {})); } - SECTION("observer with disposable") + SUBCASE("observer with disposable") { check(rpp::make_lambda_observer( rpp::composite_disposable_wrapper::make(), @@ -115,7 +114,7 @@ TEST_CASE("as_dynamic keeps disposing") [](const std::exception_ptr&) {}, []() {})); } - SECTION("observer with disposed disposable") + SUBCASE("observer with disposed disposable") { check(rpp::make_lambda_observer( rpp::composite_disposable_wrapper::make(), @@ -141,7 +140,7 @@ TEST_CASE("observer disposes disposable on termination callbacks") CHECK(!upstream.is_disposed()); CHECK(!observer.is_disposed()); - SECTION("calling on_error causes disposing of disposables") + SUBCASE("calling on_error causes disposing of disposables") { observer.on_error({}); CHECK(upstream.is_disposed()); @@ -149,7 +148,7 @@ TEST_CASE("observer disposes disposable on termination callbacks") CHECK(observer.is_disposed()); } - SECTION("calling on_completed causes disposing of disposables") + SUBCASE("calling on_completed causes disposing of disposables") { observer.on_completed(); CHECK(upstream.is_disposed()); @@ -168,14 +167,14 @@ TEST_CASE("set_upstream without base disposable makes it main disposalbe") CHECK(!upstream.is_disposed()); CHECK(!observer.is_disposed()); - SECTION("calling on_error causes disposing of upstream") + SUBCASE("calling on_error causes disposing of upstream") { observer.on_error({}); CHECK(upstream.is_disposed()); CHECK(observer.is_disposed()); } - SECTION("calling on_completed causes disposing of upstream") + SUBCASE("calling on_completed causes disposing of upstream") { observer.on_completed(); CHECK(upstream.is_disposed()); @@ -183,10 +182,10 @@ TEST_CASE("set_upstream without base disposable makes it main disposalbe") } }; - SECTION("original observer") + SUBCASE("original observer") test_observer(original_observer); - SECTION("dynamic observer") + SUBCASE("dynamic observer") test_observer(std::move(original_observer).as_dynamic()); } @@ -206,17 +205,17 @@ TEST_CASE("set_upstream can be called multiple times") CHECK(d2.is_disposed()); }; - SECTION("observer") + SUBCASE("observer") check(rpp::make_lambda_observer([](int) {}, [](const std::exception_ptr&) {}, []() {})); - SECTION("observer with disposable") + SUBCASE("observer with disposable") check(rpp::make_lambda_observer( rpp::composite_disposable_wrapper::make(), [](int) {}, [](const std::exception_ptr&) {}, []() {})); - SECTION("observer with empty disposable") + SUBCASE("observer with empty disposable") check(rpp::make_lambda_observer( rpp::composite_disposable_wrapper::empty(), [](int) {}, @@ -240,7 +239,7 @@ TEST_CASE("set_upstream depends on base disposable") CHECK(!upstream.is_disposed()); CHECK(!observer.is_disposed()); - SECTION("disposing of base disposable and setting upstream disposes upstream") + SUBCASE("disposing of base disposable and setting upstream disposes upstream") { d.dispose(); CHECK(!upstream.is_disposed()); @@ -250,7 +249,7 @@ TEST_CASE("set_upstream depends on base disposable") CHECK(observer.is_disposed()); } - SECTION("setting upstream and disposing of base disposable disposes upstream") + SUBCASE("setting upstream and disposing of base disposable disposes upstream") { observer.set_upstream(upstream); CHECK(!upstream.is_disposed()); @@ -261,10 +260,10 @@ TEST_CASE("set_upstream depends on base disposable") } }; - SECTION("original observer") + SUBCASE("original observer") test_observer(original_observer); - SECTION("dynamic observer") + SUBCASE("dynamic observer") test_observer(std::move(original_observer).as_dynamic()); } @@ -288,9 +287,9 @@ TEST_CASE("set_upstream disposing when empty base disposable") CHECK(observer.is_disposed()); }; - SECTION("original observer") + SUBCASE("original observer") test_observer(original_observer); - SECTION("dynamic observer") + SUBCASE("dynamic observer") test_observer(std::move(original_observer).as_dynamic()); } diff --git a/src/tests/rpp/test_on_error_resume_next.cpp b/src/tests/rpp/test_on_error_resume_next.cpp index 77078d7d2..67582af0a 100644 --- a/src/tests/rpp/test_on_error_resume_next.cpp +++ b/src/tests/rpp/test_on_error_resume_next.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -20,17 +19,17 @@ #include "disposable_observable.hpp" -TEMPLATE_TEST_CASE("on_error_resume_next switches observable on error", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("on_error_resume_next switches observable on error", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto mock = mock_observer_strategy(); - SECTION("observable without error emission") + SUBCASE("observable without error emission") { auto obs = rpp::source::just(rpp::schedulers::immediate{}, 1, 2, 3); - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::operators::on_error_resume_next([](const std::exception_ptr&) { return rpp::source::empty(); }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from observable") + SUBCASE("observer obtains values from observable") { CHECK(mock.get_received_values() == std::vector{1, 2, 3}); CHECK(mock.get_total_on_next_count() == 3); @@ -40,20 +39,20 @@ TEMPLATE_TEST_CASE("on_error_resume_next switches observable on error", "", rpp: } } - SECTION("observable with one error emission") + SUBCASE("observable with one error emission") { auto obs = rpp::source::create([](const auto& sub) { sub.on_next(1); sub.on_next(2); sub.on_error(std::make_exception_ptr(std::runtime_error{""})); }); - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::operators::on_error_resume_next([](const std::exception_ptr&) { return rpp::source::just(rpp::schedulers::immediate{}, 3); }) | rpp::ops::subscribe(mock); - SECTION("observer obtains values from both outer and inner observable") + SUBCASE("observer obtains values from both outer and inner observable") { CHECK(mock.get_received_values() == std::vector{1, 2, 3}); CHECK(mock.get_total_on_next_count() == 3); @@ -63,7 +62,7 @@ TEMPLATE_TEST_CASE("on_error_resume_next switches observable on error", "", rpp: } } - SECTION("observable with two error emissions") + SUBCASE("observable with two error emissions") { auto obs = rpp::source::create([](const auto& sub) { sub.on_next(1); @@ -71,13 +70,13 @@ TEMPLATE_TEST_CASE("on_error_resume_next switches observable on error", "", rpp: sub.on_error(std::make_exception_ptr(std::runtime_error{""})); sub.on_error(std::make_exception_ptr(std::runtime_error{""})); }); - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::operators::on_error_resume_next([](const std::exception_ptr&) { return rpp::source::just(rpp::schedulers::immediate{}, 3); }) | rpp::ops::subscribe(mock); - SECTION("observer only receives values from first inner observable") + SUBCASE("observer only receives values from first inner observable") { CHECK(mock.get_received_values() == std::vector{1, 2, 3}); CHECK(mock.get_total_on_next_count() == 3); @@ -87,7 +86,7 @@ TEMPLATE_TEST_CASE("on_error_resume_next switches observable on error", "", rpp: } } - SECTION("inner observable different emission type") + SUBCASE("inner observable different emission type") { auto obs = rpp::source::create([](const auto& sub) { sub.on_next(1); @@ -95,13 +94,13 @@ TEMPLATE_TEST_CASE("on_error_resume_next switches observable on error", "", rpp: sub.on_error(std::make_exception_ptr(std::runtime_error{""})); sub.on_error(std::make_exception_ptr(std::runtime_error{""})); }); - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::operators::on_error_resume_next([](const std::exception_ptr&) { return rpp::source::just(rpp::schedulers::immediate{}, 3); }) | rpp::ops::subscribe(mock); - SECTION("observer only receives values from first inner observable") + SUBCASE("observer only receives values from first inner observable") { CHECK(mock.get_received_values() == std::vector{1, 2, 3}); CHECK(mock.get_total_on_next_count() == 3); @@ -111,13 +110,13 @@ TEMPLATE_TEST_CASE("on_error_resume_next switches observable on error", "", rpp: } } - SECTION("nested on_error_resume_next operators") + SUBCASE("nested on_error_resume_next operators") { auto obs = rpp::source::create([](const auto& sub) { sub.on_next(1); sub.on_error(std::make_exception_ptr(std::runtime_error{""})); }); - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::operators::on_error_resume_next([](const std::exception_ptr&) { return rpp::source::create([](const auto& sub) { @@ -132,7 +131,7 @@ TEMPLATE_TEST_CASE("on_error_resume_next switches observable on error", "", rpp: }); }) | rpp::ops::subscribe(mock); - SECTION("observer receives values without any errors") + SUBCASE("observer receives values without any errors") { CHECK(mock.get_received_values() == std::vector{1, 2, 3}); CHECK(mock.get_total_on_next_count() == 3); @@ -142,19 +141,19 @@ TEMPLATE_TEST_CASE("on_error_resume_next switches observable on error", "", rpp: } } - SECTION("selector throwing exception") + SUBCASE("selector throwing exception") { auto obs = rpp::source::create([](const auto& sub) { sub.on_error(std::make_exception_ptr(std::runtime_error{""})); }); - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::operators::on_error_resume_next([](const std::exception_ptr& ep) { std::rethrow_exception(ep); return rpp::source::empty(); }) | rpp::ops::subscribe(mock); - SECTION("observer obtains selector error exception") + SUBCASE("observer obtains selector error exception") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); diff --git a/src/tests/rpp/test_reduce.cpp b/src/tests/rpp/test_reduce.cpp index f3fae9e19..a7c18dfe6 100644 --- a/src/tests/rpp/test_reduce.cpp +++ b/src/tests/rpp/test_reduce.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -20,17 +19,17 @@ #include "copy_count_tracker.hpp" #include "disposable_observable.hpp" -TEMPLATE_TEST_CASE("reduce reduces values and store state", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("reduce reduces values and store state", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto obs = rpp::source::just(1, 2, 3); - SECTION("subscribe on it with plus and initial seed") + SUBCASE("subscribe on it with plus and initial seed") { auto mock = mock_observer_strategy{}; obs | rpp::operators::reduce(0, std::plus{}) | rpp::operators::subscribe(mock); - SECTION("observer obtains sum") + SUBCASE("observer obtains sum") { CHECK(mock.get_received_values() == std::vector{6}); CHECK(mock.get_on_error_count() == 0); @@ -38,13 +37,13 @@ TEMPLATE_TEST_CASE("reduce reduces values and store state", "", rpp::memory_mode } } - SECTION("subscribe on it with plus and no initial seed") + SUBCASE("subscribe on it with plus and no initial seed") { auto mock = mock_observer_strategy{}; obs | rpp::operators::reduce(std::plus{}) | rpp::operators::subscribe(mock); - SECTION("observer obtains sum") + SUBCASE("observer obtains sum") { CHECK(mock.get_received_values() == std::vector{6}); CHECK(mock.get_on_error_count() == 0); @@ -52,7 +51,7 @@ TEMPLATE_TEST_CASE("reduce reduces values and store state", "", rpp::memory_mode } } - SECTION("subscribe on it with exception and no seed") + SUBCASE("subscribe on it with exception and no seed") { auto mock = mock_observer_strategy{}; @@ -62,7 +61,7 @@ TEMPLATE_TEST_CASE("reduce reduces values and store state", "", rpp::memory_mode throw std::runtime_error{""}; }) | rpp::operators::subscribe(mock); - SECTION("observer obtains only on_error") + SUBCASE("observer obtains only on_error") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); @@ -74,7 +73,7 @@ TEMPLATE_TEST_CASE("reduce reduces values and store state", "", rpp::memory_mode TEST_CASE("reduce forwards callbacks") { auto mock = mock_observer_strategy{}; - SECTION("on_error") + SUBCASE("on_error") { rpp::source::error({}) | rpp::ops::reduce(0, std::plus{}) @@ -84,7 +83,7 @@ TEST_CASE("reduce forwards callbacks") CHECK(mock.get_on_error_count() == 1); } - SECTION("on_completed") + SUBCASE("on_completed") { rpp::source::empty() | rpp::ops::reduce(0, std::plus{}) @@ -94,7 +93,7 @@ TEST_CASE("reduce forwards callbacks") CHECK(mock.get_on_completed_count() == 1); } - SECTION("on_completed no_seed") + SUBCASE("on_completed no_seed") { rpp::source::empty() | rpp::ops::reduce(std::plus{}) @@ -107,9 +106,9 @@ TEST_CASE("reduce forwards callbacks") TEST_CASE("reduce doesn't produce extra copies") { - SECTION("reduce([](verifier&& seed, auto&& v){return forward(v); }") + SUBCASE("reduce([](verifier&& seed, auto&& v){return forward(v); }") { - SECTION("send value by copy") + SUBCASE("send value by copy") { copy_count_tracker tracker{}; tracker.get_observable(2) | rpp::ops::reduce([](copy_count_tracker&&, auto&& value) { return std::forward(value); }) | rpp::ops::subscribe([](copy_count_tracker) {}); // NOLINT @@ -121,7 +120,7 @@ TEST_CASE("reduce doesn't produce extra copies") CHECK(tracker.get_move_count() == 2); } - SECTION("send value by move") + SUBCASE("send value by move") { copy_count_tracker tracker{}; tracker.get_observable_for_move(2) | rpp::ops::reduce([](copy_count_tracker&&, auto&& value) { return std::forward(value); }) | rpp::ops::subscribe([](copy_count_tracker) {}); // NOLINT diff --git a/src/tests/rpp/test_repeat.cpp b/src/tests/rpp/test_repeat.cpp index 56af00c4f..636f6c277 100644 --- a/src/tests/rpp/test_repeat.cpp +++ b/src/tests/rpp/test_repeat.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -24,7 +23,7 @@ TEST_CASE("repeat resubscribes") { auto observer = mock_observer_strategy(); - SECTION("observable with value") + SUBCASE("observable with value") { size_t subscribe_count = 0; auto observable = rpp::source::create([&subscribe_count](const auto& sub) { @@ -33,10 +32,10 @@ TEST_CASE("repeat resubscribes") sub.on_completed(); }); - SECTION("subscribe on it via repeat(0)") + SUBCASE("subscribe on it via repeat(0)") { observable | rpp::operators::repeat(0) | rpp::operators::subscribe(observer); - SECTION("only on_completed sent") + SUBCASE("only on_completed sent") { CHECK(subscribe_count == 0); CHECK(observer.get_total_on_next_count() == 0); @@ -44,10 +43,10 @@ TEST_CASE("repeat resubscribes") CHECK(observer.get_on_completed_count() == 1); } } - SECTION("subscribe on it via repeat(1)") + SUBCASE("subscribe on it via repeat(1)") { observable | rpp::operators::repeat(1) | rpp::operators::subscribe(observer); - SECTION("sent value once") + SUBCASE("sent value once") { CHECK(subscribe_count == 1); CHECK(observer.get_total_on_next_count() == 1); @@ -55,10 +54,10 @@ TEST_CASE("repeat resubscribes") CHECK(observer.get_on_completed_count() == 1); } } - SECTION("subscribe on it via repeat(10)") + SUBCASE("subscribe on it via repeat(10)") { observable | rpp::operators::repeat(10) | rpp::operators::subscribe(observer); - SECTION("sent value 10 times") + SUBCASE("sent value 10 times") { CHECK(subscribe_count == 10); CHECK(observer.get_total_on_next_count() == 10); @@ -66,10 +65,10 @@ TEST_CASE("repeat resubscribes") CHECK(observer.get_on_completed_count() == 1); } } - SECTION("subscribe on it via repeat()") + SUBCASE("subscribe on it via repeat()") { observable | rpp::operators::repeat() | rpp::operators::take(10) | rpp::operators::subscribe(observer); - SECTION("sent value infinitely") + SUBCASE("sent value infinitely") { CHECK(subscribe_count == 10); CHECK(observer.get_total_on_next_count() == 10); @@ -78,17 +77,17 @@ TEST_CASE("repeat resubscribes") } } } - SECTION("observable with on_error") + SUBCASE("observable with on_error") { size_t subscribe_count = 0; auto observable = rpp::source::create([&subscribe_count](const auto& sub) { ++subscribe_count; sub.on_error(std::make_exception_ptr(std::runtime_error{""})); }); - SECTION("subscribe on it via repeat(10)") + SUBCASE("subscribe on it via repeat(10)") { observable | rpp::operators::repeat(10) | rpp::operators::subscribe(observer); - SECTION("only on_error once") + SUBCASE("only on_error once") { CHECK(subscribe_count == 1); CHECK(observer.get_total_on_next_count() == 0); @@ -97,17 +96,17 @@ TEST_CASE("repeat resubscribes") } } } - SECTION("observable with on_completed") + SUBCASE("observable with on_completed") { size_t subscribe_count = 0; auto observable = rpp::source::create([&subscribe_count](const auto& sub) { ++subscribe_count; sub.on_completed(); }); - SECTION("subscribe on it via repeat(10)") + SUBCASE("subscribe on it via repeat(10)") { observable | rpp::operators::repeat(10) | rpp::operators::subscribe(observer); - SECTION("on_ompleted once") + SUBCASE("on_ompleted once") { CHECK(subscribe_count == 10); CHECK(observer.get_total_on_next_count() == 0); @@ -120,7 +119,7 @@ TEST_CASE("repeat resubscribes") TEST_CASE("repeat doesn't produce extra copies") { - SECTION("repeat(2)") + SUBCASE("repeat(2)") { copy_count_tracker::test_operator(rpp::ops::repeat(2), { diff --git a/src/tests/rpp/test_retry.cpp b/src/tests/rpp/test_retry.cpp index 19acfa6b5..bbcb93e0c 100644 --- a/src/tests/rpp/test_retry.cpp +++ b/src/tests/rpp/test_retry.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -30,11 +29,11 @@ TEST_CASE("retry handles errors properly") mock_observer mock{}; trompeloeil::sequence seq; - SECTION("observable 1-x-2") + SUBCASE("observable 1-x-2") { const auto observable = rpp::source::concat(rpp::source::just(1), rpp::source::error({}), rpp::source::just(2)); - SECTION("retry(0)") + SUBCASE("retry(0)") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(seq); @@ -42,7 +41,7 @@ TEST_CASE("retry handles errors properly") observable | rpp::operators::retry(0) | rpp::operators::subscribe(mock); } - SECTION("retry(1)") + SUBCASE("retry(1)") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); @@ -51,7 +50,7 @@ TEST_CASE("retry handles errors properly") observable | rpp::operators::retry(1) | rpp::operators::subscribe(mock); } - SECTION("retry(2)") + SUBCASE("retry(2)") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); @@ -60,7 +59,7 @@ TEST_CASE("retry handles errors properly") observable | rpp::operators::retry(2) | rpp::operators::subscribe(mock); } - SECTION("retry(2) from another thread") + SUBCASE("retry(2) from another thread") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); @@ -70,7 +69,7 @@ TEST_CASE("retry handles errors properly") observable | rpp::ops::subscribe_on(rpp::schedulers::new_thread{}) | rpp::operators::retry(2) | rpp::ops::as_blocking() | rpp::operators::subscribe(mock); } - SECTION("retry()") + SUBCASE("retry()") { auto d = rpp::composite_disposable_wrapper::make(); @@ -84,11 +83,11 @@ TEST_CASE("retry handles errors properly") observable | rpp::operators::retry() | rpp::operators::subscribe(d, mock); } } - SECTION("observable 1-|") + SUBCASE("observable 1-|") { const auto observable = rpp::source::just(1); - SECTION("retry(0)") + SUBCASE("retry(0)") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(seq); @@ -96,7 +95,7 @@ TEST_CASE("retry handles errors properly") observable | rpp::operators::retry(0) | rpp::operators::subscribe(mock); } - SECTION("retry(2)") + SUBCASE("retry(2)") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(seq); @@ -104,7 +103,7 @@ TEST_CASE("retry handles errors properly") observable | rpp::operators::retry(2) | rpp::operators::subscribe(mock); } - SECTION("retry()") + SUBCASE("retry()") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(seq); @@ -112,32 +111,32 @@ TEST_CASE("retry handles errors properly") observable | rpp::operators::retry() | rpp::operators::subscribe(mock); } } - SECTION("observable 1->") + SUBCASE("observable 1->") { const auto observable = rpp::source::concat(rpp::source::just(1), rpp::source::never()); - SECTION("retry(0)") + SUBCASE("retry(0)") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); observable | rpp::operators::retry(0) | rpp::operators::subscribe(mock); } - SECTION("retry(2)") + SUBCASE("retry(2)") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); observable | rpp::operators::retry(2) | rpp::operators::subscribe(mock); } - SECTION("retry()") + SUBCASE("retry()") { REQUIRE_CALL(*mock, on_next_lvalue(1)).IN_SEQUENCE(seq); observable | rpp::operators::retry() | rpp::operators::subscribe(mock); } } - SECTION("observable throws exception") + SUBCASE("observable throws exception") { size_t i = 0; const auto observable = rpp::source::create([&i](const auto& sub) { @@ -146,7 +145,7 @@ TEST_CASE("retry handles errors properly") sub.on_error({}); }); - SECTION("retry()") + SUBCASE("retry()") { REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(seq); @@ -191,7 +190,7 @@ TEST_CASE("retry disposes on looping") TEST_CASE("retry doesn't produce extra copies") { - SECTION("retry(2)") + SUBCASE("retry(2)") { copy_count_tracker::test_operator(rpp::ops::retry(2), { @@ -201,7 +200,7 @@ TEST_CASE("retry doesn't produce extra copies") .move_count = 1} // 1 move to final subscriber }); } - SECTION("retry()") + SUBCASE("retry()") { copy_count_tracker::test_operator(rpp::ops::retry(), { diff --git a/src/tests/rpp/test_retry_when.cpp b/src/tests/rpp/test_retry_when.cpp index 0e4ac96bc..b895eba6b 100644 --- a/src/tests/rpp/test_retry_when.cpp +++ b/src/tests/rpp/test_retry_when.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -33,7 +32,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") mock_observer mock{}; trompeloeil::sequence seq; - SECTION("observable without error emission") + SUBCASE("observable without error emission") { size_t subscribe_count = 0; auto observable = rpp::source::create([&subscribe_count](const auto& sub) { @@ -41,7 +40,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") sub.on_next(std::string{"1"}); sub.on_completed(); }); - SECTION("observer obtains values from observable") + SUBCASE("observer obtains values from observable") { REQUIRE_CALL(*mock, on_next_rvalue("1")).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(seq); @@ -54,7 +53,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") } } - SECTION("observable with 1 error") + SUBCASE("observable with 1 error") { size_t subscribe_count = 0; auto observable = rpp::source::create([&subscribe_count](const auto& sub) { @@ -69,7 +68,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") } }); - SECTION("original observable is subscribed twice and observer receives one emission") + SUBCASE("original observable is subscribed twice and observer receives one emission") { REQUIRE_CALL(*mock, on_next_rvalue("1")).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(seq); @@ -81,7 +80,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") CHECK(subscribe_count == 2); } - SECTION("original observable is subscribed twice and observer receives one emission, notifier emits on new_thread") + SUBCASE("original observable is subscribed twice and observer receives one emission, notifier emits on new_thread") { REQUIRE_CALL(*mock, on_next_rvalue("1")).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(seq); @@ -94,7 +93,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") CHECK(subscribe_count == 2); } - SECTION("original observable is subscribed twice and observer receives only one emission") + SUBCASE("original observable is subscribed twice and observer receives only one emission") { REQUIRE_CALL(*mock, on_next_rvalue("1")).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(seq); @@ -106,7 +105,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") CHECK(subscribe_count == 2); } - SECTION("original observable is subscribed only once and observer receives error emission") + SUBCASE("original observable is subscribed only once and observer receives error emission") { REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(seq); @@ -120,7 +119,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") CHECK(subscribe_count == 1); } - SECTION("original observable is subscribed only once and observer receives error emission") + SUBCASE("original observable is subscribed only once and observer receives error emission") { REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(seq); @@ -133,7 +132,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") CHECK(subscribe_count == 1); } - SECTION("original observable is subscribed only once and observer receives completed emission") + SUBCASE("original observable is subscribed only once and observer receives completed emission") { REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(seq); @@ -147,7 +146,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") } } - SECTION("observable with 4 errors") + SUBCASE("observable with 4 errors") { size_t subscribe_count = 0; auto observable = rpp::source::create([&subscribe_count](const auto& sub) { @@ -162,7 +161,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") } }); - SECTION("original observable is subscribed 5 times and observer receives one emission") + SUBCASE("original observable is subscribed 5 times and observer receives one emission") { REQUIRE_CALL(*mock, on_next_rvalue("1")).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(seq); @@ -174,7 +173,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") CHECK(subscribe_count == 4 + 1); } - SECTION("original observable is subscribed twice and observer receives one emission, notifier emits on new_thread") + SUBCASE("original observable is subscribed twice and observer receives one emission, notifier emits on new_thread") { REQUIRE_CALL(*mock, on_next_rvalue("1")).IN_SEQUENCE(seq); REQUIRE_CALL(*mock, on_completed()).IN_SEQUENCE(seq); @@ -186,7 +185,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") CHECK(subscribe_count == 4 + 1); } - SECTION("callable throws exception") + SUBCASE("callable throws exception") { REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(seq); @@ -197,7 +196,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") CHECK(subscribe_count == 1); } - SECTION("callable return observable throwing exception") + SUBCASE("callable return observable throwing exception") { REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(seq); @@ -209,7 +208,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") CHECK(subscribe_count == 1); } } - SECTION("observable throws exception") + SUBCASE("observable throws exception") { size_t i = 0; const auto observable = rpp::source::create([&i](const auto& sub) { @@ -218,7 +217,7 @@ TEST_CASE("retry_when resubscribes on notifier emission") sub.on_error({}); }); - SECTION("retry()") + SUBCASE("retry()") { REQUIRE_CALL(*mock, on_error(trompeloeil::_)).IN_SEQUENCE(seq); @@ -268,7 +267,7 @@ TEST_CASE("retry_when disposes on looping") TEST_CASE("retry_when doesn't produce extra copies") { - SECTION("retry_when(empty_notifier)") + SUBCASE("retry_when(empty_notifier)") { copy_count_tracker::test_operator(rpp::ops::retry_when([](const std::exception_ptr&) { return rpp::source::empty(); }), { diff --git a/src/tests/rpp/test_scan.cpp b/src/tests/rpp/test_scan.cpp index 00dfbd23d..22601b693 100644 --- a/src/tests/rpp/test_scan.cpp +++ b/src/tests/rpp/test_scan.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -19,61 +18,61 @@ #include "disposable_observable.hpp" -TEMPLATE_TEST_CASE("scan scans values and store state", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("scan scans values and store state", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto obs = rpp::source::just(1, 2, 3); - SECTION("subscribe on it via scan with plus") + SUBCASE("subscribe on it via scan with plus") { auto mock = mock_observer_strategy{}; obs | rpp::operators::scan(10, std::plus{}) | rpp::operators::subscribe(mock); - SECTION("observer obtains partial sums") + SUBCASE("observer obtains partial sums") { CHECK(mock.get_received_values() == std::vector{10, 11, 13, 16}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } } - SECTION("subscribe on it via scan with plus with no seed") + SUBCASE("subscribe on it via scan with plus with no seed") { auto mock = mock_observer_strategy{}; obs | rpp::operators::scan(std::plus{}) | rpp::operators::subscribe(mock); - SECTION("observer obtains partial sums") + SUBCASE("observer obtains partial sums") { CHECK(mock.get_received_values() == std::vector{1, 3, 6}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } } - SECTION("subscribe on it via scan as lvalue with plus") + SUBCASE("subscribe on it via scan as lvalue with plus") { auto mock = mock_observer_strategy{}; auto op = rpp::operators::scan(10, std::plus{}); obs | op | rpp::operators::subscribe(mock); - SECTION("observer obtains partial sums") + SUBCASE("observer obtains partial sums") { CHECK(mock.get_received_values() == std::vector{10, 11, 13, 16}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } } - SECTION("subscribe on it via scan with plus as lvalue with no seed") + SUBCASE("subscribe on it via scan with plus as lvalue with no seed") { auto mock = mock_observer_strategy{}; auto op = rpp::operators::scan(std::plus{}); obs | op | rpp::operators::subscribe(mock); - SECTION("observer obtains partial sums") + SUBCASE("observer obtains partial sums") { CHECK(mock.get_received_values() == std::vector{1, 3, 6}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } } - SECTION("subscribe on it via scan with aggregating in vector") + SUBCASE("subscribe on it via scan with aggregating in vector") { auto mock = mock_observer_strategy>{}; @@ -85,14 +84,14 @@ TEMPLATE_TEST_CASE("scan scans values and store state", "", rpp::memory_model::u }) | rpp::operators::subscribe(mock); - SECTION("observer obtains partial vectors") + SUBCASE("observer obtains partial vectors") { CHECK(mock.get_received_values() == std::vector{std::vector{}, std::vector{1}, std::vector{1, 2}, std::vector{1, 2, 3}}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } } - SECTION("subscribe on it via scan with exception") + SUBCASE("subscribe on it via scan with exception") { auto mock = mock_observer_strategy{}; @@ -103,14 +102,14 @@ TEMPLATE_TEST_CASE("scan scans values and store state", "", rpp::memory_model::u throw std::runtime_error{""}; }) | rpp::operators::subscribe(mock); - SECTION("observer obtains only on_error") + SUBCASE("observer obtains only on_error") { CHECK(mock.get_received_values() == std::vector{0}); CHECK(mock.get_on_error_count() == 1); CHECK(mock.get_on_completed_count() == 0); } } - SECTION("subscribe on it via scan with exception with no seed") + SUBCASE("subscribe on it via scan with exception with no seed") { auto mock = mock_observer_strategy{}; @@ -122,7 +121,7 @@ TEMPLATE_TEST_CASE("scan scans values and store state", "", rpp::memory_model::u }) | rpp::operators::subscribe(mock); - SECTION("observer obtains only on_error") + SUBCASE("observer obtains only on_error") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_error_count() == 1); @@ -133,9 +132,9 @@ TEMPLATE_TEST_CASE("scan scans values and store state", "", rpp::memory_model::u TEST_CASE("scan doesn't produce extra copies") { - SECTION("scan([](verifier&& seed, auto&& v){return forward(v); }") + SUBCASE("scan([](verifier&& seed, auto&& v){return forward(v); }") { - SECTION("send value by copy") + SUBCASE("send value by copy") { copy_count_tracker tracker{}; tracker.get_observable(2) | rpp::ops::scan([](copy_count_tracker&&, auto&& value) { return std::forward(value); }) | rpp::ops::subscribe([](copy_count_tracker) {}); // NOLINT @@ -147,7 +146,7 @@ TEST_CASE("scan doesn't produce extra copies") CHECK(tracker.get_move_count() == 1); } - SECTION("send value by move") + SUBCASE("send value by move") { copy_count_tracker tracker{}; tracker.get_observable_for_move(2) | rpp::ops::scan([](copy_count_tracker&&, auto&& value) { return std::forward(value); }) | rpp::ops::subscribe([](copy_count_tracker) {}); // NOLINT diff --git a/src/tests/rpp/test_scheduler.cpp b/src/tests/rpp/test_scheduler.cpp index 5167da976..c89b57399 100644 --- a/src/tests/rpp/test_scheduler.cpp +++ b/src/tests/rpp/test_scheduler.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -175,7 +174,7 @@ TEST_CASE("Immediate scheduler") size_t call_count{}; - SECTION("immediate scheduler schedules and re-schedules action immediately") + SUBCASE("immediate scheduler schedules and re-schedules action immediately") { worker.schedule([&call_count](const auto&) -> rpp::schedulers::optional_delay_from_now { if (++call_count <= 1) @@ -187,7 +186,7 @@ TEST_CASE("Immediate scheduler") CHECK(call_count == 2); } - SECTION("immediate scheduler schedules action with delay") + SUBCASE("immediate scheduler schedules action with delay") { auto now = rpp::schedulers::clock_type::now(); auto diff = std::chrono::milliseconds{500}; @@ -205,7 +204,7 @@ TEST_CASE("Immediate scheduler") REQUIRE(execute_time - now >= diff); } - SECTION("immediate scheduler re-schedules action at provided timepoint with duration") + SUBCASE("immediate scheduler re-schedules action at provided timepoint with duration") { std::vector executions{}; std::chrono::milliseconds diff = std::chrono::milliseconds{500}; @@ -221,7 +220,7 @@ TEST_CASE("Immediate scheduler") REQUIRE(executions[1] - executions[0] >= (diff - std::chrono::milliseconds(100))); } - SECTION("immediate scheduler re-schedules action at provided timepoint") + SUBCASE("immediate scheduler re-schedules action at provided timepoint") { std::vector executions{}; std::chrono::milliseconds diff = std::chrono::milliseconds{500}; @@ -237,7 +236,7 @@ TEST_CASE("Immediate scheduler") REQUIRE(executions[1] - executions[0] >= (diff - std::chrono::milliseconds(100))); } - SECTION("immediate scheduler with nesting scheduling should be like call-stack in a recursive order") + SUBCASE("immediate scheduler with nesting scheduling should be like call-stack in a recursive order") { std::vector call_stack; @@ -252,7 +251,7 @@ TEST_CASE("Immediate scheduler") }); } - SECTION("immediate scheduler with complex scheduling with delay should be like call-stack in a recursive order") + SUBCASE("immediate scheduler with complex scheduling with delay should be like call-stack in a recursive order") { std::vector call_stack; @@ -273,7 +272,7 @@ TEST_CASE("Immediate scheduler") "Task 1 ends "s + execution_thread, }); } - SECTION("immediate scheduler with complex scheduling should be like call-stack in a recursive order") + SUBCASE("immediate scheduler with complex scheduling should be like call-stack in a recursive order") { std::vector call_stack; @@ -295,7 +294,7 @@ TEST_CASE("Immediate scheduler") }); } - SECTION("immediate scheduler does nothing with disposed observer") + SUBCASE("immediate scheduler does nothing with disposed observer") { d.dispose(); worker.schedule([&call_count](const auto&) -> rpp::schedulers::optional_delay_from_now { @@ -307,7 +306,7 @@ TEST_CASE("Immediate scheduler") CHECK(call_count == 0); } - SECTION("immediate scheduler does nothing with observer disposed during wait") + SUBCASE("immediate scheduler does nothing with observer disposed during wait") { worker.schedule( [&call_count, obs](const auto&) -> rpp::schedulers::optional_delay_from_now { @@ -324,7 +323,7 @@ TEST_CASE("Immediate scheduler") CHECK(call_count == 1); } - SECTION("immediate scheduler does not reschedule after disposing inside schedulable") + SUBCASE("immediate scheduler does not reschedule after disposing inside schedulable") { worker.schedule([&call_count, &d](const auto&) -> rpp::schedulers::optional_delay_from_now { if (++call_count > 1) @@ -336,19 +335,19 @@ TEST_CASE("Immediate scheduler") CHECK(call_count == 2); } - SECTION("immediate scheduler forwards any arguments") + SUBCASE("immediate scheduler forwards any arguments") { worker.schedule([](const auto&, int, const std::string&) { return rpp::schedulers::optional_delay_from_now{}; }, obs, int{}, std::string{}); } - SECTION("error during schedulable") + SUBCASE("error during schedulable") { worker.schedule([](const auto&) -> rpp::schedulers::optional_delay_from_now { throw std::runtime_error{"test"}; }, obs); CHECK(mock_obs.get_on_error_count() == 1); } } -TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, rpp::schedulers::new_thread, rpp::schedulers::thread_pool) +TEST_CASE_TEMPLATE("queue_based scheduler", TestType, rpp::schedulers::current_thread, rpp::schedulers::new_thread, rpp::schedulers::thread_pool) { auto d = rpp::composite_disposable_wrapper::make(); auto mock_obs = mock_observer_strategy{}; @@ -393,7 +392,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, }; }; - SECTION("scheduler schedules and re-schedules action immediately") + SUBCASE("scheduler schedules and re-schedules action immediately") { worker->schedule([&call_count](const auto&) -> rpp::schedulers::optional_delay_from_now { if (++call_count <= 1) @@ -407,7 +406,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(call_count == 2); } - SECTION("scheduler recursive scheduling") + SUBCASE("scheduler recursive scheduling") { worker->schedule([&call_count, worker](const auto& obs) -> rpp::schedulers::optional_delay_from_now { worker->schedule([&call_count](const auto&) -> rpp::schedulers::optional_delay_from_now { @@ -425,7 +424,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(call_count == 2); } - SECTION("scheduler recursive scheduling with original") + SUBCASE("scheduler recursive scheduling with original") { worker->schedule([&call_count, worker](const auto& obs) -> rpp::schedulers::optional_delay_from_now { worker->schedule([&call_count](const auto&) -> rpp::schedulers::optional_delay_from_now { @@ -446,7 +445,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(call_count == 3); } - SECTION("scheduler schedules action with delay") + SUBCASE("scheduler schedules action with delay") { auto now = rpp::schedulers::clock_type::now(); auto diff = std::chrono::milliseconds{500}; @@ -467,7 +466,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, REQUIRE(execute_time - now >= diff); } - SECTION("scheduler re-schedules action at provided timepoint") + SUBCASE("scheduler re-schedules action at provided timepoint") { std::vector executions{}; std::chrono::milliseconds diff = std::chrono::milliseconds{500}; @@ -485,7 +484,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, REQUIRE(executions[1] - executions[0] >= (diff - std::chrono::milliseconds(100))); } - SECTION("scheduler with nesting scheduling should defer actual execution of tasks") + SUBCASE("scheduler with nesting scheduling should defer actual execution of tasks") { std::vector call_stack; @@ -502,7 +501,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, }); } - SECTION("scheduler with complex scheduling should defer actual execution of tasks") + SUBCASE("scheduler with complex scheduling should defer actual execution of tasks") { std::vector call_stack; @@ -526,7 +525,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, }); } - SECTION("scheduler with complex scheduling with delay should defer actual execution of tasks") + SUBCASE("scheduler with complex scheduling with delay should defer actual execution of tasks") { std::vector call_stack; @@ -550,7 +549,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, }); } - SECTION("scheduler does nothing with disposed observer") + SUBCASE("scheduler does nothing with disposed observer") { d.dispose(); worker->schedule([&call_count](const auto&) -> rpp::schedulers::optional_delay_from_now { @@ -564,7 +563,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(call_count == 0); } - SECTION("scheduler does nothing with recursive disposed observer") + SUBCASE("scheduler does nothing with recursive disposed observer") { worker->schedule([&call_count, d, worker](const auto& obs) -> rpp::schedulers::optional_delay_from_now { d.dispose(); @@ -583,7 +582,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(call_count == 0); } - SECTION("scheduler does not reschedule after disposing inside schedulable") + SUBCASE("scheduler does not reschedule after disposing inside schedulable") { worker->schedule([&call_count, d](const auto&) -> rpp::schedulers::optional_delay_from_now { if (++call_count > 1) @@ -597,7 +596,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(call_count == 2); } - SECTION("scheduler does not reschedule after disposing inside recursive schedulable") + SUBCASE("scheduler does not reschedule after disposing inside recursive schedulable") { worker->schedule([&call_count, d, worker](const auto& obs) -> rpp::schedulers::optional_delay_from_now { worker->schedule([&call_count, d](const auto&) -> rpp::schedulers::optional_delay_from_now { @@ -615,7 +614,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(call_count == 2); } - SECTION("scheduler does not reschedule after disposing inside recursive schedulable") + SUBCASE("scheduler does not reschedule after disposing inside recursive schedulable") { worker->schedule([&call_count, d, worker](const auto& obs) -> rpp::schedulers::optional_delay_from_now { worker->schedule([&call_count, d](const auto&) -> rpp::schedulers::optional_delay_from_now { @@ -633,7 +632,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(call_count == 2); } - SECTION("scheduler does not dispatch schedulable after disposing of disposable") + SUBCASE("scheduler does not dispatch schedulable after disposing of disposable") { worker->schedule([&call_count, d, worker](const auto& obs) -> rpp::schedulers::optional_delay_from_now { ++call_count; @@ -652,7 +651,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(call_count == 1); } - SECTION("scheduler respects to time point") + SUBCASE("scheduler respects to time point") { std::vector executions{}; worker->schedule([&executions, worker](const auto& obs) -> rpp::schedulers::optional_delay_from_now { @@ -677,12 +676,12 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(executions == std::vector{1, 2, 3}); } - SECTION("scheduler forwards any arguments") + SUBCASE("scheduler forwards any arguments") { worker->schedule([](const auto&, int, const std::string&) { return rpp::schedulers::optional_delay_from_now{}; }, obs.value(), int{}, std::string{}); } - SECTION("error during schedulable") + SUBCASE("error during schedulable") { worker->schedule([](const auto&) -> rpp::schedulers::optional_delay_from_now { throw std::runtime_error{"test"}; }, obs.value()); @@ -691,7 +690,7 @@ TEMPLATE_TEST_CASE("queue_based scheduler", "", rpp::schedulers::current_thread, CHECK(mock_obs.get_on_error_count() == 1); } - SECTION("error during recursive schedulable") + SUBCASE("error during recursive schedulable") { worker->schedule([worker](const auto& obs) { worker->schedule([](const auto&) -> rpp::schedulers::optional_delay_from_now { throw std::runtime_error{"test"}; }, obs); @@ -774,7 +773,7 @@ TEST_CASE("run_loop scheduler dispatches tasks only manually") auto d = rpp::composite_disposable_wrapper::make(); auto obs = mock_observer_strategy{}.get_observer(d).as_dynamic(); - SECTION("submit 3 tasks to run_loop") + SUBCASE("submit 3 tasks to run_loop") { size_t schedulable_1_executed_count{}; size_t schedulable_2_executed_count{}; @@ -783,7 +782,7 @@ TEST_CASE("run_loop scheduler dispatches tasks only manually") worker.schedule([&](const auto&) -> rpp::schedulers::optional_delay_from_now {++schedulable_2_executed_count; d.dispose(); return {}; }, obs); worker.schedule([&](const auto&) -> rpp::schedulers::optional_delay_from_now {++schedulable_3_executed_count; return {}; }, obs); - SECTION("nothing happens but scheduler has schedulable to dispatch") + SUBCASE("nothing happens but scheduler has schedulable to dispatch") { CHECK(schedulable_1_executed_count == 0); CHECK(schedulable_2_executed_count == 0); @@ -792,10 +791,10 @@ TEST_CASE("run_loop scheduler dispatches tasks only manually") CHECK(scheduler.is_empty() == false); CHECK(scheduler.is_any_ready_schedulable() == true); } - SECTION("call dispatch_if_ready") + SUBCASE("call dispatch_if_ready") { scheduler.dispatch_if_ready(); - SECTION("only first schedulable dispatched") + SUBCASE("only first schedulable dispatched") { CHECK(schedulable_1_executed_count == 1); CHECK(schedulable_2_executed_count == 0); @@ -804,10 +803,10 @@ TEST_CASE("run_loop scheduler dispatches tasks only manually") CHECK(scheduler.is_empty() == false); CHECK(scheduler.is_any_ready_schedulable() == true); - SECTION("call dispatch_if_ready again") + SUBCASE("call dispatch_if_ready again") { scheduler.dispatch_if_ready(); - SECTION("both schedulable dispatched") + SUBCASE("both schedulable dispatched") { CHECK(schedulable_1_executed_count == 1); CHECK(schedulable_2_executed_count == 1); @@ -816,10 +815,10 @@ TEST_CASE("run_loop scheduler dispatches tasks only manually") CHECK(scheduler.is_empty() == false); CHECK(scheduler.is_any_ready_schedulable() == true); } - SECTION("call dispatch_if_ready again") + SUBCASE("call dispatch_if_ready again") { scheduler.dispatch_if_ready(); - SECTION("third scehdulable not dispatched, but scheduler is empty") + SUBCASE("third scehdulable not dispatched, but scheduler is empty") { CHECK(schedulable_1_executed_count == 1); CHECK(schedulable_2_executed_count == 1); @@ -833,22 +832,22 @@ TEST_CASE("run_loop scheduler dispatches tasks only manually") } } } - SECTION("submit 1 task to run_loop") + SUBCASE("submit 1 task to run_loop") { size_t schedulable_1_executed_count{}; worker.schedule([&](const auto&) -> rpp::schedulers::optional_delay_from_now {++schedulable_1_executed_count; return {}; }, obs); - SECTION("call dispatch") + SUBCASE("call dispatch") { scheduler.dispatch(); - SECTION("only first schedulable dispatched") + SUBCASE("only first schedulable dispatched") { CHECK(schedulable_1_executed_count == 1); CHECK(d.is_disposed() == false); CHECK(scheduler.is_empty() == true); CHECK(scheduler.is_any_ready_schedulable() == false); - SECTION("call dispatch and schedule in other thread") + SUBCASE("call dispatch and schedule in other thread") { std::atomic_bool dispatched{}; size_t schedulable_2_executed_count{}; @@ -890,21 +889,21 @@ TEST_CASE("different delaying strategies") obs); }; - SECTION("return delay_from_now") + SUBCASE("return delay_from_now") { test(rpp::schedulers::optional_delay_from_now{delay}); CHECK(scheduler.get_schedulings() == std::vector{now, now + advance + delay}); CHECK(scheduler.get_executions() == std::vector{now}); } - SECTION("return delay_from_this_timepoint") + SUBCASE("return delay_from_this_timepoint") { test(rpp::schedulers::optional_delay_from_this_timepoint{delay}); CHECK(scheduler.get_schedulings() == std::vector{now, now + delay}); CHECK(scheduler.get_executions() == std::vector{now}); } - SECTION("return delay_to") + SUBCASE("return delay_to") { test(rpp::schedulers::optional_delay_to{now + delay}); CHECK(scheduler.get_schedulings() == std::vector{now, now + delay}); diff --git a/src/tests/rpp/test_skip.cpp b/src/tests/rpp/test_skip.cpp index b4b30dfdc..725f9b8c6 100644 --- a/src/tests/rpp/test_skip.cpp +++ b/src/tests/rpp/test_skip.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -23,12 +22,12 @@ #include "disposable_observable.hpp" -TEMPLATE_TEST_CASE("skip ignores first `count` of items", - "", - (std::pair), - (std::pair), - (std::pair), - (std::pair)) +TEST_CASE_TEMPLATE("skip ignores first `count` of items", + TestType, + std::pair, + std::pair, + std::pair, + std::pair) { using memory_model = std::tuple_element_t<1, TestType>; using scheduler = std::tuple_element_t<0, TestType>; @@ -36,7 +35,7 @@ TEMPLATE_TEST_CASE("skip ignores first `count` of items", auto mock = mock_observer_strategy{}; auto obs = rpp::source::just(scheduler{}, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9); - SECTION("subscribe to observable of 10 items via skip(5) skips first 5 items") + SUBCASE("subscribe to observable of 10 items via skip(5) skips first 5 items") { constexpr size_t count = 5; auto new_obs = obs | rpp::operators::skip(count); @@ -45,7 +44,7 @@ TEMPLATE_TEST_CASE("skip ignores first `count` of items", CHECK(mock.get_received_values() == std::vector{5, 6, 7, 8, 9}); CHECK(mock.get_on_completed_count() == 1); - SECTION("second subscription sees same") + SUBCASE("second subscription sees same") { auto mock_2 = mock_observer_strategy{}; new_obs.subscribe(mock_2); @@ -54,7 +53,7 @@ TEMPLATE_TEST_CASE("skip ignores first `count` of items", CHECK(mock.get_on_completed_count() == 1); } } - SECTION("subscribe to observable of 10 via skip(0) emits all values") + SUBCASE("subscribe to observable of 10 via skip(0) emits all values") { constexpr size_t count = 0; auto new_obs = obs | rpp::ops::skip(count); @@ -62,7 +61,7 @@ TEMPLATE_TEST_CASE("skip ignores first `count` of items", CHECK(mock.get_received_values() == std::vector{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}); CHECK(mock.get_on_completed_count() == 1); } - SECTION("subscribe to observable of 10 via skip(1000) emits nothing but completes") + SUBCASE("subscribe to observable of 10 via skip(1000) emits nothing but completes") { constexpr size_t count = 1000; auto new_obs = obs | rpp::ops::skip(count); @@ -93,7 +92,7 @@ TEST_CASE("skip forwards completion") TEST_CASE("skip doesn't produce extra copies") { - SECTION("skip(1)") + SUBCASE("skip(1)") { copy_count_tracker::test_operator(rpp::ops::skip(1), { diff --git a/src/tests/rpp/test_start_with.cpp b/src/tests/rpp/test_start_with.cpp index 0f8ae1953..5e6b3d2e9 100644 --- a/src/tests/rpp/test_start_with.cpp +++ b/src/tests/rpp/test_start_with.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -19,19 +18,19 @@ TEST_CASE("start_with works as concat with prepending instead of adding at the e auto mock = mock_observer_strategy{}; auto check = [&] { - SECTION("obtain values from start_with firstly, then from original observable") + SUBCASE("obtain values from start_with firstly, then from original observable") { CHECK(mock.get_received_values() == std::vector{2, 3, 1}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } }; - SECTION("3 observables") + SUBCASE("3 observables") { auto obs_1 = rpp::source::just(1); auto obs_2 = rpp::source::just(2); auto obs_3 = rpp::source::just(3); - SECTION("subscribe on them via start_with") + SUBCASE("subscribe on them via start_with") { obs_1 | rpp::ops::start_with(obs_2, obs_3) | rpp::ops::subscribe(mock); @@ -39,16 +38,16 @@ TEST_CASE("start_with works as concat with prepending instead of adding at the e } } - SECTION("observable") + SUBCASE("observable") { auto obs_1 = rpp::source::just(1); - SECTION("subscribe on it via start_with with values") + SUBCASE("subscribe on it via start_with with values") { obs_1 | rpp::ops::start_with(2, 3) | rpp::ops::subscribe(mock); check(); } - SECTION("subscribe on it via start_with with values") + SUBCASE("subscribe on it via start_with with values") { obs_1 | rpp::ops::start_with(2, 3) | rpp::ops::subscribe(mock); diff --git a/src/tests/rpp/test_subjects.cpp b/src/tests/rpp/test_subjects.cpp index 04eaac90c..3293d46fe 100644 --- a/src/tests/rpp/test_subjects.cpp +++ b/src/tests/rpp/test_subjects.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -28,20 +27,20 @@ TEST_CASE("publish subject multicasts values") { auto mock_1 = mock_observer_strategy{}; auto mock_2 = mock_observer_strategy{}; - SECTION("publish subject") + SUBCASE("publish subject") { auto sub = rpp::subjects::publish_subject{}; - SECTION("subscribe multiple observers") + SUBCASE("subscribe multiple observers") { auto dis_1 = rpp::composite_disposable_wrapper::make(); auto dis_2 = rpp::composite_disposable_wrapper::make(); sub.get_observable().subscribe(mock_1.get_observer(dis_1)); sub.get_observable().subscribe(mock_2.get_observer(dis_2)); - SECTION("emit value") + SUBCASE("emit value") { sub.get_observer().on_next(1); - SECTION("observers obtain value") + SUBCASE("observers obtain value") { auto validate = [](auto mock) { CHECK(mock.get_received_values() == std::vector{1}); @@ -53,10 +52,10 @@ TEST_CASE("publish subject multicasts values") validate(mock_2); } } - SECTION("emit error") + SUBCASE("emit error") { sub.get_observer().on_error(std::make_exception_ptr(std::runtime_error{""})); - SECTION("observers obtain error") + SUBCASE("observers obtain error") { auto validate = [](auto mock) { CHECK(mock.get_total_on_next_count() == 0); @@ -65,7 +64,7 @@ TEST_CASE("publish subject multicasts values") }; validate(mock_1); validate(mock_2); - SECTION("and then emission of on_next does nothing") + SUBCASE("and then emission of on_next does nothing") { sub.get_observer().on_next(1); validate(mock_1); @@ -73,10 +72,10 @@ TEST_CASE("publish subject multicasts values") } } } - SECTION("emit on_completed") + SUBCASE("emit on_completed") { sub.get_observer().on_completed(); - SECTION("observers obtain on_completed") + SUBCASE("observers obtain on_completed") { auto validate = [](auto mock) { CHECK(mock.get_total_on_next_count() == 0); @@ -86,7 +85,7 @@ TEST_CASE("publish subject multicasts values") validate(mock_1); validate(mock_2); - SECTION("and then emission of on_next does nothing") + SUBCASE("and then emission of on_next does nothing") { sub.get_observer().on_next(1); validate(mock_1); @@ -94,9 +93,9 @@ TEST_CASE("publish subject multicasts values") } } } - SECTION("emit multiple values") + SUBCASE("emit multiple values") { - SECTION("each sbuscriber obtain first value, then seconds and etc") + SUBCASE("each sbuscriber obtain first value, then seconds and etc") { sub.get_observer().on_next(1); auto check_1 = [](auto mock) { @@ -113,7 +112,7 @@ TEST_CASE("publish subject multicasts values") check_2(mock_2); } } - SECTION("first subscriber unsubscribes and then emit value") + SUBCASE("first subscriber unsubscribes and then emit value") { // 1 native, 1 inside subject // CHECK(dis_1.use_count() == 2); @@ -122,7 +121,7 @@ TEST_CASE("publish subject multicasts values") // CHECK(dis_1.use_count() == 1); sub.get_observer().on_next(1); - SECTION("observers obtain value") + SUBCASE("observers obtain value") { CHECK(mock_1.get_total_on_next_count() == 0); CHECK(mock_1.get_on_error_count() == 0); @@ -143,7 +142,7 @@ TEST_CASE("subject can be modified from on_next call") rpp::subjects::publish_subject subject{}; mock_observer inner_mock{}; - SECTION("subscribe inside on_next") + SUBCASE("subscribe inside on_next") { subject.get_observable().subscribe([&subject, &inner_mock](int) { subject.get_observable().subscribe(inner_mock); @@ -155,7 +154,7 @@ TEST_CASE("subject can be modified from on_next call") subject.get_observer().on_next(2); } - SECTION("unsubscribe inside on_next") + SUBCASE("unsubscribe inside on_next") { auto d = rpp::composite_disposable_wrapper::make(); @@ -173,16 +172,16 @@ TEST_CASE("subject can be modified from on_next call") TEST_CASE("publish subject caches error/completed") { auto mock = mock_observer_strategy{}; - SECTION("publish subject") + SUBCASE("publish subject") { auto subj = rpp::subjects::publish_subject{}; - SECTION("emit value") + SUBCASE("emit value") { subj.get_observer().on_next(1); - SECTION("subscribe observer after emission") + SUBCASE("subscribe observer after emission") { subj.get_observable().subscribe(mock); - SECTION("observer doesn't obtain value") + SUBCASE("observer doesn't obtain value") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); @@ -190,13 +189,13 @@ TEST_CASE("publish subject caches error/completed") } } } - SECTION("emit error") + SUBCASE("emit error") { subj.get_observer().on_error(std::make_exception_ptr(std::runtime_error{""})); - SECTION("subscribe observer after emission") + SUBCASE("subscribe observer after emission") { subj.get_observable().subscribe(mock); - SECTION("observer obtains error") + SUBCASE("observer obtains error") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); @@ -204,13 +203,13 @@ TEST_CASE("publish subject caches error/completed") } } } - SECTION("emit on_completed") + SUBCASE("emit on_completed") { subj.get_observer().on_completed(); - SECTION("subscribe observer after emission") + SUBCASE("subscribe observer after emission") { subj.get_observable().subscribe(mock); - SECTION("observer obtains on_completed") + SUBCASE("observer obtains on_completed") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); @@ -218,14 +217,14 @@ TEST_CASE("publish subject caches error/completed") } } } - SECTION("emit error and on_completed") + SUBCASE("emit error and on_completed") { subj.get_observer().on_error(std::make_exception_ptr(std::runtime_error{""})); subj.get_observer().on_completed(); - SECTION("subscribe observer after emission") + SUBCASE("subscribe observer after emission") { subj.get_observable().subscribe(mock); - SECTION("observer obtains error") + SUBCASE("observer obtains error") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); @@ -233,14 +232,14 @@ TEST_CASE("publish subject caches error/completed") } } } - SECTION("emit on_completed and error") + SUBCASE("emit on_completed and error") { subj.get_observer().on_completed(); subj.get_observer().on_error(std::make_exception_ptr(std::runtime_error{""})); - SECTION("subscribe observer after emission") + SUBCASE("subscribe observer after emission") { subj.get_observable().subscribe(mock); - SECTION("observer obtains on_completed") + SUBCASE("observer obtains on_completed") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); @@ -248,7 +247,7 @@ TEST_CASE("publish subject caches error/completed") } } } - SECTION("emit everything after on_completed via get_observer to avoid subscription") + SUBCASE("emit everything after on_completed via get_observer to avoid subscription") { auto observer = subj.get_observer(); observer.on_completed(); @@ -256,7 +255,7 @@ TEST_CASE("publish subject caches error/completed") observer.on_next(1); observer.on_error(std::make_exception_ptr(std::runtime_error{""})); observer.on_completed(); - SECTION("no any calls except of cached on_completed") + SUBCASE("no any calls except of cached on_completed") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); @@ -266,7 +265,7 @@ TEST_CASE("publish subject caches error/completed") } } -TEMPLATE_TEST_CASE("serialized subjects handles race condition", "", rpp::subjects::serialized_publish_subject, rpp::subjects::serialized_replay_subject, rpp::subjects::serialized_behavior_subject) +TEST_CASE_TEMPLATE("serialized subjects handles race condition", TestType, rpp::subjects::serialized_publish_subject, rpp::subjects::serialized_replay_subject, rpp::subjects::serialized_behavior_subject) { auto subj = []() { if constexpr (std::same_as>) @@ -275,7 +274,7 @@ TEMPLATE_TEST_CASE("serialized subjects handles race condition", "", rpp::subjec return TestType{}; }(); - SECTION("call on_next from 2 threads") + SUBCASE("call on_next from 2 threads") { bool on_error_called{}; rpp::source::create([&](auto&& obs) { @@ -295,9 +294,9 @@ TEMPLATE_TEST_CASE("serialized subjects handles race condition", "", rpp::subjec } } -TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subjects::replay_subject, rpp::subjects::serialized_replay_subject) +TEST_CASE_TEMPLATE("replay subject multicasts values and replay", TestType, rpp::subjects::replay_subject, rpp::subjects::serialized_replay_subject) { - SECTION("replay subject") + SUBCASE("replay subject") { auto mock_1 = mock_observer_strategy{}; auto mock_2 = mock_observer_strategy{}; @@ -305,7 +304,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje auto sub = TestType{}; - SECTION("subscribe multiple observers") + SUBCASE("subscribe multiple observers") { sub.get_observable().subscribe(mock_1.get_observer()); sub.get_observable().subscribe(mock_2.get_observer()); @@ -314,7 +313,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje sub.get_observer().on_next(2); sub.get_observer().on_next(3); - SECTION("observers obtain values") + SUBCASE("observers obtain values") { auto validate = [](auto mock) { CHECK(mock.get_received_values() == std::vector{1, 2, 3}); @@ -328,7 +327,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje sub.get_observable().subscribe(mock_3.get_observer()); - SECTION("observer obtains replayed values") + SUBCASE("observer obtains replayed values") { CHECK(mock_3.get_received_values() == std::vector{1, 2, 3}); CHECK(mock_3.get_total_on_next_count() == 3); @@ -338,7 +337,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje sub.get_observer().on_next(4); - SECTION("observers stil obtain values") + SUBCASE("observers stil obtain values") { auto validate = [](auto mock) { CHECK(mock.get_received_values() == std::vector{1, 2, 3, 4}); @@ -353,7 +352,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje } } - SECTION("bounded replay subject") + SUBCASE("bounded replay subject") { auto mock_1 = mock_observer_strategy{}; auto mock_2 = mock_observer_strategy{}; @@ -361,7 +360,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje size_t bound = 1; auto sub = TestType{bound}; - SECTION("subscribe multiple observers") + SUBCASE("subscribe multiple observers") { sub.get_observable().subscribe(mock_1.get_observer()); @@ -369,7 +368,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje sub.get_observer().on_next(2); sub.get_observer().on_next(3); - SECTION("observer obtains values") + SUBCASE("observer obtains values") { CHECK(mock_1.get_received_values() == std::vector{1, 2, 3}); CHECK(mock_1.get_total_on_next_count() == 3); @@ -379,7 +378,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje sub.get_observable().subscribe(mock_2.get_observer()); - SECTION("observer obtains latest replayed values") + SUBCASE("observer obtains latest replayed values") { CHECK(mock_2.get_received_values() == std::vector{3}); CHECK(mock_2.get_total_on_next_count() == 1); @@ -389,7 +388,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje } } - SECTION("bounded replay subject with duration") + SUBCASE("bounded replay subject with duration") { using namespace std::chrono_literals; @@ -400,7 +399,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje auto duration = 5ms; auto sub = TestType{bound, duration}; - SECTION("subscribe multiple observers") + SUBCASE("subscribe multiple observers") { sub.get_observable().subscribe(mock_1.get_observer()); @@ -408,7 +407,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje sub.get_observer().on_next(2); sub.get_observer().on_next(3); - SECTION("observer obtains values") + SUBCASE("observer obtains values") { CHECK(mock_1.get_received_values() == std::vector{1, 2, 3}); CHECK(mock_1.get_total_on_next_count() == 3); @@ -420,7 +419,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje sub.get_observable().subscribe(mock_2.get_observer()); - SECTION("subject replay only non expired values") + SUBCASE("subject replay only non expired values") { CHECK(mock_2.get_received_values() == std::vector{}); CHECK(mock_2.get_total_on_next_count() == 0); @@ -431,9 +430,9 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje } } -TEMPLATE_TEST_CASE("replay subject doesn't introduce additional copies", "", rpp::subjects::replay_subject, rpp::subjects::serialized_replay_subject) +TEST_CASE_TEMPLATE("replay subject doesn't introduce additional copies", TestType, rpp::subjects::replay_subject, rpp::subjects::serialized_replay_subject) { - SECTION("on_next by rvalue") + SUBCASE("on_next by rvalue") { auto sub = TestType{}; @@ -450,7 +449,7 @@ TEMPLATE_TEST_CASE("replay subject doesn't introduce additional copies", "", rpp }); } - SECTION("on_next by lvalue") + SUBCASE("on_next by lvalue") { copy_count_tracker tracker{}; auto sub = TestType{}; @@ -469,19 +468,19 @@ TEMPLATE_TEST_CASE("replay subject doesn't introduce additional copies", "", rpp } } -TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subjects::behavior_subject, rpp::subjects::serialized_behavior_subject) +TEST_CASE_TEMPLATE("replay subject multicasts values and replay", TestType, rpp::subjects::behavior_subject, rpp::subjects::serialized_behavior_subject) { const auto mock_1 = mock_observer_strategy{}; const auto subj = TestType{10}; CHECK(subj.get_value() == 10); - SECTION("subscribe to subject with default") + SUBCASE("subscribe to subject with default") { subj.get_observable().subscribe(mock_1); CHECK(mock_1.get_received_values() == std::vector{10}); - SECTION("emit value and subscribe other observer") + SUBCASE("emit value and subscribe other observer") { const auto mock_2 = mock_observer_strategy{}; @@ -495,7 +494,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje CHECK(mock_2.get_received_values() == std::vector{5}); - SECTION("emit one more value and subscribe one more other observer") + SUBCASE("emit one more value and subscribe one more other observer") { const auto mock_3 = mock_observer_strategy{}; subj.get_observer().on_next(1); @@ -511,7 +510,7 @@ TEMPLATE_TEST_CASE("replay subject multicasts values and replay", "", rpp::subje } } - SECTION("subject keeps error") + SUBCASE("subject keeps error") { subj.get_observer().on_error(std::exception_ptr{}); CHECK(mock_1.get_on_error_count() == 1); diff --git a/src/tests/rpp/test_subscribe.cpp b/src/tests/rpp/test_subscribe.cpp index 8fca2b799..9829395a0 100644 --- a/src/tests/rpp/test_subscribe.cpp +++ b/src/tests/rpp/test_subscribe.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -17,19 +16,19 @@ #include -TEMPLATE_TEST_CASE("subscribe as operator", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("subscribe as operator", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { mock_observer_strategy mock{}; auto observable = rpp::source::just(1); - SECTION("subscribe observer strategy") + SUBCASE("subscribe observer strategy") { static_assert(std::is_same_v); observable | rpp::operators::subscribe(mock); CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe observer strategy with disposable") + SUBCASE("subscribe observer strategy with disposable") { static_assert(std::is_same_v); auto d = observable | rpp::operators::subscribe(rpp::composite_disposable_wrapper::make(), mock); @@ -37,7 +36,7 @@ TEMPLATE_TEST_CASE("subscribe as operator", "", rpp::memory_model::use_stack, rp CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe observer strategy with disposed disposable") + SUBCASE("subscribe observer strategy with disposed disposable") { static_assert(std::is_same_v); auto d = observable | rpp::operators::subscribe(rpp::composite_disposable_wrapper::empty(), mock); @@ -45,14 +44,14 @@ TEMPLATE_TEST_CASE("subscribe as operator", "", rpp::memory_model::use_stack, rp CHECK(mock.get_received_values().empty()); } - SECTION("subscribe observer") + SUBCASE("subscribe observer") { static_assert(std::is_same_v); observable | rpp::operators::subscribe(mock.get_observer()); CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe observer with disposable") + SUBCASE("subscribe observer with disposable") { static_assert(std::is_same_v); auto d = observable | rpp::operators::subscribe(rpp::composite_disposable_wrapper::make(), mock.get_observer()); @@ -60,7 +59,7 @@ TEMPLATE_TEST_CASE("subscribe as operator", "", rpp::memory_model::use_stack, rp CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe observer with disposed disposable") + SUBCASE("subscribe observer with disposed disposable") { static_assert(std::is_same_v); auto d = observable | rpp::operators::subscribe(rpp::composite_disposable_wrapper::empty(), mock.get_observer()); @@ -68,14 +67,14 @@ TEMPLATE_TEST_CASE("subscribe as operator", "", rpp::memory_model::use_stack, rp CHECK(mock.get_received_values().empty()); } - SECTION("subscribe dynamic observer") + SUBCASE("subscribe dynamic observer") { static_assert(std::is_same_v); observable | rpp::operators::subscribe(mock.get_observer().as_dynamic()); CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe dynamic observer with disposable") + SUBCASE("subscribe dynamic observer with disposable") { static_assert(std::is_same_v); auto d = observable | rpp::operators::subscribe(rpp::composite_disposable_wrapper::make(), mock.get_observer().as_dynamic()); @@ -83,7 +82,7 @@ TEMPLATE_TEST_CASE("subscribe as operator", "", rpp::memory_model::use_stack, rp CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe dynamic observer with disposed disposable") + SUBCASE("subscribe dynamic observer with disposed disposable") { static_assert(std::is_same_v); auto d = observable | rpp::operators::subscribe(rpp::composite_disposable_wrapper::empty(), mock.get_observer().as_dynamic()); @@ -91,14 +90,14 @@ TEMPLATE_TEST_CASE("subscribe as operator", "", rpp::memory_model::use_stack, rp CHECK(mock.get_received_values().empty()); } - SECTION("subscribe lambdas") + SUBCASE("subscribe lambdas") { static_assert(std::is_same_v{}, rpp::utils::empty_function_t{}, rpp::utils::empty_function_t<>{})), void>); observable | rpp::operators::subscribe([&mock](const auto& v) { mock.on_next(v); }, rpp::utils::empty_function_t{}, rpp::utils::empty_function_t<>{}); CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe lambdas with disposable") + SUBCASE("subscribe lambdas with disposable") { static_assert(std::is_same_v{}, rpp::utils::empty_function_t{}, rpp::utils::empty_function_t<>{})), rpp::composite_disposable_wrapper>); auto d = observable | rpp::operators::subscribe(rpp::composite_disposable_wrapper::make(), [&mock](const auto& v) { mock.on_next(v); }, rpp::utils::empty_function_t{}, rpp::utils::empty_function_t<>{}); @@ -106,7 +105,7 @@ TEMPLATE_TEST_CASE("subscribe as operator", "", rpp::memory_model::use_stack, rp CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe lambdas with disposed disposable") + SUBCASE("subscribe lambdas with disposed disposable") { static_assert(std::is_same_v{}, rpp::utils::empty_function_t{}, rpp::utils::empty_function_t<>{})), rpp::composite_disposable_wrapper>); auto d = observable | rpp::operators::subscribe(rpp::composite_disposable_wrapper::empty(), [&mock](const auto& v) { mock.on_next(v); }, rpp::utils::empty_function_t{}, rpp::utils::empty_function_t<>{}); @@ -115,19 +114,19 @@ TEMPLATE_TEST_CASE("subscribe as operator", "", rpp::memory_model::use_stack, rp } } -TEMPLATE_TEST_CASE("subscribe as member", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("subscribe as member", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { mock_observer_strategy mock{}; auto observable = rpp::source::just(1); - SECTION("subscribe observer strategy") + SUBCASE("subscribe observer strategy") { static_assert(std::is_same_v); observable.subscribe(mock); CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe observer strategy with disposable") + SUBCASE("subscribe observer strategy with disposable") { static_assert(std::is_same_v); auto d = observable.subscribe(rpp::composite_disposable_wrapper::make(), mock); @@ -135,7 +134,7 @@ TEMPLATE_TEST_CASE("subscribe as member", "", rpp::memory_model::use_stack, rpp: CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe observer strategy with disposed disposable") + SUBCASE("subscribe observer strategy with disposed disposable") { static_assert(std::is_same_v); auto d = observable.subscribe(rpp::composite_disposable_wrapper::empty(), mock); @@ -143,14 +142,14 @@ TEMPLATE_TEST_CASE("subscribe as member", "", rpp::memory_model::use_stack, rpp: CHECK(mock.get_received_values().empty()); } - SECTION("subscribe observer") + SUBCASE("subscribe observer") { static_assert(std::is_same_v); observable.subscribe(mock); CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe observer with disposable") + SUBCASE("subscribe observer with disposable") { static_assert(std::is_same_v); auto d = observable.subscribe(rpp::composite_disposable_wrapper::make(), mock.get_observer()); @@ -158,7 +157,7 @@ TEMPLATE_TEST_CASE("subscribe as member", "", rpp::memory_model::use_stack, rpp: CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe observer with disposed disposable") + SUBCASE("subscribe observer with disposed disposable") { static_assert(std::is_same_v); auto d = observable.subscribe(rpp::composite_disposable_wrapper::empty(), mock.get_observer()); @@ -166,14 +165,14 @@ TEMPLATE_TEST_CASE("subscribe as member", "", rpp::memory_model::use_stack, rpp: CHECK(mock.get_received_values().empty()); } - SECTION("subscribe dynamic observer") + SUBCASE("subscribe dynamic observer") { static_assert(std::is_same_v); observable.subscribe(mock.get_observer().as_dynamic()); CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe dynamic observer with disposable") + SUBCASE("subscribe dynamic observer with disposable") { static_assert(std::is_same_v); auto d = observable.subscribe(rpp::composite_disposable_wrapper::make(), mock.get_observer().as_dynamic()); @@ -181,7 +180,7 @@ TEMPLATE_TEST_CASE("subscribe as member", "", rpp::memory_model::use_stack, rpp: CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe dynamic observer with disposed disposable") + SUBCASE("subscribe dynamic observer with disposed disposable") { static_assert(std::is_same_v); auto d = observable.subscribe(rpp::composite_disposable_wrapper::empty(), mock.get_observer().as_dynamic()); @@ -189,14 +188,14 @@ TEMPLATE_TEST_CASE("subscribe as member", "", rpp::memory_model::use_stack, rpp: CHECK(mock.get_received_values().empty()); } - SECTION("subscribe lambdas") + SUBCASE("subscribe lambdas") { static_assert(std::is_same_v{}, rpp::utils::empty_function_t{}, rpp::utils::empty_function_t<>{})), void>); observable.subscribe([&mock](const auto& v) { mock.on_next(v); }, rpp::utils::empty_function_t{}, rpp::utils::empty_function_t<>{}); CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe lambdas with disposable") + SUBCASE("subscribe lambdas with disposable") { static_assert(std::is_same_v{}, rpp::utils::empty_function_t{}, rpp::utils::empty_function_t<>{})), rpp::composite_disposable_wrapper>); auto d = observable.subscribe( @@ -208,7 +207,7 @@ TEMPLATE_TEST_CASE("subscribe as member", "", rpp::memory_model::use_stack, rpp: CHECK(mock.get_received_values() == std::vector{1}); } - SECTION("subscribe lambdas with disposed disposable") + SUBCASE("subscribe lambdas with disposed disposable") { static_assert(std::is_same_v{}, rpp::utils::empty_function_t{}, rpp::utils::empty_function_t<>{})), rpp::composite_disposable_wrapper>); auto d = observable.subscribe( diff --git a/src/tests/rpp/test_subscribe_on.cpp b/src/tests/rpp/test_subscribe_on.cpp index 5a39e7be3..f85d4f178 100644 --- a/src/tests/rpp/test_subscribe_on.cpp +++ b/src/tests/rpp/test_subscribe_on.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -35,7 +34,7 @@ TEST_CASE("subscribe_on schedules job in another scheduler") auto mock = mock_observer_strategy{}; auto scheduler = rpp::schedulers::new_thread{}; - SECTION("observable") + SUBCASE("observable") { std::promise thread_id{}; auto obs = rpp::source::create([&](auto&& sub) { @@ -44,10 +43,10 @@ TEST_CASE("subscribe_on schedules job in another scheduler") sub.on_next(1); sub.on_completed(); }); - SECTION("subscribe on it with subscribe_on") + SUBCASE("subscribe on it with subscribe_on") { obs | rpp::ops::subscribe_on(scheduler) | rpp::ops::as_blocking() | rpp::ops::subscribe(mock); - SECTION("expect to obtain value via scheduling") + SUBCASE("expect to obtain value via scheduling") { REQUIRE(mock.get_total_on_next_count() == 1); REQUIRE(mock.get_on_completed_count() == 1); @@ -55,13 +54,13 @@ TEST_CASE("subscribe_on schedules job in another scheduler") } } } - SECTION("observable with error") + SUBCASE("observable with error") { auto obs = rpp::source::error(std::make_exception_ptr(std::runtime_error{""})); - SECTION("subscribe on it with subscribe_on") + SUBCASE("subscribe on it with subscribe_on") { obs | rpp::ops::subscribe_on(scheduler) | rpp::ops::as_blocking() | rpp::ops::subscribe(mock); - SECTION("expect to obtain error via scheduling") + SUBCASE("expect to obtain error via scheduling") { REQUIRE(mock.get_total_on_next_count() == 0); REQUIRE(mock.get_on_error_count() == 1); @@ -69,7 +68,7 @@ TEST_CASE("subscribe_on schedules job in another scheduler") } } } - SECTION("subscribe_on inside current_thread scheduler and disposing it before execution") + SUBCASE("subscribe_on inside current_thread scheduler and disposing it before execution") { bool executed{}; @@ -93,7 +92,7 @@ TEST_CASE("subscribe_on schedules job in another scheduler") CHECK(!executed); } - SECTION("subscribe_on and then upstream updates upstream inside observer") + SUBCASE("subscribe_on and then upstream updates upstream inside observer") { auto d = rpp::composite_disposable_wrapper::make(); auto second = rpp::composite_disposable_wrapper::make(); diff --git a/src/tests/rpp/test_switch_on_next.cpp b/src/tests/rpp/test_switch_on_next.cpp index f16d19e62..18613c985 100644 --- a/src/tests/rpp/test_switch_on_next.cpp +++ b/src/tests/rpp/test_switch_on_next.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -26,13 +25,13 @@ TEST_CASE("switch_on_next switches observable after obtaining new one") { auto mock = mock_observer_strategy(); - SECTION("just observable of just observables") + SUBCASE("just observable of just observables") { auto observable = rpp::source::just(rpp::source::just(1), rpp::source::just(2), rpp::source::just(3)); - SECTION("subscribe on it via switch_on_next") + SUBCASE("subscribe on it via switch_on_next") { observable | rpp::ops::switch_on_next() | rpp::ops::subscribe(mock); - SECTION("obtains values as from concat") + SUBCASE("obtains values as from concat") { CHECK(mock.get_received_values() == std::vector{1, 2, 3}); CHECK(mock.get_on_error_count() == 0); @@ -40,15 +39,15 @@ TEST_CASE("switch_on_next switches observable after obtaining new one") } } } - SECTION("just observable of just observables where second is error") + SUBCASE("just observable of just observables where second is error") { auto observable = rpp::source::just(rpp::source::just(1).as_dynamic(), rpp::source::error(std::make_exception_ptr(std::runtime_error{""})).as_dynamic(), rpp::source::just(3).as_dynamic()); - SECTION("subscribe on it via switch_on_next") + SUBCASE("subscribe on it via switch_on_next") { observable | rpp::ops::switch_on_next() | rpp::ops::subscribe(mock); - SECTION("obtains values as from concat but stops on error") + SUBCASE("obtains values as from concat but stops on error") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_error_count() == 1); @@ -56,15 +55,15 @@ TEST_CASE("switch_on_next switches observable after obtaining new one") } } } - SECTION("just observable of just observables where second is completed") + SUBCASE("just observable of just observables where second is completed") { auto observable = rpp::source::just(rpp::source::just(1).as_dynamic(), rpp::source::empty().as_dynamic(), rpp::source::just(3).as_dynamic()); - SECTION("subscribe on it via switch_on_next") + SUBCASE("subscribe on it via switch_on_next") { observable | rpp::ops::switch_on_next() | rpp::ops::subscribe(mock); - SECTION("obtains values as from concat") + SUBCASE("obtains values as from concat") { CHECK(mock.get_received_values() == std::vector{1, 3}); CHECK(mock.get_on_error_count() == 0); @@ -72,15 +71,15 @@ TEST_CASE("switch_on_next switches observable after obtaining new one") } } } - SECTION("just observable of just observables where second is never") + SUBCASE("just observable of just observables where second is never") { auto observable = rpp::source::just(rpp::source::just(1).as_dynamic(), rpp::source::never().as_dynamic(), rpp::source::just(3).as_dynamic()); - SECTION("subscribe on it via switch_on_next") + SUBCASE("subscribe on it via switch_on_next") { observable | rpp::ops::switch_on_next() | rpp::ops::subscribe(mock); - SECTION("obtains values as from concat") + SUBCASE("obtains values as from concat") { CHECK(mock.get_received_values() == std::vector{1, 3}); CHECK(mock.get_on_error_count() == 0); @@ -88,15 +87,15 @@ TEST_CASE("switch_on_next switches observable after obtaining new one") } } } - SECTION("just observable of just observables where last is never") + SUBCASE("just observable of just observables where last is never") { auto observable = rpp::source::just(rpp::source::just(1).as_dynamic(), rpp::source::just(3).as_dynamic(), rpp::source::never().as_dynamic()); - SECTION("subscribe on it via switch_on_next") + SUBCASE("subscribe on it via switch_on_next") { observable | rpp::ops::switch_on_next() | rpp::ops::subscribe(mock); - SECTION("obtains values as from concat but no complete") + SUBCASE("obtains values as from concat but no complete") { CHECK(mock.get_received_values() == std::vector{1, 3}); CHECK(mock.get_on_error_count() == 0); @@ -104,22 +103,22 @@ TEST_CASE("switch_on_next switches observable after obtaining new one") } } } - SECTION("subject of just subjects") + SUBCASE("subject of just subjects") { auto subj_1 = rpp::subjects::publish_subject(); auto subj_2 = rpp::subjects::publish_subject(); auto subj_of_subjects = rpp::subjects::publish_subject>(); - SECTION("subscribe on it via switch_on_next") + SUBCASE("subscribe on it via switch_on_next") { subj_of_subjects.get_observable() | rpp::ops::switch_on_next() | rpp::ops::subscribe(mock); - SECTION("send first subject and send values for all subjects") + SUBCASE("send first subject and send values for all subjects") { subj_1.get_observer().on_next(0); subj_of_subjects.get_observer().on_next(subj_1.get_observable().as_dynamic()); - SECTION("Only value from first subject obtained") + SUBCASE("Only value from first subject obtained") { subj_1.get_observer().on_next(1); subj_2.get_observer().on_next(2); @@ -128,11 +127,11 @@ TEST_CASE("switch_on_next switches observable after obtaining new one") CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("send second subject and send values for all subjects") + SUBCASE("send second subject and send values for all subjects") { subj_of_subjects.get_observer().on_next(subj_2.get_observable().as_dynamic()); - SECTION("Only value from second subject obtained") + SUBCASE("Only value from second subject obtained") { subj_1.get_observer().on_next(1); subj_2.get_observer().on_next(2); @@ -142,21 +141,21 @@ TEST_CASE("switch_on_next switches observable after obtaining new one") CHECK(mock.get_on_completed_count() == 0); } } - SECTION("original subject completes but provided send value") + SUBCASE("original subject completes but provided send value") { subj_of_subjects.get_observer().on_completed(); subj_1.get_observer().on_next(1); subj_2.get_observer().on_next(2); - SECTION("value obtained") + SUBCASE("value obtained") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("subject sends on_completed") + SUBCASE("subject sends on_completed") { subj_1.get_observer().on_completed(); - SECTION("subsriber completed") + SUBCASE("subsriber completed") { CHECK(mock.get_on_completed_count() == 1); } @@ -169,14 +168,14 @@ TEST_CASE("switch_on_next switches observable after obtaining new one") TEST_CASE("switch_on_next doesn't produce extra copies") { - SECTION("observable and subscriber") + SUBCASE("observable and subscriber") { copy_count_tracker verifier{}; auto obs = rpp::source::just(verifier.get_observable()) | rpp::ops::switch_on_next(); - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::ops::subscribe([](copy_count_tracker) {}); // NOLINT - SECTION("no extra copies") + SUBCASE("no extra copies") { REQUIRE(verifier.get_copy_count() == 1); // 1 copy to final lambda REQUIRE(verifier.get_move_count() == 0); @@ -187,14 +186,14 @@ TEST_CASE("switch_on_next doesn't produce extra copies") TEST_CASE("switch_on_next doesn't produce extra copies for move") { - SECTION("observable and subscriber") + SUBCASE("observable and subscriber") { copy_count_tracker verifier{}; auto obs = rpp::source::just(verifier.get_observable_for_move()) | rpp::ops::switch_on_next(); - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::ops::subscribe([](copy_count_tracker) {}); // NOLINT - SECTION("no extra copies") + SUBCASE("no extra copies") { REQUIRE(verifier.get_copy_count() == 0); REQUIRE(verifier.get_move_count() == 1); // 1 move to final lambda @@ -205,13 +204,13 @@ TEST_CASE("switch_on_next doesn't produce extra copies for move") TEST_CASE("switch_on_next handles race condition") { - SECTION("source observable in current thread pairs with error in other thread") + SUBCASE("source observable in current thread pairs with error in other thread") { std::atomic_bool on_error_called{false}; auto subject = rpp::subjects::publish_subject>{}; - SECTION("subscribe on it") + SUBCASE("subscribe on it") { - SECTION("on_error can't interleave with on_next") + SUBCASE("on_error can't interleave with on_next") { std::thread th{}; diff --git a/src/tests/rpp/test_take.cpp b/src/tests/rpp/test_take.cpp index ed62e148d..9f4b732d0 100644 --- a/src/tests/rpp/test_take.cpp +++ b/src/tests/rpp/test_take.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -38,7 +37,7 @@ TEST_CASE("take operator limits emissions") mock_observer_strategy mock{}; - SECTION("subscribe via take(3)") + SUBCASE("subscribe via take(3)") { (obs | rpp::operators::take(3)).subscribe(mock); @@ -47,7 +46,7 @@ TEST_CASE("take operator limits emissions") CHECK(mock.get_on_completed_count() == 1); } - SECTION("subscribe via take(2) | take(3)") + SUBCASE("subscribe via take(2) | take(3)") { (obs | rpp::operators::take(2) | rpp::operators::take(3)).subscribe(mock); @@ -56,7 +55,7 @@ TEST_CASE("take operator limits emissions") CHECK(mock.get_on_completed_count() == 1); } - SECTION("subscribe via take(0)") + SUBCASE("subscribe via take(0)") { (obs | rpp::operators::take(0)).subscribe(mock); @@ -96,7 +95,7 @@ TEST_CASE("take operator forwards on_error") TEST_CASE("take doesn't produce extra copies") { - SECTION("take(1)") + SUBCASE("take(1)") { copy_count_tracker::test_operator(rpp::ops::take(1), { diff --git a/src/tests/rpp/test_take_last.cpp b/src/tests/rpp/test_take_last.cpp index ed21b8313..f668c43fa 100644 --- a/src/tests/rpp/test_take_last.cpp +++ b/src/tests/rpp/test_take_last.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -26,13 +25,13 @@ TEST_CASE("take_last sends last values in correct order on completed") { auto mock = mock_observer_strategy{}; - SECTION("observable of +-1-2-3-4-5-|") + SUBCASE("observable of +-1-2-3-4-5-|") { auto obs = rpp::source::just(1, 2, 3, 4, 5); - SECTION("subscribe on it via take_last(1)") + SUBCASE("subscribe on it via take_last(1)") { obs | rpp::ops::take_last(1) | rpp::ops::subscribe(mock); - SECTION("see +-5-|") + SUBCASE("see +-5-|") { CHECK(mock.get_received_values() == std::vector{5}); CHECK(mock.get_on_error_count() == 0); @@ -40,10 +39,10 @@ TEST_CASE("take_last sends last values in correct order on completed") } } - SECTION("subscribe on it via take_last(3)") + SUBCASE("subscribe on it via take_last(3)") { obs | rpp::ops::take_last(3) | rpp::ops::subscribe(mock); - SECTION("see +-3-4-5-|") + SUBCASE("see +-3-4-5-|") { CHECK(mock.get_received_values() == std::vector{3, 4, 5}); CHECK(mock.get_on_error_count() == 0); @@ -51,10 +50,10 @@ TEST_CASE("take_last sends last values in correct order on completed") } } - SECTION("subscribe on it via take_last(5)") + SUBCASE("subscribe on it via take_last(5)") { obs | rpp::ops::take_last(5) | rpp::ops::subscribe(mock); - SECTION("see +-1-2-3-4-5-|") + SUBCASE("see +-1-2-3-4-5-|") { CHECK(mock.get_received_values() == std::vector{1, 2, 3, 4, 5}); CHECK(mock.get_on_error_count() == 0); @@ -62,20 +61,20 @@ TEST_CASE("take_last sends last values in correct order on completed") } } - SECTION("subscribe on it via take_last(10)") + SUBCASE("subscribe on it via take_last(10)") { obs | rpp::ops::take_last(10) | rpp::ops::subscribe(mock); - SECTION("see +-1-2-3-4-5-|") + SUBCASE("see +-1-2-3-4-5-|") { CHECK(mock.get_received_values() == std::vector{1, 2, 3, 4, 5}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } } - SECTION("subscribe on it via take_last(0)") + SUBCASE("subscribe on it via take_last(0)") { obs | rpp::ops::take_last(0) | rpp::ops::subscribe(mock); - SECTION("see +-|") + SUBCASE("see +-|") { CHECK(mock.get_received_values().empty()); CHECK(mock.get_on_error_count() == 0); @@ -89,13 +88,13 @@ TEST_CASE("take_last sends last values in correct order on completed") TEST_CASE("take_last forwards error") { auto mock = mock_observer_strategy{}; - SECTION("observable of +-x") + SUBCASE("observable of +-x") { auto source = rpp::source::error(std::exception_ptr{}); - SECTION("subscribe on it via take(2)") + SUBCASE("subscribe on it via take(2)") { source | rpp::ops::take_last(2) | rpp::ops::subscribe(mock); - SECTION("see error") + SUBCASE("see error") { CHECK(mock.get_received_values().empty()); CHECK(mock.get_on_error_count() == 1); @@ -104,17 +103,17 @@ TEST_CASE("take_last forwards error") } } - SECTION("observable of +-1-x") + SUBCASE("observable of +-1-x") { auto source = rpp::source::create([](const auto& obs) { obs.on_next(1); obs.on_error({}); }); - SECTION("subscribe on it via take(2)") + SUBCASE("subscribe on it via take(2)") { source | rpp::ops::take_last(2) | rpp::ops::subscribe(mock); - SECTION("see error") + SUBCASE("see error") { CHECK(mock.get_received_values().empty()); CHECK(mock.get_on_error_count() == 1); @@ -127,13 +126,13 @@ TEST_CASE("take_last forwards error") TEST_CASE("take_last completes with empty") { auto mock = mock_observer_strategy{}; - SECTION("observable of +-|") + SUBCASE("observable of +-|") { auto source = rpp::source::empty(); - SECTION("subscribe on it via take(2)") + SUBCASE("subscribe on it via take(2)") { source | rpp::ops::take_last(2) | rpp::ops::subscribe(mock); - SECTION("see completed") + SUBCASE("see completed") { CHECK(mock.get_received_values().empty()); CHECK(mock.get_on_error_count() == 0); @@ -146,13 +145,13 @@ TEST_CASE("take_last completes with empty") TEST_CASE("take_last nothing with never") { auto mock = mock_observer_strategy{}; - SECTION("observable of +-|") + SUBCASE("observable of +-|") { auto source = rpp::source::never(); - SECTION("subscribe on it via take(2)") + SUBCASE("subscribe on it via take(2)") { source | rpp::ops::take_last(2) | rpp::ops::subscribe(mock); - SECTION("see nothing") + SUBCASE("see nothing") { CHECK(mock.get_received_values().empty()); CHECK(mock.get_on_error_count() == 0); @@ -164,7 +163,7 @@ TEST_CASE("take_last nothing with never") TEST_CASE("take_last doesn't produce extra copies") { - SECTION("take_last(1)") + SUBCASE("take_last(1)") { copy_count_tracker::test_operator(rpp::ops::take_last(1), { diff --git a/src/tests/rpp/test_take_until.cpp b/src/tests/rpp/test_take_until.cpp index 5ab1b77cf..727bd29dc 100644 --- a/src/tests/rpp/test_take_until.cpp +++ b/src/tests/rpp/test_take_until.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -31,7 +30,7 @@ TEST_CASE("take_until mirrors both source observable and trigger observable") { auto mock = mock_observer_strategy{}; - SECTION("observable of -1-2... pairs with trigger observable from a publish subject") + SUBCASE("observable of -1-2... pairs with trigger observable from a publish subject") { auto test = [&mock](auto inner_action) { auto subject = rpp::subjects::publish_subject{}; @@ -50,30 +49,30 @@ TEST_CASE("take_until mirrors both source observable and trigger observable") | rpp::ops::subscribe(mock); }; - SECTION("subcject emits on_next") + SUBCASE("subcject emits on_next") { test([](const auto& sub) { sub.on_next(true); }); - SECTION("should see -1-2-|") + SUBCASE("should see -1-2-|") { CHECK(mock.get_received_values() == std::vector{1, 2}); CHECK(mock.get_on_completed_count() == 1); CHECK(mock.get_on_error_count() == 0); } } - SECTION("subcject emits on_error") + SUBCASE("subcject emits on_error") { test([](const auto& sub) { sub.on_error({}); }); - SECTION("should see -1-2-x") + SUBCASE("should see -1-2-x") { CHECK(mock.get_received_values() == std::vector{1, 2}); CHECK(mock.get_on_completed_count() == 0); CHECK(mock.get_on_error_count() == 1); } } - SECTION("subcject emits on_completed") + SUBCASE("subcject emits on_completed") { test([](const auto& sub) { sub.on_completed(); }); - SECTION("should see -1-2-|") + SUBCASE("should see -1-2-|") { CHECK(mock.get_received_values() == std::vector{1, 2}); CHECK(mock.get_on_completed_count() == 1); @@ -82,13 +81,13 @@ TEST_CASE("take_until mirrors both source observable and trigger observable") } } - SECTION("observable of -1-2-3-| pairs with trigger observable of never") + SUBCASE("observable of -1-2-3-| pairs with trigger observable of never") { rpp::source::just(1, 2, 3) | rpp::ops::take_until(rpp::source::never()) | rpp::ops::subscribe(mock); - SECTION("should see -1-2-3-|") + SUBCASE("should see -1-2-3-|") { CHECK(mock.get_received_values() == std::vector{1, 2, 3}); CHECK(mock.get_on_completed_count() == 1); @@ -96,13 +95,13 @@ TEST_CASE("take_until mirrors both source observable and trigger observable") } } - SECTION("observable of -1-| pairs with trigger observable of -1-|") + SUBCASE("observable of -1-| pairs with trigger observable of -1-|") { rpp::source::just(1) | rpp::ops::take_until(rpp::source::just(1)) | rpp::ops::subscribe(mock); - SECTION("should see -| because take_until is subscribed first and it also mirrors the trigger observable 's completed event") + SUBCASE("should see -| because take_until is subscribed first and it also mirrors the trigger observable 's completed event") { CHECK(mock.get_received_values().empty()); CHECK(mock.get_on_completed_count() == 1); @@ -110,13 +109,13 @@ TEST_CASE("take_until mirrors both source observable and trigger observable") } } - SECTION("observable of -1-| pairs with trigger observable of -x") + SUBCASE("observable of -1-| pairs with trigger observable of -x") { rpp::source::just(1) | rpp::ops::take_until(rpp::source::error(std::make_exception_ptr(std::runtime_error{""}))) | rpp::ops::subscribe(mock); - SECTION("should see -x because take_until also mirrors the trigger observable 's error event") + SUBCASE("should see -x because take_until also mirrors the trigger observable 's error event") { CHECK(mock.get_received_values().empty()); CHECK(mock.get_on_completed_count() == 0); @@ -124,13 +123,13 @@ TEST_CASE("take_until mirrors both source observable and trigger observable") } } - SECTION("observable of -1-| pairs with trigger observable of -|") + SUBCASE("observable of -1-| pairs with trigger observable of -|") { rpp::source::just(1) | rpp::ops::take_until(rpp::source::empty()) | rpp::ops::subscribe(mock); - SECTION("should see -| because take_until completes prior to the source") + SUBCASE("should see -| because take_until completes prior to the source") { CHECK(mock.get_received_values().empty()); CHECK(mock.get_on_completed_count() == 1); @@ -141,12 +140,12 @@ TEST_CASE("take_until mirrors both source observable and trigger observable") TEST_CASE("take_until can handle race condition") { - SECTION("observer consumes on_next slower than source sends on_next and on_completed events") + SUBCASE("observer consumes on_next slower than source sends on_next and on_completed events") { std::atomic_bool on_completed_called{false}; auto subject = rpp::subjects::publish_subject{}; - SECTION("on_completed shall not interleave with on_next") + SUBCASE("on_completed shall not interleave with on_next") { rpp::source::concat(rpp::source::just(1) | rpp::ops::take(1), rpp::source::never()) | rpp::ops::take_until(subject.get_observable()) @@ -168,12 +167,12 @@ TEST_CASE("take_until can handle race condition") } } - SECTION("observer consumes on_next slower than source sends on_next and on_error events") + SUBCASE("observer consumes on_next slower than source sends on_next and on_error events") { std::atomic_bool on_error_called{false}; auto subject = rpp::subjects::publish_subject{}; - SECTION("on_error shall not interleave with on_next") + SUBCASE("on_error shall not interleave with on_next") { rpp::source::concat(rpp::source::just(1) | rpp::ops::take(1), rpp::source::never()) | rpp::ops::take_until(subject.get_observable()) @@ -210,7 +209,7 @@ TEST_CASE("take_until handles current_thread scheduling") TEST_CASE("take_until doesn't produce extra copies") { - SECTION("take_until(other)") + SUBCASE("take_until(other)") { copy_count_tracker::test_operator(rpp::ops::take_until(rpp::source::never()), { diff --git a/src/tests/rpp/test_take_while.cpp b/src/tests/rpp/test_take_while.cpp index 0e1f73e6a..8d18f563a 100644 --- a/src/tests/rpp/test_take_while.cpp +++ b/src/tests/rpp/test_take_while.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -26,7 +25,7 @@ TEST_CASE("take_while") { auto mock = mock_observer_strategy{}; - SECTION("-1-2-3-...") + SUBCASE("-1-2-3-...") { auto obs = rpp::source::create( [](const auto& sub) { @@ -35,14 +34,14 @@ TEST_CASE("take_while") sub.on_next(v++); }); - SECTION("take while val <= 5") + SUBCASE("take while val <= 5") { obs | rpp::operators::take_while([](int val) { return val <= 5; }) | rpp::operators::subscribe(mock); CHECK(mock.get_received_values() == std::vector{0, 1, 2, 3, 4, 5}); } - SECTION("take while false") + SUBCASE("take while false") { auto op = rpp::operators::take_while([](auto) { return false; }); obs | op | rpp::operators::subscribe(mock); @@ -50,7 +49,7 @@ TEST_CASE("take_while") CHECK(mock.get_received_values().empty()); } } - SECTION("-x") + SUBCASE("-x") { rpp::source::error({}) | rpp::operators::take_while([](int) { return false; }) | rpp::ops::subscribe(mock); CHECK(mock.get_received_values() == std::vector{}); @@ -58,7 +57,7 @@ TEST_CASE("take_while") CHECK(mock.get_on_completed_count() == 0); } - SECTION("-|") + SUBCASE("-|") { rpp::source::empty() | rpp::operators::take_while([](int) { return true; }) | rpp::ops::subscribe(mock); CHECK(mock.get_received_values() == std::vector{}); @@ -69,7 +68,7 @@ TEST_CASE("take_while") TEST_CASE("take_while doesn't produce extra copies") { - SECTION("take_while([](auto) { return true; })") + SUBCASE("take_while([](auto) { return true; })") { copy_count_tracker::test_operator(rpp::ops::take_while([](auto) { return true; }), { diff --git a/src/tests/rpp/test_tap.cpp b/src/tests/rpp/test_tap.cpp index a5d66553d..1da6d2535 100644 --- a/src/tests/rpp/test_tap.cpp +++ b/src/tests/rpp/test_tap.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -20,17 +19,17 @@ #include "copy_count_tracker.hpp" #include "disposable_observable.hpp" -TEMPLATE_TEST_CASE("tap observes emissions and doesn't modify them", "", rpp::memory_model::use_stack, rpp::memory_model::use_shared) +TEST_CASE_TEMPLATE("tap observes emissions and doesn't modify them", TestType, rpp::memory_model::use_stack, rpp::memory_model::use_shared) { auto mock = mock_observer_strategy{}; - SECTION("observable with error emission") + SUBCASE("observable with error emission") { auto obs = rpp::source::concat(rpp::source::just(1, 2, 3), rpp::source::error(std::make_exception_ptr(std::runtime_error{""}))); - SECTION("subscribe") + SUBCASE("subscribe") { size_t on_next_invoked = 0; size_t on_error_invoked = 0; @@ -51,11 +50,11 @@ TEMPLATE_TEST_CASE("tap observes emissions and doesn't modify them", "", rpp::me } } - SECTION("observable with completed emission") + SUBCASE("observable with completed emission") { auto obs = rpp::source::just(1, 2, 3); - SECTION("subscribe") + SUBCASE("subscribe") { size_t on_next_invoked = 0; size_t on_completed_invoked = 0; @@ -75,7 +74,7 @@ TEMPLATE_TEST_CASE("tap observes emissions and doesn't modify them", "", rpp::me CHECK(on_completed_invoked == mock.get_on_completed_count()); } - SECTION("pass on_next callback with auto argument") + SUBCASE("pass on_next callback with auto argument") { size_t on_next_invoked = 0; diff --git a/src/tests/rpp/test_throttle.cpp b/src/tests/rpp/test_throttle.cpp index d441f2e4c..a87f06105 100644 --- a/src/tests/rpp/test_throttle.cpp +++ b/src/tests/rpp/test_throttle.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -25,14 +24,14 @@ TEST_CASE("throttle throttles emissions") auto subj = rpp::subjects::publish_subject{}; const auto throttle_duration = std::chrono::seconds{2}; subj.get_observable() | rpp::ops::throttle(throttle_duration) | rpp::ops::map([](int v) { return std::tuple{v, rpp::schedulers::test_scheduler::now()}; }) | rpp::ops::subscribe(mock); - SECTION("emiting second value forwards it immediately") + SUBCASE("emiting second value forwards it immediately") { const auto first_value_time = rpp::schedulers::test_scheduler::now(); subj.get_observer().on_next(1); CHECK(mock.get_received_values() == std::vector{std::tuple{1, first_value_time}}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); - SECTION("emitting second value in throttle_duration/2 not forwards it") + SUBCASE("emitting second value in throttle_duration/2 not forwards it") { rpp::schedulers::test_scheduler{}.time_advance(throttle_duration / 2); @@ -40,7 +39,7 @@ TEST_CASE("throttle throttles emissions") CHECK(mock.get_received_values() == std::vector{std::tuple{1, first_value_time}}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); - SECTION("emitting third value in throttle_duration/2+throttle_duration/2 forwards it") + SUBCASE("emitting third value in throttle_duration/2+throttle_duration/2 forwards it") { rpp::schedulers::test_scheduler{}.time_advance(throttle_duration / 2); @@ -50,21 +49,21 @@ TEST_CASE("throttle throttles emissions") CHECK(mock.get_on_completed_count() == 0); } } - SECTION("emitting error forwards it immediately") + SUBCASE("emitting error forwards it immediately") { subj.get_observer().on_error({}); CHECK(mock.get_received_values() == std::vector{std::tuple{1, first_value_time}}); CHECK(mock.get_on_error_count() == 1); CHECK(mock.get_on_completed_count() == 0); } - SECTION("emitting completed forwards it immediately") + SUBCASE("emitting completed forwards it immediately") { subj.get_observer().on_completed(); CHECK(mock.get_received_values() == std::vector{std::tuple{1, first_value_time}}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } - SECTION("emitting second value in throttle_duration forwards it") + SUBCASE("emitting second value in throttle_duration forwards it") { rpp::schedulers::test_scheduler{}.time_advance(throttle_duration); @@ -73,7 +72,7 @@ TEST_CASE("throttle throttles emissions") CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("emitting second value in 3/2*throttle_duration forwards it") + SUBCASE("emitting second value in 3/2*throttle_duration forwards it") { rpp::schedulers::test_scheduler{}.time_advance(throttle_duration / 2 * 3); diff --git a/src/tests/rpp/test_timeout.cpp b/src/tests/rpp/test_timeout.cpp index b356d1c43..67220298c 100644 --- a/src/tests/rpp/test_timeout.cpp +++ b/src/tests/rpp/test_timeout.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -29,7 +28,7 @@ TEST_CASE("timeout subscribes to passed observable in case of reaching timeout") auto mock = mock_observer_strategy{}; const auto now = scheduler.now(); - SECTION("timeout not reached") + SUBCASE("timeout not reached") { rpp::source::just(scheduler, 1, 2, 3) | rpp::ops::timeout(std::chrono::seconds{1}, rpp::source::just(100), scheduler) @@ -46,7 +45,7 @@ TEST_CASE("timeout subscribes to passed observable in case of reaching timeout") CHECK(mock.get_on_completed_count() == 1); } - SECTION("timeout reached") + SUBCASE("timeout reached") { rpp::source::just(scheduler, 1) | rpp::ops::delay(std::chrono::seconds{5}, scheduler) @@ -65,7 +64,7 @@ TEST_CASE("timeout subscribes to passed observable in case of reaching timeout") CHECK(mock.get_on_completed_count() == 1); } - SECTION("timeout with never") + SUBCASE("timeout with never") { rpp::source::never() | rpp::ops::timeout(std::chrono::seconds{1}, rpp::source::just(100), scheduler) @@ -80,7 +79,7 @@ TEST_CASE("timeout subscribes to passed observable in case of reaching timeout") CHECK(mock.get_on_completed_count() == 1); } - SECTION("timeout with empty") + SUBCASE("timeout with empty") { rpp::source::empty() | rpp::ops::timeout(std::chrono::seconds{1}, rpp::source::just(100), scheduler) @@ -95,7 +94,7 @@ TEST_CASE("timeout subscribes to passed observable in case of reaching timeout") CHECK(mock.get_on_completed_count() == 1); } - SECTION("timeout with error") + SUBCASE("timeout with error") { rpp::source::error({}) | rpp::ops::timeout(std::chrono::seconds{1}, rpp::source::just(100), scheduler) @@ -110,7 +109,7 @@ TEST_CASE("timeout subscribes to passed observable in case of reaching timeout") CHECK(mock.get_on_completed_count() == 0); } - SECTION("timeout with default args") + SUBCASE("timeout with default args") { rpp::source::never() | rpp::ops::timeout(std::chrono::seconds{1}, scheduler) @@ -125,7 +124,7 @@ TEST_CASE("timeout subscribes to passed observable in case of reaching timeout") CHECK(mock.get_on_completed_count() == 0); } - SECTION("never timeout with never") + SUBCASE("never timeout with never") { rpp::source::never() | rpp::ops::timeout(std::chrono::seconds{1}, rpp::source::never(), scheduler) diff --git a/src/tests/rpp/test_timer.cpp b/src/tests/rpp/test_timer.cpp index 13e078ecc..a7200c1b5 100644 --- a/src/tests/rpp/test_timer.cpp +++ b/src/tests/rpp/test_timer.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -24,19 +23,19 @@ TEST_CASE("timer emit single value at provided duration") auto mock = mock_observer_strategy{}; auto mock2 = mock_observer_strategy{}; - SECTION("timer observable") + SUBCASE("timer observable") { auto when = std::chrono::seconds{1}; auto time_point = scheduler2.now() + when; auto obs = rpp::source::timer(when, scheduler); auto obs2 = rpp::source::timer(time_point, scheduler2); - SECTION("subscribe") + SUBCASE("subscribe") { obs | rpp::ops::subscribe(mock); obs2 | rpp::ops::subscribe(mock2); - SECTION("nothing happens immediately till scheduler advanced") + SUBCASE("nothing happens immediately till scheduler advanced") { auto validate = [&](const auto& mock, const auto& scheduler) { CHECK(mock.get_received_values() == std::vector{}); @@ -50,12 +49,12 @@ TEST_CASE("timer emit single value at provided duration") validate(mock2, scheduler2); } - SECTION("advance time") + SUBCASE("advance time") { scheduler.time_advance(when); scheduler2.time_advance(when); - SECTION("observer obtains value") + SUBCASE("observer obtains value") { auto validate = [&](const auto& mock) { CHECK(mock.get_received_values() == std::vector{0}); @@ -66,7 +65,7 @@ TEST_CASE("timer emit single value at provided duration") validate(mock2); } - SECTION("timer schedules schedulable with provided interval") + SUBCASE("timer schedules schedulable with provided interval") { CHECK(scheduler.get_executions().size() == 1); CHECK(scheduler2.get_executions().size() == 1); @@ -81,18 +80,18 @@ TEST_CASE("timer emit single value at provided time_point") auto scheduler = rpp::schedulers::test_scheduler{}; auto mock = mock_observer_strategy{}; - SECTION("timer observable") + SUBCASE("timer observable") { auto when = std::chrono::seconds{1}; auto time_point = scheduler.now() + when; auto obs = rpp::source::timer(time_point, scheduler); - SECTION("subscribe") + SUBCASE("subscribe") { scheduler.time_advance(when * 2); obs | rpp::ops::subscribe(mock); - SECTION("expect value as time_point is in the past") + SUBCASE("expect value as time_point is in the past") { CHECK(mock.get_received_values() == std::vector{0}); CHECK(mock.get_on_error_count() == 0); diff --git a/src/tests/rpp/test_window.cpp b/src/tests/rpp/test_window.cpp index de5130b85..a5a36b7d1 100644 --- a/src/tests/rpp/test_window.cpp +++ b/src/tests/rpp/test_window.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -21,12 +20,12 @@ TEST_CASE("window subdivide observable into sub-observables") { - SECTION("observable of 3 items with window(2)") + SUBCASE("observable of 3 items with window(2)") { auto obs = rpp::source::just(1, 2, 3) | rpp::ops::window(2); - SECTION("subscribe on it") + SUBCASE("subscribe on it") { - SECTION("see 2 observables") + SUBCASE("see 2 observables") { auto mock = mock_observer_strategy>{}; obs.subscribe(mock); @@ -35,7 +34,7 @@ TEST_CASE("window subdivide observable into sub-observables") CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } - SECTION("first window observable emits first 2 values and completes") + SUBCASE("first window observable emits first 2 values and completes") { auto mock = mock_observer_strategy{}; size_t i = 0; @@ -48,7 +47,7 @@ TEST_CASE("window subdivide observable into sub-observables") CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } - SECTION("second window observable emits last 1 value and completes") + SUBCASE("second window observable emits last 1 value and completes") { auto mock = mock_observer_strategy{}; size_t i = 0; @@ -64,14 +63,14 @@ TEST_CASE("window subdivide observable into sub-observables") } } - SECTION("subject of values") + SUBCASE("subject of values") { auto subj = rpp::subjects::publish_subject{}; - SECTION("subscribe on it via window(2)") + SUBCASE("subscribe on it via window(2)") { auto obs = subj.get_observable() | rpp::ops::window(2); - SECTION("emit first item") + SUBCASE("emit first item") { auto mock = mock_observer_strategy>{}; obs.subscribe(mock); @@ -82,27 +81,27 @@ TEST_CASE("window subdivide observable into sub-observables") subj.get_observer().on_next(1); - SECTION("see new window observable") + SUBCASE("see new window observable") { CHECK(mock.get_total_on_next_count() == 1); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("emit second item") + SUBCASE("emit second item") { subj.get_observer().on_next(2); - SECTION("no any new window observable") + SUBCASE("no any new window observable") { CHECK(mock.get_total_on_next_count() == 1); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("emit third item") + SUBCASE("emit third item") { subj.get_observer().on_next(3); - SECTION("new window observable") + SUBCASE("new window observable") { CHECK(mock.get_total_on_next_count() == 2); CHECK(mock.get_on_error_count() == 0); @@ -111,10 +110,10 @@ TEST_CASE("window subdivide observable into sub-observables") } } - SECTION("emit on_error") + SUBCASE("emit on_error") { subj.get_observer().on_error(std::make_exception_ptr(std::runtime_error{""})); - SECTION("subscriber see error") + SUBCASE("subscriber see error") { CHECK(mock.get_total_on_next_count() == 1); CHECK(mock.get_on_error_count() == 1); @@ -123,25 +122,25 @@ TEST_CASE("window subdivide observable into sub-observables") } } - SECTION("emit first item") + SUBCASE("emit first item") { auto mock = mock_observer_strategy{}; obs.subscribe([&](const auto& observable) { observable.subscribe(mock); }, [](const std::exception_ptr&) {}); subj.get_observer().on_next(1); - SECTION("inner subscriber see first value without complete") + SUBCASE("inner subscriber see first value without complete") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("emit on_completed") + SUBCASE("emit on_completed") { subj.get_observer().on_completed(); - SECTION("inner subscriber see completed") + SUBCASE("inner subscriber see completed") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_error_count() == 0); @@ -149,11 +148,11 @@ TEST_CASE("window subdivide observable into sub-observables") } } - SECTION("emit on_error") + SUBCASE("emit on_error") { subj.get_observer().on_error(std::make_exception_ptr(std::runtime_error{""})); - SECTION("inner subscriber see error") + SUBCASE("inner subscriber see error") { CHECK(mock.get_received_values() == std::vector{1}); CHECK(mock.get_on_error_count() == 1); @@ -161,11 +160,11 @@ TEST_CASE("window subdivide observable into sub-observables") } } - SECTION("emit second item") + SUBCASE("emit second item") { subj.get_observer().on_next(2); - SECTION("inner subscriber see second value and completes") + SUBCASE("inner subscriber see second value and completes") { CHECK(mock.get_received_values() == std::vector{1, 2}); CHECK(mock.get_on_error_count() == 0); diff --git a/src/tests/rpp/test_window_toggle.cpp b/src/tests/rpp/test_window_toggle.cpp index a0a73b385..664399c69 100644 --- a/src/tests/rpp/test_window_toggle.cpp +++ b/src/tests/rpp/test_window_toggle.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -35,7 +34,7 @@ TEST_CASE("window_toggle") [&mock]() { mock.on_completed(); }); }; - SECTION("opening - just(1), closing - never()") + SUBCASE("opening - just(1), closing - never()") { subscribe_mocks(rpp::source::just(1, 2, 3) | rpp::ops::window_toggle(rpp::source::just(1), [](int) { return rpp::source::never(); })); @@ -50,7 +49,7 @@ TEST_CASE("window_toggle") CHECK(inner.get_on_completed_count() == 1); } } - SECTION("opening - just(1), closing - empty()") + SUBCASE("opening - just(1), closing - empty()") { subscribe_mocks(rpp::source::just(1, 2, 3) | rpp::ops::window_toggle(rpp::source::just(1), [](int) { return rpp::source::empty(); })); @@ -65,7 +64,7 @@ TEST_CASE("window_toggle") CHECK(inner.get_on_completed_count() == 1); } } - SECTION("opening - just(1,2,3), closing - empty()") + SUBCASE("opening - just(1,2,3), closing - empty()") { subscribe_mocks(rpp::source::just(1, 2, 3) | rpp::ops::window_toggle(rpp::source::just(1, 2, 3), [](int) { return rpp::source::empty(); })); @@ -80,7 +79,7 @@ TEST_CASE("window_toggle") CHECK(inner.get_on_completed_count() == 1); } } - SECTION("opening - just(1,2,3), closing - never()") + SUBCASE("opening - just(1,2,3), closing - never()") { subscribe_mocks(rpp::source::just(1, 2, 3) | rpp::ops::window_toggle(rpp::source::just(1, 2, 3), [](int) { return rpp::source::never(); })); @@ -97,7 +96,7 @@ TEST_CASE("window_toggle") CHECK(inner_mocks[1].get_received_values() == std::vector{2, 3}); CHECK(inner_mocks[2].get_received_values() == std::vector{3}); } - SECTION("opening - just(1,2,3), closing - just(1)") + SUBCASE("opening - just(1,2,3), closing - just(1)") { subscribe_mocks(rpp::source::just(1, 2, 3) | rpp::ops::window_toggle(rpp::source::just(1, 2, 3), [](int) { return rpp::source::just(1); })); @@ -114,7 +113,7 @@ TEST_CASE("window_toggle") CHECK(inner_mocks[1].get_received_values() == std::vector{2}); CHECK(inner_mocks[2].get_received_values() == std::vector{3}); } - SECTION("opening - never(), closing - just(1)") + SUBCASE("opening - never(), closing - just(1)") { subscribe_mocks(rpp::source::never() | rpp::ops::window_toggle(rpp::source::just(1, 2, 3), [](int) { return rpp::source::just(1); })); @@ -128,7 +127,7 @@ TEST_CASE("window_toggle") CHECK(inner.get_on_completed_count() == 1); } } - SECTION("opening - empty(), closing - just(1)") + SUBCASE("opening - empty(), closing - just(1)") { subscribe_mocks(rpp::source::empty() | rpp::ops::window_toggle(rpp::source::just(1, 2, 3), [](int) { return rpp::source::just(1); })); @@ -137,7 +136,7 @@ TEST_CASE("window_toggle") CHECK(mock.get_on_completed_count() == 1); REQUIRE(inner_mocks.size() == 0); } - SECTION("source - error") + SUBCASE("source - error") { subscribe_mocks(rpp::source::error({}) | rpp::ops::window_toggle(rpp::source::just(rpp::schedulers::immediate{}, 1), [](int) { return rpp::source::never(); })); @@ -145,7 +144,7 @@ TEST_CASE("window_toggle") CHECK(mock.get_on_error_count() == 1); CHECK(mock.get_on_completed_count() == 0); } - SECTION("openings - error") + SUBCASE("openings - error") { subscribe_mocks(rpp::source::never() | rpp::ops::window_toggle(rpp::source::error({}), [](int) { return rpp::source::never(); })); @@ -153,7 +152,7 @@ TEST_CASE("window_toggle") CHECK(mock.get_on_error_count() == 1); CHECK(mock.get_on_completed_count() == 0); } - SECTION("openings - just(1), closings - error") + SUBCASE("openings - just(1), closings - error") { subscribe_mocks(rpp::source::never() | rpp::ops::window_toggle(rpp::source::just(1), [](int) { return rpp::source::error({}); })); @@ -167,7 +166,7 @@ TEST_CASE("window_toggle") CHECK(inner.get_on_completed_count() == 0); } } - SECTION("openings - just(1), closings - throw") + SUBCASE("openings - just(1), closings - throw") { subscribe_mocks(rpp::source::never() | rpp::ops::window_toggle(rpp::source::just(1), [](int) { throw std::runtime_error{""}; return rpp::source::error({}); })); diff --git a/src/tests/rpp/test_with_latest_from.cpp b/src/tests/rpp/test_with_latest_from.cpp index b6bbddbdc..828f68a55 100644 --- a/src/tests/rpp/test_with_latest_from.cpp +++ b/src/tests/rpp/test_with_latest_from.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -23,22 +22,22 @@ TEST_CASE("with_latest_from combines observables") { auto obs_1 = rpp::source::just(1); auto obs_2 = rpp::source::just(2.2); - SECTION("subscribe on it via with_latest_from") + SUBCASE("subscribe on it via with_latest_from") { auto mock = mock_observer_strategy>{}; obs_1 | rpp::ops::with_latest_from(obs_2) | rpp::ops::subscribe(mock); - SECTION("obtain tuple of values") + SUBCASE("obtain tuple of values") { CHECK(mock.get_received_values() == std::vector{std::tuple{1, 2.2}}); CHECK(mock.get_total_on_next_count() == 1); CHECK(mock.get_on_completed_count() == 1); } } - SECTION("subscribe on it via with_latest_from with custom selector") + SUBCASE("subscribe on it via with_latest_from with custom selector") { auto mock = mock_observer_strategy{}; obs_1 | rpp::ops::with_latest_from([](int left, double right) { return left + right; }, obs_2) | rpp::ops::subscribe(mock); - SECTION("obtain values") + SUBCASE("obtain values") { CHECK(mock.get_received_values() == std::vector{1 + 2.2}); CHECK(mock.get_total_on_next_count() == 1); @@ -49,49 +48,49 @@ TEST_CASE("with_latest_from combines observables") TEST_CASE("with_latest_from reacts only on main root but sends last value from others") { - SECTION("subjects and subscribe on it with_latest_from") + SUBCASE("subjects and subscribe on it with_latest_from") { auto subj_1 = rpp::subjects::publish_subject{}; auto subj_2 = rpp::subjects::publish_subject{}; auto mock = mock_observer_strategy>{}; subj_1.get_observable() | rpp::ops::with_latest_from(subj_2.get_observable()) | rpp::ops::subscribe(mock); - SECTION("send only first subject sends value") + SUBCASE("send only first subject sends value") { subj_1.get_observer().on_next(1); - SECTION("No values to observer") + SUBCASE("No values to observer") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } } - SECTION("send only second subject sends value") + SUBCASE("send only second subject sends value") { subj_2.get_observer().on_next(1); - SECTION("No values to observer") + SUBCASE("No values to observer") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } } - SECTION("send first subject sends value SECTION combine called with last second value") + SUBCASE("send first subject sends value SUBCASE combine called with last second value") { subj_2.get_observer().on_next(1); subj_2.get_observer().on_next(2); subj_2.get_observer().on_next(3); subj_1.get_observer().on_next(4); - SECTION("obtain last combintaion") + SUBCASE("obtain last combintaion") { CHECK(mock.get_received_values() == std::vector{std::tuple{4, 3}}); CHECK(mock.get_total_on_next_count() == 1); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } - SECTION("second sends values again") + SUBCASE("second sends values again") { subj_2.get_observer().on_next(5); - SECTION("nothing new happens") + SUBCASE("nothing new happens") { CHECK(mock.get_received_values() == std::vector{std::tuple{4, 3}}); CHECK(mock.get_total_on_next_count() == 1); @@ -100,40 +99,40 @@ TEST_CASE("with_latest_from reacts only on main root but sends last value from o } } } - SECTION("second completes") + SUBCASE("second completes") { subj_2.get_observer().on_completed(); - SECTION("nothing happens") + SUBCASE("nothing happens") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 0); } } - SECTION("second errors") + SUBCASE("second errors") { subj_2.get_observer().on_error({}); - SECTION("error obtained") + SUBCASE("error obtained") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); CHECK(mock.get_on_completed_count() == 0); } } - SECTION("first completes") + SUBCASE("first completes") { subj_1.get_observer().on_completed(); - SECTION("observer completed") + SUBCASE("observer completed") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 0); CHECK(mock.get_on_completed_count() == 1); } } - SECTION("first errors") + SUBCASE("first errors") { subj_1.get_observer().on_error({}); - SECTION("error obtained") + SUBCASE("error obtained") { CHECK(mock.get_total_on_next_count() == 0); CHECK(mock.get_on_error_count() == 1); @@ -145,14 +144,14 @@ TEST_CASE("with_latest_from reacts only on main root but sends last value from o TEST_CASE("with_latest_from handles race condition") { - SECTION("source observable in current thread pairs with error in other thread") + SUBCASE("source observable in current thread pairs with error in other thread") { std::atomic_bool on_error_called{false}; auto subject = rpp::subjects::publish_subject{}; - SECTION("subscribe on it") + SUBCASE("subscribe on it") { - SECTION("on_error can't interleave with on_next") + SUBCASE("on_error can't interleave with on_next") { std::thread th{}; auto source = rpp::subjects::publish_subject{}; diff --git a/src/tests/rpp/test_zip.cpp b/src/tests/rpp/test_zip.cpp index aaec6a20b..269f324d0 100644 --- a/src/tests/rpp/test_zip.cpp +++ b/src/tests/rpp/test_zip.cpp @@ -8,8 +8,7 @@ // Project home: https://github.com/victimsnino/ReactivePlusPlus // -#include -#include +#include #include #include @@ -27,7 +26,7 @@ TEST_CASE("zip zips items") { - SECTION("observable of -1-2-3-| zip with -4-5-6-| on immediate scheduler") + SUBCASE("observable of -1-2-3-| zip with -4-5-6-| on immediate scheduler") { auto mock = mock_observer_strategy>{}; rpp::source::just(rpp::schedulers::immediate{}, 1, 2, 3) @@ -43,7 +42,7 @@ TEST_CASE("zip zips items") CHECK(mock.get_on_error_count() == 0); } - SECTION("observable of -1-2-3-| zip with -4-5-6-| on current_thread") + SUBCASE("observable of -1-2-3-| zip with -4-5-6-| on current_thread") { auto mock = mock_observer_strategy>{}; @@ -64,7 +63,7 @@ TEST_CASE("zip zips items") CHECK(mock.get_on_error_count() == 0); } - SECTION("observable of -1-2-3-| zip with two other sources on current_thread") + SUBCASE("observable of -1-2-3-| zip with two other sources on current_thread") { auto mock = mock_observer_strategy>{}; @@ -91,7 +90,7 @@ TEST_CASE("zip zips items") TEST_CASE("zip waits for all emissions") { - SECTION("observable of -1-2-3-| and never") + SUBCASE("observable of -1-2-3-| and never") { auto mock = mock_observer_strategy>{}; rpp::source::just(1, 2, 3) @@ -106,7 +105,7 @@ TEST_CASE("zip waits for all emissions") TEST_CASE("zip forwards errors") { - SECTION("observable of -1-2-3-| combines with error") + SUBCASE("observable of -1-2-3-| combines with error") { auto mock = mock_observer_strategy>{}; rpp::source::just(1, 2, 3) @@ -121,14 +120,14 @@ TEST_CASE("zip forwards errors") TEST_CASE("zip handles race conditions") { - SECTION("source observable in current thread pairs with error in other thread") + SUBCASE("source observable in current thread pairs with error in other thread") { std::atomic_bool on_error_called{false}; auto subject = rpp::subjects::publish_subject{}; - SECTION("subscribe on it") + SUBCASE("subscribe on it") { - SECTION("on_error can't interleave with on_next") + SUBCASE("on_error can't interleave with on_next") { rpp::source::just(1, 1, 1) | rpp::ops::zip(rpp::source::concat(rpp::source::just(2), subject.get_observable())) @@ -151,7 +150,7 @@ TEST_CASE("zip handles race conditions") TEST_CASE("zip doesn't produce extra copies") { - SECTION("send value by copy") + SUBCASE("send value by copy") { copy_count_tracker verifier{}; auto obs = verifier.get_observable() @@ -163,7 +162,7 @@ TEST_CASE("zip doesn't produce extra copies") REQUIRE(verifier.get_move_count() == 2); // 1 move to selector + 1 move to final subscriber } - SECTION("send value by move") + SUBCASE("send value by move") { copy_count_tracker verifier{}; auto obs = verifier.get_observable_for_move() diff --git a/src/tests/rppasio/test_rppasio_scheduler.cpp b/src/tests/rppasio/test_rppasio_scheduler.cpp index 87df9aa6a..f2d36a143 100644 --- a/src/tests/rppasio/test_rppasio_scheduler.cpp +++ b/src/tests/rppasio/test_rppasio_scheduler.cpp @@ -7,7 +7,7 @@ // // Project home: https://github.com/victimsnino/ReactivePlusPlus -#include +#include #include #include diff --git a/src/tests/rppgrpc/test_async_client.cpp b/src/tests/rppgrpc/test_async_client.cpp index fd79b64a4..e73f7d3cb 100644 --- a/src/tests/rppgrpc/test_async_client.cpp +++ b/src/tests/rppgrpc/test_async_client.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -42,7 +42,7 @@ TEST_CASE("async client reactor") rpp::subjects::publish_subject subj{}; mock_observer out_mock{}; - SECTION("bidirectional") + SUBCASE("bidirectional") { grpc::ClientContext ctx{}; @@ -51,7 +51,7 @@ TEST_CASE("async client reactor") subj.get_observable() | rpp::ops::map([](int v) { Request request{}; request.set_value(v); return request; }) | rpp::ops::subscribe(bidi_reactor->get_observer()); stub->async()->Bidirectional(&ctx, bidi_reactor); - SECTION("no stream job - completion") + SUBCASE("no stream job - completion") { REQUIRE_CALL(*mock_service, Bidirectional(trompeloeil::_, trompeloeil::_)).RETURN(grpc::Status::OK).IN_SEQUENCE(s); const auto last = NAMED_REQUIRE_CALL(*out_mock, on_completed()).IN_SEQUENCE(s); @@ -60,7 +60,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("error status - error") + SUBCASE("error status - error") { REQUIRE_CALL(*mock_service, Bidirectional(trompeloeil::_, trompeloeil::_)).RETURN(grpc::Status::CANCELLED).IN_SEQUENCE(s); const auto last = NAMED_REQUIRE_CALL(*out_mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); @@ -69,7 +69,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("manual server-side cancel") + SUBCASE("manual server-side cancel") { REQUIRE_CALL(*mock_service, Bidirectional(trompeloeil::_, trompeloeil::_)) .RETURN(grpc::Status::OK) @@ -85,7 +85,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("manual client-side completion") + SUBCASE("manual client-side completion") { REQUIRE_CALL(*mock_service, Bidirectional(trompeloeil::_, trompeloeil::_)) .RETURN(grpc::Status::OK) @@ -105,7 +105,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("client-side write + completion") + SUBCASE("client-side write + completion") { std::promise> results{}; REQUIRE_CALL(*mock_service, Bidirectional(trompeloeil::_, trompeloeil::_)) @@ -136,7 +136,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("client-side read + completion") + SUBCASE("client-side read + completion") { REQUIRE_CALL(*mock_service, Bidirectional(trompeloeil::_, trompeloeil::_)) .RETURN(grpc::Status::OK) @@ -160,7 +160,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("client-side read-write + completeion") + SUBCASE("client-side read-write + completeion") { REQUIRE_CALL(*mock_service, Bidirectional(trompeloeil::_, trompeloeil::_)) .RETURN(grpc::Status::OK) @@ -189,14 +189,14 @@ TEST_CASE("async client reactor") wait(last); } } - SECTION("server-side") + SUBCASE("server-side") { grpc::ClientContext ctx{}; const auto read_reactor = new rppgrpc::client_read_reactor(); read_reactor->get_observable() | rpp::ops::map([](const Response& out) { return out.value(); }) | rpp::ops::observe_on(rpp::schedulers::new_thread{}) | rpp::ops::subscribe(out_mock); - SECTION("empty request") + SUBCASE("empty request") { stub->async()->ServerSide(&ctx, nullptr, read_reactor); @@ -205,12 +205,12 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("normal request") + SUBCASE("normal request") { Request r{}; stub->async()->ServerSide(&ctx, &r, read_reactor); - SECTION("no stream job - completion") + SUBCASE("no stream job - completion") { REQUIRE_CALL(*mock_service, ServerSide(trompeloeil::_, trompeloeil::_, trompeloeil::_)).RETURN(grpc::Status::OK).IN_SEQUENCE(s); const auto last = NAMED_REQUIRE_CALL(*out_mock, on_completed()).IN_SEQUENCE(s); @@ -219,7 +219,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("error status - error") + SUBCASE("error status - error") { REQUIRE_CALL(*mock_service, ServerSide(trompeloeil::_, trompeloeil::_, trompeloeil::_)).RETURN(grpc::Status::CANCELLED).IN_SEQUENCE(s); const auto last = NAMED_REQUIRE_CALL(*out_mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); @@ -228,7 +228,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("manual server-side cancel") + SUBCASE("manual server-side cancel") { REQUIRE_CALL(*mock_service, ServerSide(trompeloeil::_, trompeloeil::_, trompeloeil::_)) .RETURN(grpc::Status::OK) @@ -244,7 +244,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("client-side read + completion") + SUBCASE("client-side read + completion") { REQUIRE_CALL(*mock_service, ServerSide(trompeloeil::_, trompeloeil::_, trompeloeil::_)) .RETURN(grpc::Status::OK) @@ -269,7 +269,7 @@ TEST_CASE("async client reactor") } } } - SECTION("client-side") + SUBCASE("client-side") { grpc::ClientContext ctx{}; @@ -279,7 +279,7 @@ TEST_CASE("async client reactor") Response r{}; stub->async()->ClientSide(&ctx, &r, write_reactor); - SECTION("no stream job - completion") + SUBCASE("no stream job - completion") { REQUIRE_CALL(*mock_service, ClientSide(trompeloeil::_, trompeloeil::_, trompeloeil::_)).RETURN(grpc::Status::OK).IN_SEQUENCE(s); const auto last = NAMED_REQUIRE_CALL(*out_mock, on_completed()).IN_SEQUENCE(s); @@ -288,7 +288,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("error status - error") + SUBCASE("error status - error") { REQUIRE_CALL(*mock_service, ClientSide(trompeloeil::_, trompeloeil::_, trompeloeil::_)).RETURN(grpc::Status::CANCELLED).IN_SEQUENCE(s); const auto last = NAMED_REQUIRE_CALL(*out_mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); @@ -297,7 +297,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("manual server-side cancel") + SUBCASE("manual server-side cancel") { REQUIRE_CALL(*mock_service, ClientSide(trompeloeil::_, trompeloeil::_, trompeloeil::_)) .RETURN(grpc::Status::OK) @@ -313,7 +313,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("manual client-side completion") + SUBCASE("manual client-side completion") { REQUIRE_CALL(*mock_service, ClientSide(trompeloeil::_, trompeloeil::_, trompeloeil::_)) .RETURN(grpc::Status::OK) @@ -333,7 +333,7 @@ TEST_CASE("async client reactor") wait(last); } - SECTION("client-side write + completion") + SUBCASE("client-side write + completion") { std::promise> results{}; REQUIRE_CALL(*mock_service, ClientSide(trompeloeil::_, trompeloeil::_, trompeloeil::_)) diff --git a/src/tests/rppgrpc/test_async_server.cpp b/src/tests/rppgrpc/test_async_server.cpp index 9bfc97668..71b254287 100644 --- a/src/tests/rppgrpc/test_async_server.cpp +++ b/src/tests/rppgrpc/test_async_server.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -46,7 +46,7 @@ TEST_CASE("Async server") grpc::CallbackServerContext* obtained_context{}; auto test_common = [&](const auto& writer, const auto* reactor) { - SECTION("writer immediate finish") + SUBCASE("writer immediate finish") { const auto last = NAMED_REQUIRE_CALL(*out_mock, on_completed()).IN_SEQUENCE(s); if constexpr (requires { writer->WritesDone(); }) @@ -60,14 +60,14 @@ TEST_CASE("Async server") wait(last); } - SECTION("writer cancels") + SUBCASE("writer cancels") { const auto last = NAMED_REQUIRE_CALL(*out_mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); ctx.TryCancel(); wait(last); } - SECTION("server cancels") + SUBCASE("server cancels") { const auto last = NAMED_REQUIRE_CALL(*out_mock, on_error(trompeloeil::_)).IN_SEQUENCE(s); obtained_context->TryCancel(); @@ -76,7 +76,7 @@ TEST_CASE("Async server") }; auto test_read = [&](const auto& writer, const auto* reactor) { - SECTION("writer writes") + SUBCASE("writer writes") { REQUIRE_CALL(*out_mock, on_next_rvalue(1)).IN_SEQUENCE(s); REQUIRE_CALL(*out_mock, on_next_rvalue(2)).IN_SEQUENCE(s); @@ -101,7 +101,7 @@ TEST_CASE("Async server") }; auto test_write = [&](const auto& writer, const auto* reactor) { - SECTION("writer reads") + SUBCASE("writer reads") { const auto last = NAMED_REQUIRE_CALL(*out_mock, on_completed()).IN_SEQUENCE(s); Response response{}; @@ -127,7 +127,7 @@ TEST_CASE("Async server") } }; - SECTION("bidirectionl") + SUBCASE("bidirectionl") { const auto reactor = new rppgrpc::server_bidi_reactor(); reactor->get_observable() | rpp::ops::map([](const Request& out) { return out.value(); }) | rpp::ops::subscribe(out_mock); @@ -143,7 +143,7 @@ TEST_CASE("Async server") test_write(writer, reactor); } - SECTION("server-side") + SUBCASE("server-side") { const auto reactor = new rppgrpc::server_write_reactor(); reactor->get_observable() | rpp::ops::map([](const rpp::utils::none&) { return 0; }) | rpp::ops::subscribe(out_mock); @@ -158,7 +158,7 @@ TEST_CASE("Async server") test_write(writer, reactor); } - SECTION("client-side") + SUBCASE("client-side") { const auto reactor = new rppgrpc::server_read_reactor(); reactor->get_observable() | rpp::ops::map([](const Request& out) { return out.value(); }) | rpp::ops::subscribe(out_mock); diff --git a/src/tests/rppqt/test_from_signal.cpp b/src/tests/rppqt/test_from_signal.cpp index 5894e2038..5b01b13b8 100644 --- a/src/tests/rppqt/test_from_signal.cpp +++ b/src/tests/rppqt/test_from_signal.cpp @@ -38,8 +38,7 @@ struct test_q_object : public QObject void no_value_signal(); }; -#include -#include +#include #include @@ -50,26 +49,26 @@ struct test_q_object : public QObject TEST_CASE("from_signal can see object value from object signal") { - SECTION("qobject with signal with 1 argument and observable from signal from this object") + SUBCASE("qobject with signal with 1 argument and observable from signal from this object") { mock_observer_strategy mock_observer{}; auto testobject = std::make_unique(); auto obs = rppqt::source::from_signal(*testobject, &test_q_object::single_value_signal); - SECTION("emit signal, subscribe on it and emit signal") + SUBCASE("emit signal, subscribe on it and emit signal") { testobject->emit_single_value_signal(1); obs.subscribe(mock_observer); testobject->emit_single_value_signal(2); - SECTION("subscriber sees only emission after subscribe") + SUBCASE("subscriber sees only emission after subscribe") { CHECK(mock_observer.get_received_values() == std::vector{2}); CHECK(mock_observer.get_on_error_count() == 0); CHECK(mock_observer.get_on_completed_count() == 0); } - SECTION("object destroyed") + SUBCASE("object destroyed") { testobject.reset(); - SECTION("subscriber sees completion") + SUBCASE("subscriber sees completion") { CHECK(mock_observer.get_received_values() == std::vector{2}); CHECK(mock_observer.get_on_error_count() == 0); @@ -77,14 +76,14 @@ TEST_CASE("from_signal can see object value from object signal") } } } - SECTION("object destroyed before subscription") + SUBCASE("object destroyed before subscription") { testobject.reset(); - SECTION("section subscriber subscribed") + SUBCASE("SUBCASE subscriber subscribed") { obs.subscribe(mock_observer); - SECTION("subscriber sees only completion") + SUBCASE("subscriber sees only completion") { CHECK(mock_observer.get_received_values() == std::vector{}); CHECK(mock_observer.get_on_error_count() == 0); @@ -97,16 +96,16 @@ TEST_CASE("from_signal can see object value from object signal") TEST_CASE("from_signal sends tuple if multiple values") { - SECTION("object with signal with multiple values and observable from this signal") + SUBCASE("object with signal with multiple values and observable from this signal") { mock_observer_strategy> mock_observer{}; auto testobject = std::make_unique(); auto obs = rppqt::source::from_signal(*testobject, &test_q_object::multiple_value_signal); - SECTION("subscribe on it and emit signal") + SUBCASE("subscribe on it and emit signal") { obs.subscribe(mock_observer); testobject->emit_multiple_value_signal(1, 2, "31"); - SECTION("subscriber sees values") + SUBCASE("subscriber sees values") { CHECK(mock_observer.get_received_values() == std::vector>{std::tuple{1, 2.0, "31"}}); CHECK(mock_observer.get_on_error_count() == 0); @@ -118,17 +117,17 @@ TEST_CASE("from_signal sends tuple if multiple values") TEST_CASE("from_signal sends special struct if no args in signal") { - SECTION("object with signal with zero values and observable from this signal") + SUBCASE("object with signal with zero values and observable from this signal") { mock_observer_strategy mock_observer{}; auto testobject = std::make_unique(); auto obs = rppqt::source::from_signal(*testobject, &test_q_object::no_value_signal); - SECTION("subscribe on it and emit signal") + SUBCASE("subscribe on it and emit signal") { obs.subscribe(mock_observer); testobject->emit_no_value_signal(); - SECTION("subscriber sees values") + SUBCASE("subscriber sees values") { CHECK(mock_observer.get_received_values().size() == 1); CHECK(mock_observer.get_on_error_count() == 0); diff --git a/src/tests/rppqt/test_main_thread_scheduler.cpp b/src/tests/rppqt/test_main_thread_scheduler.cpp index 05a06cdf4..6caafec6a 100644 --- a/src/tests/rppqt/test_main_thread_scheduler.cpp +++ b/src/tests/rppqt/test_main_thread_scheduler.cpp @@ -7,8 +7,7 @@ // // Project home: https://github.com/victimsnino/ReactivePlusPlus -#include -#include +#include #include #include @@ -33,7 +32,7 @@ TEST_CASE("main_thread_scheduler schedules actions to main thread") QTimer::singleShot(10, &application, [&] { application.exit(); }); - SECTION("submitting action to main scheduler from another thread") + SUBCASE("submitting action to main scheduler from another thread") { std::promise execution_thread{}; std::thread{[&] { @@ -45,7 +44,7 @@ TEST_CASE("main_thread_scheduler schedules actions to main thread") }}.join(); application.exec(); - SECTION("thread of exectuion of schedulable should be same as thread of application") + SUBCASE("thread of exectuion of schedulable should be same as thread of application") { auto future = execution_thread.get_future(); REQUIRE(future.wait_for(std::chrono::seconds{1}) == std::future_status::ready); @@ -53,7 +52,7 @@ TEST_CASE("main_thread_scheduler schedules actions to main thread") } } - SECTION("nothing happens for disposed handler") + SUBCASE("nothing happens for disposed handler") { std::promise execution_thread{}; std::thread{[&] { @@ -72,7 +71,7 @@ TEST_CASE("main_thread_scheduler schedules actions to main thread") } auto test_recursive_scheduling = [&](const auto& duration) { - SECTION("recursive scheduling to main thread") + SUBCASE("recursive scheduling to main thread") { std::string execution{}; std::thread{[&] { @@ -94,15 +93,15 @@ TEST_CASE("main_thread_scheduler schedules actions to main thread") CHECK(execution == "outer inner outer inner "); } }; - SECTION("optional_delay_from_now") + SUBCASE("optional_delay_from_now") { test_recursive_scheduling(rpp::schedulers::optional_delay_from_now{std::chrono::nanoseconds{}}); } - SECTION("optional_delay_from_this_timepoint") + SUBCASE("optional_delay_from_this_timepoint") { test_recursive_scheduling(rpp::schedulers::optional_delay_from_this_timepoint{std::chrono::nanoseconds{}}); } - SECTION("optional_delay_to") + SUBCASE("optional_delay_to") { test_recursive_scheduling(rpp::schedulers::optional_delay_to{rpp::schedulers::time_point{}}); } diff --git a/src/tests/utils/copy_count_tracker.hpp b/src/tests/utils/copy_count_tracker.hpp index 666df1ec9..13a0b927d 100644 --- a/src/tests/utils/copy_count_tracker.hpp +++ b/src/tests/utils/copy_count_tracker.hpp @@ -10,8 +10,7 @@ #pragma once -#include -#include +#include #include #include @@ -97,14 +96,14 @@ class copy_count_tracker static void test_operator(auto&& op, test_expectations expectations, size_t count = 1) { copy_count_tracker tracker{}; - SECTION("send value by copy") + SUBCASE("send value by copy") { tracker.get_observable(count) | op | rpp::ops::subscribe(rpp::utils::empty_function_any_by_lvalue_t{}); CHECK(tracker.get_copy_count() == expectations.send_by_copy.copy_count); CHECK(tracker.get_move_count() == expectations.send_by_copy.move_count); } - SECTION("send value by move") + SUBCASE("send value by move") { tracker.get_observable_for_move(count) | op | rpp::ops::subscribe(rpp::utils::empty_function_any_by_lvalue_t{}); CHECK(tracker.get_copy_count() == expectations.send_by_move.copy_count); diff --git a/src/tests/utils/disposable_observable.hpp b/src/tests/utils/disposable_observable.hpp index c8124077f..e5b527b95 100644 --- a/src/tests/utils/disposable_observable.hpp +++ b/src/tests/utils/disposable_observable.hpp @@ -10,8 +10,7 @@ #pragma once -#include -#include +#include #include #include @@ -49,7 +48,7 @@ struct wrapped_observable_strategy_no_set_upstream template void test_operator_over_observable_finish_before_dispose(auto&& op) { - SECTION("operator calls on_error before dispose") + SUBCASE("operator calls on_error before dispose") { bool callback_called = false; auto observable_disposable = rpp::make_callback_disposable([&callback_called]() noexcept { @@ -64,7 +63,7 @@ void test_operator_over_observable_finish_before_dispose(auto&& op) CHECK(callback_called); } - SECTION("operator calls on_completed before dispose") + SUBCASE("operator calls on_completed before dispose") { bool callback_called = false; auto observable_disposable = rpp::make_callback_disposable([&callback_called]() noexcept { @@ -83,7 +82,7 @@ void test_operator_over_observable_finish_before_dispose(auto&& op) template void test_operator_over_observable_with_disposable(auto&& op) { - SECTION("operator disposes disposable") + SUBCASE("operator disposes disposable") { auto observable_disposable = rpp::composite_disposable_wrapper::make(); std::optional> saved_observer{}; @@ -99,7 +98,7 @@ void test_operator_over_observable_with_disposable(auto&& op) CHECK(observable_disposable.is_disposed()); } - SECTION("operator doesn't disposes disposable too early") + SUBCASE("operator doesn't disposes disposable too early") { auto observable_disposable = rpp::composite_disposable_wrapper::make(); auto observable = rpp::source::create([&observable_disposable](auto&& obs) { @@ -114,7 +113,7 @@ void test_operator_over_observable_with_disposable(auto&& op) CHECK(observable_disposable.is_disposed()); } - SECTION("operator disposes disposable on_error") + SUBCASE("operator disposes disposable on_error") { op(rpp::source::create([](auto&& obs) { const auto d = rpp::composite_disposable_wrapper::make(); @@ -124,7 +123,7 @@ void test_operator_over_observable_with_disposable(auto&& op) })).subscribe([](const auto&) {}, [](const std::exception_ptr&) {}); } - SECTION("operator disposes disposable on_completed") + SUBCASE("operator disposes disposable on_completed") { op(rpp::source::create([](auto&& obs) { const auto d = rpp::composite_disposable_wrapper::make(); @@ -134,43 +133,43 @@ void test_operator_over_observable_with_disposable(auto&& op) })).subscribe([](const auto&) {}, [](const std::exception_ptr&) {}); } - SECTION("set_upstream with fixed_disposable_strategy_selector<1>") + SUBCASE("set_upstream with fixed_disposable_strategy_selector<1>") { CHECK_NOTHROW(op(rpp::observable>>{}) .subscribe([](const auto&) {}, rpp::utils::rethrow_error_t{})); } - SECTION("set_upstream with dynamic_disposable_strategy_selector<0>") + SUBCASE("set_upstream with dynamic_disposable_strategy_selector<0>") { CHECK_NOTHROW(op(rpp::observable>>{}) .subscribe([](const auto&) {}, rpp::utils::rethrow_error_t{})); } - SECTION("none_disposable_strategy") + SUBCASE("none_disposable_strategy") { CHECK_NOTHROW(op(rpp::observable>{}) .subscribe([](const auto&) {}, rpp::utils::rethrow_error_t{})); } - SECTION("fixed_disposable_strategy_selector<0>") + SUBCASE("fixed_disposable_strategy_selector<0>") { CHECK_NOTHROW(op(rpp::observable>>{}) .subscribe([](const auto&) {}, rpp::utils::rethrow_error_t{})); } - SECTION("dynamic_disposable_strategy_selector<0>") + SUBCASE("dynamic_disposable_strategy_selector<0>") { CHECK_NOTHROW(op(rpp::observable>>{}) .subscribe([](const auto&) {}, rpp::utils::rethrow_error_t{})); } - SECTION("set_upstream with none_disposable_strategy calls on_error") + SUBCASE("set_upstream with none_disposable_strategy calls on_error") { CHECK_NOTHROW(op(rpp::observable>{}) .subscribe([](const auto&) {}, [](const std::exception_ptr& err) { CHECK_THROWS_AS(std::rethrow_exception(err), rpp::utils::more_disposables_than_expected); })); } - SECTION("set_upstream with fixed_disposable_strategy_selector<0> calls on_error") + SUBCASE("set_upstream with fixed_disposable_strategy_selector<0> calls on_error") { CHECK_NOTHROW(op(rpp::observable>>{}) .subscribe([](const auto&) {}, [](const std::exception_ptr& err) { CHECK_THROWS_AS(std::rethrow_exception(err), rpp::utils::more_disposables_than_expected); })); diff --git a/src/tests/utils/rpp_trompeloil.hpp b/src/tests/utils/rpp_trompeloil.hpp index 712cf907b..910e277be 100644 --- a/src/tests/utils/rpp_trompeloil.hpp +++ b/src/tests/utils/rpp_trompeloil.hpp @@ -1,7 +1,7 @@ #pragma once -#include -#include +#include +#include #include @@ -12,30 +12,6 @@ #include #include -namespace trompeloeil -{ - template<> - inline void reporter::send( - severity s, - const char*, - unsigned long, - const char* msg) - { - FAIL_CHECK(msg); - if (s == severity::fatal) - { - std::terminate(); // terminate due to rpp could catch exceptions but we dont want it - } - } - - template<> - inline void reporter::sendOk( - const char* trompeloeil_mock_calls_done_correctly) - { - REQUIRE(trompeloeil_mock_calls_done_correctly); - } -} // namespace trompeloeil - template class mock_observer { From 847dbd99c76131c92f23bc70f892942240a1df43 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Tue, 1 Oct 2024 11:00:43 +0300 Subject: [PATCH 2/8] Update CMakeLists.txt --- src/tests/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index b71df7fd7..00b4c9eed 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -14,7 +14,7 @@ macro(add_test_target target_name module files) set(TARGET ${target_name}) add_executable(${TARGET} ${files}) - target_link_libraries(${TARGET} PRIVATE doctest trompeloeil::trompeloeil rpp_tests_utils ${module}) + target_link_libraries(${TARGET} PRIVATE doctest::doctest trompeloeil::trompeloeil rpp_tests_utils ${module}) target_compile_definitions(${TARGET} PRIVATE "DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN") set_target_properties(${TARGET} PROPERTIES FOLDER Tests/Suites/${module}) From bc21f1f3b087a1ecef1d900d5e3bc94a56d89beb Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Tue, 1 Oct 2024 16:45:44 +0300 Subject: [PATCH 3/8] Update CMakeLists.txt --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4afedadc4..8800bf2ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,9 +52,9 @@ if (RPP_BUILD_TESTS OR RPP_BUILD_BENCHMARKS) macro(add_test_with_coverage TARGET) if (RPP_ENABLE_COVERAGE) - add_test(NAME ${TARGET} COMMAND ${CMAKE_COMMAND} -E env LLVM_PROFILE_FILE=${RPP_TEST_RESULTS_DIR}/${TARGET}.profraw $ -s) + add_test(NAME ${TARGET} COMMAND ${CMAKE_COMMAND} -E env LLVM_PROFILE_FILE=${RPP_TEST_RESULTS_DIR}/${TARGET}.profraw $) else() - add_test(NAME ${TARGET} COMMAND $ -s) + add_test(NAME ${TARGET} COMMAND $) endif() endmacro() endif() From 0b74c00e29e85bceb9ffbc794ac265a51abbbaa5 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Tue, 1 Oct 2024 23:33:04 +0300 Subject: [PATCH 4/8] fix take_until --- src/tests/rpp/test_take_until.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/tests/rpp/test_take_until.cpp b/src/tests/rpp/test_take_until.cpp index 727bd29dc..3be57826b 100644 --- a/src/tests/rpp/test_take_until.cpp +++ b/src/tests/rpp/test_take_until.cpp @@ -223,12 +223,14 @@ TEST_CASE("take_until doesn't produce extra copies") TEST_CASE("take_until satisfies disposable contracts") { - test_operator_with_disposable(rpp::ops::take_until(rpp::source::never())); - test_operator_with_disposable(rpp::ops::take_until(rpp::source::empty())); - test_operator_finish_before_dispose(rpp::ops::take_until(rpp::source::empty())); - test_operator_over_observable_finish_before_dispose([](const auto& ob) { - return rpp::source::never() | rpp::ops::take_until(ob); - }); + SUBCASE("take_until(never)") + test_operator_with_disposable(rpp::ops::take_until(rpp::source::never())); + SUBCASE("take_until(empty)") + test_operator_finish_before_dispose(rpp::ops::take_until(rpp::source::empty())); + SUBCASE("never | take_until(ob)") + test_operator_over_observable_finish_before_dispose([](const auto& ob) { + return rpp::source::never() | rpp::ops::take_until(ob); + }); } TEST_CASE("take_until dispose after completion") From 7d953bc88fd215f6f2589a1b1b404088866a4997 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Tue, 1 Oct 2024 23:36:27 +0300 Subject: [PATCH 5/8] fix loop --- src/tests/rpp/test_retry_when.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tests/rpp/test_retry_when.cpp b/src/tests/rpp/test_retry_when.cpp index b895eba6b..441926891 100644 --- a/src/tests/rpp/test_retry_when.cpp +++ b/src/tests/rpp/test_retry_when.cpp @@ -287,7 +287,8 @@ TEST_CASE("retry_when satisfies disposable contracts") test_operator_over_observable_with_disposable( [](auto observable) { + auto c = std::make_shared(); return rpp::source::concat(observable, rpp::source::error(std::make_exception_ptr(std::runtime_error{"error"}))) - | rpp::ops::retry_when([](const std::exception_ptr&) { return rpp::source::just(1); }); + | rpp::ops::retry_when([c](const std::exception_ptr&) -> rpp::dynamic_observable { if ((*c)++ ==0) return rpp::source::just(1); return rpp::source::empty(); }); }); } From 6d09411f23ee984e00d8be2b46f03d736308aa15 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 1 Oct 2024 20:37:41 +0000 Subject: [PATCH 6/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/tests/rpp/test_take_until.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/tests/rpp/test_take_until.cpp b/src/tests/rpp/test_take_until.cpp index 3be57826b..ca1348418 100644 --- a/src/tests/rpp/test_take_until.cpp +++ b/src/tests/rpp/test_take_until.cpp @@ -224,13 +224,13 @@ TEST_CASE("take_until doesn't produce extra copies") TEST_CASE("take_until satisfies disposable contracts") { SUBCASE("take_until(never)") - test_operator_with_disposable(rpp::ops::take_until(rpp::source::never())); + test_operator_with_disposable(rpp::ops::take_until(rpp::source::never())); SUBCASE("take_until(empty)") - test_operator_finish_before_dispose(rpp::ops::take_until(rpp::source::empty())); + test_operator_finish_before_dispose(rpp::ops::take_until(rpp::source::empty())); SUBCASE("never | take_until(ob)") - test_operator_over_observable_finish_before_dispose([](const auto& ob) { - return rpp::source::never() | rpp::ops::take_until(ob); - }); + test_operator_over_observable_finish_before_dispose([](const auto& ob) { + return rpp::source::never() | rpp::ops::take_until(ob); + }); } TEST_CASE("take_until dispose after completion") From 44617526a0bfbbc612995da1efb87d891ce34640 Mon Sep 17 00:00:00 2001 From: Aleksey Loginov Date: Fri, 4 Oct 2024 00:06:14 +0300 Subject: [PATCH 7/8] fix sonar --- src/tests/CMakeLists.txt | 3 +-- src/tests/utils/CMakeLists.txt | 4 ++++ src/tests/utils/doctest_main.cpp | 2 ++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 src/tests/utils/doctest_main.cpp diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 00b4c9eed..33695d0ea 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -14,8 +14,7 @@ macro(add_test_target target_name module files) set(TARGET ${target_name}) add_executable(${TARGET} ${files}) - target_link_libraries(${TARGET} PRIVATE doctest::doctest trompeloeil::trompeloeil rpp_tests_utils ${module}) - target_compile_definitions(${TARGET} PRIVATE "DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN") + target_link_libraries(${TARGET} PRIVATE rpp_doctest_main trompeloeil::trompeloeil rpp_tests_utils ${module}) set_target_properties(${TARGET} PROPERTIES FOLDER Tests/Suites/${module}) add_test_with_coverage(${TARGET}) diff --git a/src/tests/utils/CMakeLists.txt b/src/tests/utils/CMakeLists.txt index 32ebb8325..afce3c5fa 100644 --- a/src/tests/utils/CMakeLists.txt +++ b/src/tests/utils/CMakeLists.txt @@ -1,3 +1,7 @@ add_library(rpp_tests_utils INTERFACE) target_include_directories(rpp_tests_utils INTERFACE .) target_link_libraries(rpp_tests_utils INTERFACE rpp) + + +add_library(rpp_doctest_main doctest_main.cpp) +target_link_libraries(rpp_doctest_main PUBLIC doctest::doctest) \ No newline at end of file diff --git a/src/tests/utils/doctest_main.cpp b/src/tests/utils/doctest_main.cpp new file mode 100644 index 000000000..0a3f254ea --- /dev/null +++ b/src/tests/utils/doctest_main.cpp @@ -0,0 +1,2 @@ +#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN +#include From 752b2f9fb930dac2c3decce90b8a5769deee8eda Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 3 Oct 2024 21:06:07 +0000 Subject: [PATCH 8/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/tests/utils/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tests/utils/CMakeLists.txt b/src/tests/utils/CMakeLists.txt index afce3c5fa..23507f9b5 100644 --- a/src/tests/utils/CMakeLists.txt +++ b/src/tests/utils/CMakeLists.txt @@ -4,4 +4,4 @@ target_link_libraries(rpp_tests_utils INTERFACE rpp) add_library(rpp_doctest_main doctest_main.cpp) -target_link_libraries(rpp_doctest_main PUBLIC doctest::doctest) \ No newline at end of file +target_link_libraries(rpp_doctest_main PUBLIC doctest::doctest)