summaryrefslogtreecommitdiff
path: root/Rx/v2/test/operators/pairwise.cpp
diff options
context:
space:
mode:
authorGrigoriy Chudnov <g.chudnov@gmail.com>2016-12-19 16:35:12 +0300
committerKirk Shoop <kirk.shoop@microsoft.com>2016-12-19 08:59:45 -0800
commitae41c69ff2684ad2d80841948e0bed203a0b7504 (patch)
tree32564f18b641b511784c81fa4fa6f976a1cd72ca /Rx/v2/test/operators/pairwise.cpp
parentfa9428c65f09f76024f0f2acfb819f22f0875320 (diff)
downloadRxCpp-ae41c69ff2684ad2d80841948e0bed203a0b7504.tar.gz
decouple pairwise from observable
Diffstat (limited to 'Rx/v2/test/operators/pairwise.cpp')
-rw-r--r--Rx/v2/test/operators/pairwise.cpp42
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);
+ }
+ }
+ }
+}