diff options
Diffstat (limited to 'Rx/v2/test/operators')
-rw-r--r-- | Rx/v2/test/operators/buffer.cpp | 10 | ||||
-rw-r--r-- | Rx/v2/test/operators/concat.cpp | 6 | ||||
-rw-r--r-- | Rx/v2/test/operators/concat_map.cpp | 8 | ||||
-rw-r--r-- | Rx/v2/test/operators/flat_map.cpp | 10 | ||||
-rw-r--r-- | Rx/v2/test/operators/group_by.cpp | 4 | ||||
-rw-r--r-- | Rx/v2/test/operators/merge.cpp | 6 | ||||
-rw-r--r-- | Rx/v2/test/operators/merge_delay_error.cpp | 2 | ||||
-rw-r--r-- | Rx/v2/test/operators/observe_on.cpp | 2 | ||||
-rw-r--r-- | Rx/v2/test/operators/publish.cpp | 102 | ||||
-rw-r--r-- | Rx/v2/test/operators/scan.cpp | 2 | ||||
-rw-r--r-- | Rx/v2/test/operators/subscribe_on.cpp | 4 |
11 files changed, 127 insertions, 29 deletions
diff --git a/Rx/v2/test/operators/buffer.cpp b/Rx/v2/test/operators/buffer.cpp index 2aec5d1..e1b980c 100644 --- a/Rx/v2/test/operators/buffer.cpp +++ b/Rx/v2/test/operators/buffer.cpp @@ -455,7 +455,7 @@ SCENARIO("buffer count error 2", "[buffer][operators]"){ } } -SCENARIO("buffer with time on intervals", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on intervals", "[buffer_with_time][operators][long][!hide]"){ GIVEN("7 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-----------------| @@ -500,7 +500,7 @@ SCENARIO("buffer with time on intervals", "[buffer_with_time][operators][long][h } } -SCENARIO("buffer with time on intervals, implicit coordination", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on intervals, implicit coordination", "[buffer_with_time][operators][long][!hide]"){ GIVEN("7 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-----------------| @@ -543,7 +543,7 @@ SCENARIO("buffer with time on intervals, implicit coordination", "[buffer_with_t } } -SCENARIO("buffer with time on overlapping intervals", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on overlapping intervals", "[buffer_with_time][operators][long][!hide]"){ GIVEN("5 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-------------| @@ -587,7 +587,7 @@ SCENARIO("buffer with time on overlapping intervals", "[buffer_with_time][operat } } -SCENARIO("buffer with time on overlapping intervals, implicit coordination", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on overlapping intervals, implicit coordination", "[buffer_with_time][operators][long][!hide]"){ GIVEN("5 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-------------| @@ -631,7 +631,7 @@ SCENARIO("buffer with time on overlapping intervals, implicit coordination", "[b } } -SCENARIO("buffer with time on intervals, error", "[buffer_with_time][operators][long][hide]"){ +SCENARIO("buffer with time on intervals, error", "[buffer_with_time][operators][long][!hide]"){ GIVEN("5 intervals of 2 seconds"){ WHEN("the period is 2sec and the initial is 5sec"){ // time: |-------------| diff --git a/Rx/v2/test/operators/concat.cpp b/Rx/v2/test/operators/concat.cpp index 86f4a7e..88dcac7 100644 --- a/Rx/v2/test/operators/concat.cpp +++ b/Rx/v2/test/operators/concat.cpp @@ -5,7 +5,7 @@ const int static_onnextcalls = 1000000; -SCENARIO("synchronize concat ranges", "[hide][range][synchronize][concat][perf]"){ +SCENARIO("synchronize concat ranges", "[!hide][range][synchronize][concat][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -33,7 +33,7 @@ SCENARIO("synchronize concat ranges", "[hide][range][synchronize][concat][perf]" } } -SCENARIO("observe_on concat ranges", "[hide][range][observe_on][concat][perf]"){ +SCENARIO("observe_on concat ranges", "[!hide][range][observe_on][concat][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -61,7 +61,7 @@ SCENARIO("observe_on concat ranges", "[hide][range][observe_on][concat][perf]"){ } } -SCENARIO("serialize concat ranges", "[hide][range][serialize][concat][perf]"){ +SCENARIO("serialize concat ranges", "[!hide][range][serialize][concat][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ diff --git a/Rx/v2/test/operators/concat_map.cpp b/Rx/v2/test/operators/concat_map.cpp index cc163b1..cfd6f4f 100644 --- a/Rx/v2/test/operators/concat_map.cpp +++ b/Rx/v2/test/operators/concat_map.cpp @@ -8,7 +8,7 @@ static const int static_tripletCount = 100; -SCENARIO("concat_transform pythagorian ranges", "[hide][range][concat_transform][pythagorian][perf]"){ +SCENARIO("concat_transform pythagorian ranges", "[!hide][range][concat_transform][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -53,7 +53,7 @@ SCENARIO("concat_transform pythagorian ranges", "[hide][range][concat_transform] } } -SCENARIO("synchronize concat_transform pythagorian ranges", "[hide][range][concat_transform][synchronize][pythagorian][perf]"){ +SCENARIO("synchronize concat_transform pythagorian ranges", "[!hide][range][concat_transform][synchronize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -101,7 +101,7 @@ SCENARIO("synchronize concat_transform pythagorian ranges", "[hide][range][conca } } -SCENARIO("observe_on concat_transform pythagorian ranges", "[hide][range][concat_transform][observe_on][pythagorian][perf]"){ +SCENARIO("observe_on concat_transform pythagorian ranges", "[!hide][range][concat_transform][observe_on][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -150,7 +150,7 @@ SCENARIO("observe_on concat_transform pythagorian ranges", "[hide][range][concat } } -SCENARIO("serialize concat_transform pythagorian ranges", "[hide][range][concat_transform][serialize][pythagorian][perf]"){ +SCENARIO("serialize concat_transform pythagorian ranges", "[!hide][range][concat_transform][serialize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ diff --git a/Rx/v2/test/operators/flat_map.cpp b/Rx/v2/test/operators/flat_map.cpp index 2e01a30..e1837b0 100644 --- a/Rx/v2/test/operators/flat_map.cpp +++ b/Rx/v2/test/operators/flat_map.cpp @@ -8,7 +8,7 @@ static const int static_tripletCount = 100; -SCENARIO("pythagorian for loops", "[hide][for][pythagorian][perf]"){ +SCENARIO("pythagorian for loops", "[!hide][for][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("a for loop"){ WHEN("generating pythagorian triplets"){ @@ -45,7 +45,7 @@ SCENARIO("pythagorian for loops", "[hide][for][pythagorian][perf]"){ } } -SCENARIO("merge_transform pythagorian ranges", "[hide][range][merge_transform][pythagorian][perf]"){ +SCENARIO("merge_transform pythagorian ranges", "[!hide][range][merge_transform][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -89,7 +89,7 @@ SCENARIO("merge_transform pythagorian ranges", "[hide][range][merge_transform][p } } -SCENARIO("synchronize merge_transform pythagorian ranges", "[hide][range][merge_transform][synchronize][pythagorian][perf]"){ +SCENARIO("synchronize merge_transform pythagorian ranges", "[!hide][range][merge_transform][synchronize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -137,7 +137,7 @@ SCENARIO("synchronize merge_transform pythagorian ranges", "[hide][range][merge_ } } -SCENARIO("observe_on merge_transform pythagorian ranges", "[hide][range][merge_transform][observe_on][pythagorian][perf]"){ +SCENARIO("observe_on merge_transform pythagorian ranges", "[!hide][range][merge_transform][observe_on][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ @@ -185,7 +185,7 @@ SCENARIO("observe_on merge_transform pythagorian ranges", "[hide][range][merge_t } } -SCENARIO("serialize merge_transform pythagorian ranges", "[hide][range][merge_transform][serialize][pythagorian][perf]"){ +SCENARIO("serialize merge_transform pythagorian ranges", "[!hide][range][merge_transform][serialize][pythagorian][perf]"){ const int& tripletCount = static_tripletCount; GIVEN("some ranges"){ WHEN("generating pythagorian triplets"){ diff --git a/Rx/v2/test/operators/group_by.cpp b/Rx/v2/test/operators/group_by.cpp index b575cd9..645bda4 100644 --- a/Rx/v2/test/operators/group_by.cpp +++ b/Rx/v2/test/operators/group_by.cpp @@ -11,7 +11,7 @@ #include <locale> #include <sstream> -SCENARIO("range partitioned by group_by across hardware threads to derive pi", "[hide][pi][group_by][observe_on][long][perf]"){ +SCENARIO("range partitioned by group_by across hardware threads to derive pi", "[!hide][pi][group_by][observe_on][long][perf]"){ GIVEN("a for loop"){ WHEN("partitioning pi series across all hardware threads"){ @@ -93,7 +93,7 @@ SCENARIO("range partitioned by group_by across hardware threads to derive pi", " } } -SCENARIO("range partitioned by dividing work across hardware threads to derive pi", "[hide][pi][observe_on][long][perf]"){ +SCENARIO("range partitioned by dividing work across hardware threads to derive pi", "[!hide][pi][observe_on][long][perf]"){ GIVEN("a for loop"){ WHEN("partitioning pi series across all hardware threads"){ diff --git a/Rx/v2/test/operators/merge.cpp b/Rx/v2/test/operators/merge.cpp index 9a7f28c..917d74d 100644 --- a/Rx/v2/test/operators/merge.cpp +++ b/Rx/v2/test/operators/merge.cpp @@ -6,7 +6,7 @@ const int static_onnextcalls = 1000000; -SCENARIO("synchronize merge ranges", "[hide][range][synchronize][merge][perf]"){ +SCENARIO("synchronize merge ranges", "[!hide][range][synchronize][merge][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -34,7 +34,7 @@ SCENARIO("synchronize merge ranges", "[hide][range][synchronize][merge][perf]"){ } } -SCENARIO("observe_on merge ranges", "[hide][range][observe_on][merge][perf]"){ +SCENARIO("observe_on merge ranges", "[!hide][range][observe_on][merge][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ @@ -62,7 +62,7 @@ SCENARIO("observe_on merge ranges", "[hide][range][observe_on][merge][perf]"){ } } -SCENARIO("serialize merge ranges", "[hide][range][serialize][merge][perf]"){ +SCENARIO("serialize merge ranges", "[!hide][range][serialize][merge][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("some ranges"){ WHEN("generating ints"){ diff --git a/Rx/v2/test/operators/merge_delay_error.cpp b/Rx/v2/test/operators/merge_delay_error.cpp index b53b884..83172ec 100644 --- a/Rx/v2/test/operators/merge_delay_error.cpp +++ b/Rx/v2/test/operators/merge_delay_error.cpp @@ -3,8 +3,6 @@ #include <rxcpp/operators/rx-merge_delay_error.hpp> #include <rxcpp/operators/rx-observe_on.hpp> -const int static_onnextcalls = 1000000; - //merge_delay_error must work the very same way as `merge()` except the error handling SCENARIO("merge_delay_error completes", "[merge][join][operators]"){ diff --git a/Rx/v2/test/operators/observe_on.cpp b/Rx/v2/test/operators/observe_on.cpp index ffa85aa..aac2d40 100644 --- a/Rx/v2/test/operators/observe_on.cpp +++ b/Rx/v2/test/operators/observe_on.cpp @@ -5,7 +5,7 @@ const int static_onnextcalls = 100000; -SCENARIO("range observed on new_thread", "[hide][range][observe_on_debug][observe_on][long][perf]"){ +SCENARIO("range observed on new_thread", "[!hide][range][observe_on_debug][observe_on][long][perf]"){ const int& onnextcalls = static_onnextcalls; GIVEN("a range"){ WHEN("multicasting a million ints"){ diff --git a/Rx/v2/test/operators/publish.cpp b/Rx/v2/test/operators/publish.cpp index 87c8fff..fe578d7 100644 --- a/Rx/v2/test/operators/publish.cpp +++ b/Rx/v2/test/operators/publish.cpp @@ -2,9 +2,11 @@ #include <rxcpp/operators/rx-publish.hpp> #include <rxcpp/operators/rx-connect_forever.hpp> #include <rxcpp/operators/rx-ref_count.hpp> +#include <rxcpp/operators/rx-map.hpp> +#include <rxcpp/operators/rx-merge.hpp> -SCENARIO("publish range", "[hide][range][subject][publish][subject][operators]"){ +SCENARIO("publish range", "[!hide][range][subject][publish][subject][operators]"){ GIVEN("a range"){ WHEN("published"){ auto published = rxs::range<int>(0, 10).publish(); @@ -38,6 +40,104 @@ SCENARIO("publish range", "[hide][range][subject][publish][subject][operators]") } } +SCENARIO("publish ref_count", "[range][subject][publish][ref_count][operators]"){ + GIVEN("a range"){ + WHEN("ref_count is used"){ + auto published = rxs::range<int>(0, 3).publish().ref_count(); + + std::vector<int> results; + published.subscribe( + // on_next + [&](int v){ + results.push_back(v); + }, + // on_completed + [](){}); + + std::vector<int> expected_results; + expected_results.push_back(0); + expected_results.push_back(1); + expected_results.push_back(2); + expected_results.push_back(3); + + CHECK(results == expected_results); + } + WHEN("ref_count(other) is used"){ + auto published = rxs::range<double>(0, 10).publish(); + auto map_to_int = published.map([](double v) { return (long) v; }); + + // Ensures that 'ref_count(other)' has the source value type, + // not the publisher's value type. + auto with_ref_count = map_to_int.ref_count(published); + + std::vector<long> results; + + with_ref_count.subscribe( + // on_next + [&](long v){ + results.push_back(v); + }, + // on_completed + [](){}); + + std::vector<long> expected_results; + for (long i = 0; i <= 10; ++i) { + expected_results.push_back(i); + } + CHECK(results == expected_results); + } + WHEN("ref_count(other) is used in a diamond"){ + auto source = rxs::range<double>(0, 3); + + int published_on_next_count = 0; + // Ensure we only subscribe once to 'published' when its in a diamond. + auto next = source.map( + [&](double v) { + published_on_next_count++; + return v; + } + ); + auto published = next.publish(); + + // Ensures that 'x.ref_count(other)' has the 'x' value type, not the other's value + // type. + auto map_to_int = published.map([](double v) { return (long) v; }); + + auto left = map_to_int.map([](long v) { return v * 2; }); + auto right = map_to_int.map([](long v) { return v * 100; }); + + auto merge = left.merge(right); + auto with_ref_count = merge.ref_count(published); + + std::vector<long> results; + + with_ref_count.subscribe( + // on_next + [&](long v){ + results.push_back(v); + }, + // on_completed + [](){}); + + // Ensure we only subscribe once to 'published' when its in a diamond. + CHECK(published_on_next_count == 4); + + std::vector<long> expected_results; + expected_results.push_back(0); + expected_results.push_back(0); + expected_results.push_back(2); + expected_results.push_back(100); + expected_results.push_back(4); + expected_results.push_back(200); + expected_results.push_back(6); + expected_results.push_back(300); + + // Ensure left,right is interleaved without being biased towards one side. + CHECK(results == expected_results); + } + } +} + SCENARIO("publish basic", "[publish][multicast][subject][operators]"){ GIVEN("a test hot observable of longs"){ auto sc = rxsc::make_test(); diff --git a/Rx/v2/test/operators/scan.cpp b/Rx/v2/test/operators/scan.cpp index f1d64e9..1cb38a5 100644 --- a/Rx/v2/test/operators/scan.cpp +++ b/Rx/v2/test/operators/scan.cpp @@ -3,7 +3,7 @@ #include <rxcpp/operators/rx-take.hpp> #include <rxcpp/operators/rx-scan.hpp> -SCENARIO("scan: issue 41", "[scan][operators][issue][hide]"){ +SCENARIO("scan: issue 41", "[scan][operators][issue][!hide]"){ GIVEN("map of scan of interval"){ auto sc = rxsc::make_current_thread(); auto so = rxcpp::synchronize_in_one_worker(sc); diff --git a/Rx/v2/test/operators/subscribe_on.cpp b/Rx/v2/test/operators/subscribe_on.cpp index 936fbc1..ef8a8c7 100644 --- a/Rx/v2/test/operators/subscribe_on.cpp +++ b/Rx/v2/test/operators/subscribe_on.cpp @@ -8,7 +8,7 @@ static const int static_subscriptions = 50000; -SCENARIO("for loop subscribes to map with subscribe_on and observe_on", "[hide][for][just][subscribe][subscribe_on][observe_on][long][perf]"){ +SCENARIO("for loop subscribes to map with subscribe_on and observe_on", "[!hide][for][just][subscribe][subscribe_on][observe_on][long][perf]"){ const int& subscriptions = static_subscriptions; GIVEN("a for loop"){ WHEN("subscribe 50K times"){ @@ -48,7 +48,7 @@ SCENARIO("for loop subscribes to map with subscribe_on and observe_on", "[hide][ } } -SCENARIO("for loop subscribes to map with subscribe_on", "[hide][subscribe_on_only][for][just][subscribe][subscribe_on][long][perf]"){ +SCENARIO("for loop subscribes to map with subscribe_on", "[!hide][subscribe_on_only][for][just][subscribe][subscribe_on][long][perf]"){ const int& subscriptions = static_subscriptions; GIVEN("a for loop"){ WHEN("subscribe 50K times"){ |