diff options
author | Grigoriy Chudnov <g.chudnov@gmail.com> | 2016-12-19 16:35:12 +0300 |
---|---|---|
committer | Kirk Shoop <kirk.shoop@microsoft.com> | 2016-12-19 08:59:45 -0800 |
commit | ae41c69ff2684ad2d80841948e0bed203a0b7504 (patch) | |
tree | 32564f18b641b511784c81fa4fa6f976a1cd72ca /Rx/v2/test/operators/pairwise.cpp | |
parent | fa9428c65f09f76024f0f2acfb819f22f0875320 (diff) | |
download | RxCpp-ae41c69ff2684ad2d80841948e0bed203a0b7504.tar.gz |
decouple pairwise from observable
Diffstat (limited to 'Rx/v2/test/operators/pairwise.cpp')
-rw-r--r-- | Rx/v2/test/operators/pairwise.cpp | 42 |
1 files changed, 39 insertions, 3 deletions
diff --git a/Rx/v2/test/operators/pairwise.cpp b/Rx/v2/test/operators/pairwise.cpp index 20da0d8..7ba0c42 100644 --- a/Rx/v2/test/operators/pairwise.cpp +++ b/Rx/v2/test/operators/pairwise.cpp @@ -1,6 +1,7 @@ #include "../test.h" +#include "rxcpp/operators/rx-pairwise.hpp" -SCENARIO("pairwise", "[pairwise][operators]") { +SCENARIO("pairwise - enough items to create pairs", "[pairwise][operators]") { GIVEN("a cold observable of n ints") { auto sc = rxsc::make_test(); auto w = sc.create_worker(); @@ -22,9 +23,9 @@ SCENARIO("pairwise", "[pairwise][operators]") { auto res = w.start( [xs, &invoked]() { return xs - .pairwise() + | rxo::pairwise() // forget type to workaround lambda deduction bug on msvc 2013 - .as_dynamic(); + | rxo::as_dynamic(); } ); @@ -43,3 +44,38 @@ SCENARIO("pairwise", "[pairwise][operators]") { } } } + +SCENARIO("pairwise - not enough items to create a pair", "[pairwise][operators]") { + GIVEN("a cold observable of 1 ints") { + auto sc = rxsc::make_test(); + auto w = sc.create_worker(); + const rxsc::test::messages<int> on; + const rxsc::test::messages<std::tuple<int, int>> on_pairwise; + + auto xs = sc.make_cold_observable({ + on.next(180, 1), + on.completed(400), + }); + + WHEN("taken pairwise") { + + auto res = w.start( + [xs]() { + return xs + .pairwise() + // forget type to workaround lambda deduction bug on msvc 2013 + .as_dynamic(); + } + ); + + THEN("the output contains no tuples of ints"){ + auto delay = rxcpp::schedulers::test::subscribed_time; + auto required = rxu::to_vector({ + on_pairwise.completed(400 + delay) + }); + auto actual = res.get_observer().messages(); + REQUIRE(required == actual); + } + } + } +} |