summaryrefslogtreecommitdiff
path: root/Rx/v2/test/sources
diff options
context:
space:
mode:
authorKirk Shoop <kirk.shoop@microsoft.com>2014-07-29 07:39:29 -0700
committerKirk Shoop <kirk.shoop@microsoft.com>2014-07-29 10:48:56 -0700
commit0caa97f932c4b96a5964d5c22076634e9fadb1a7 (patch)
treeee34718ed4dabbadff5895960ad365e9a48bac5d /Rx/v2/test/sources
parenta5f53c4efff956d9f3c7232b23711dddc7f44612 (diff)
downloadRxCpp-0caa97f932c4b96a5964d5c22076634e9fadb1a7.tar.gz
add create and print. redo lift.
arrrggg pulled a thread in lift and it unravelled..
Diffstat (limited to 'Rx/v2/test/sources')
-rw-r--r--Rx/v2/test/sources/create.cpp46
-rw-r--r--Rx/v2/test/sources/defer.cpp2
-rw-r--r--Rx/v2/test/sources/interval.cpp6
3 files changed, 50 insertions, 4 deletions
diff --git a/Rx/v2/test/sources/create.cpp b/Rx/v2/test/sources/create.cpp
new file mode 100644
index 0000000..063ff7e
--- /dev/null
+++ b/Rx/v2/test/sources/create.cpp
@@ -0,0 +1,46 @@
+#include "rxcpp/rx.hpp"
+namespace rx=rxcpp;
+namespace rxu=rxcpp::util;
+namespace rxsc=rxcpp::schedulers;
+
+#include "rxcpp/rx-test.hpp"
+#include "catch.hpp"
+
+SCENARIO("create stops on completion", "[create][sources]"){
+ GIVEN("a test cold observable of ints"){
+ auto sc = rxsc::make_test();
+ auto w = sc.create_worker();
+ const rxsc::test::messages<int> on;
+
+ long invoked = 0;
+
+ WHEN("created"){
+
+ auto res = w.start(
+ [&]() {
+ return rx::observable<>::create<int>(
+ [&](const rx::subscriber<int>& s){
+ invoked++;
+ s.on_next(1);
+ s.on_next(2);
+ })
+ // forget type to workaround lambda deduction bug on msvc 2013
+ .as_dynamic();
+ }
+ );
+
+ THEN("the output contains all items"){
+ auto required = rxu::to_vector({
+ on.on_next(200, 1),
+ on.on_next(200, 2)
+ });
+ auto actual = res.get_observer().messages();
+ REQUIRE(required == actual);
+ }
+
+ THEN("create was called until completed"){
+ REQUIRE(1 == invoked);
+ }
+ }
+ }
+}
diff --git a/Rx/v2/test/sources/defer.cpp b/Rx/v2/test/sources/defer.cpp
index bf4779e..e9e62c2 100644
--- a/Rx/v2/test/sources/defer.cpp
+++ b/Rx/v2/test/sources/defer.cpp
@@ -6,7 +6,7 @@ namespace rxsc=rxcpp::schedulers;
#include "rxcpp/rx-test.hpp"
#include "catch.hpp"
-SCENARIO("defer stops on completion", "[defer][operators]"){
+SCENARIO("defer stops on completion", "[defer][sources]"){
GIVEN("a test cold observable of ints"){
auto sc = rxsc::make_test();
auto w = sc.create_worker();
diff --git a/Rx/v2/test/sources/interval.cpp b/Rx/v2/test/sources/interval.cpp
index 49d68e2..ae1a149 100644
--- a/Rx/v2/test/sources/interval.cpp
+++ b/Rx/v2/test/sources/interval.cpp
@@ -7,7 +7,7 @@ namespace rxsc=rxcpp::schedulers;
#include "catch.hpp"
-SCENARIO("schedule_periodically", "[hide][periodically][scheduler][long][perf]"){
+SCENARIO("schedule_periodically", "[hide][periodically][scheduler][long][perf][sources]"){
GIVEN("schedule_periodically"){
WHEN("the period is 1sec and the initial is 2sec"){
using namespace std::chrono;
@@ -29,7 +29,7 @@ SCENARIO("schedule_periodically", "[hide][periodically][scheduler][long][perf]")
}
}
-SCENARIO("schedule_periodically by duration", "[hide][periodically][scheduler][long][perf]"){
+SCENARIO("schedule_periodically by duration", "[hide][periodically][scheduler][long][perf][sources]"){
GIVEN("schedule_periodically_duration"){
WHEN("the period is 1sec and the initial is 2sec"){
using namespace std::chrono;
@@ -72,7 +72,7 @@ SCENARIO("schedule_periodically by duration", "[hide][periodically][scheduler][l
}
}
-SCENARIO("intervals", "[hide][periodically][interval][scheduler][long][perf]"){
+SCENARIO("intervals", "[hide][periodically][interval][scheduler][long][perf][sources]"){
GIVEN("10 intervals of 1 seconds"){
WHEN("the period is 1sec and the initial is 2sec"){
using namespace std::chrono;