示例#1
0
文件: repeat.cpp 项目: gamako/RxCpp
#include "rxcpp/rx.hpp"
namespace rxu=rxcpp::util;
namespace rxsc=rxcpp::schedulers;

#include "rxcpp/rx-test.hpp"
#include "catch.hpp"

SCENARIO("repeat, basic test", "[repeat][operators]"){
    GIVEN("cold observable of 3 ints."){
        auto sc = rxsc::make_test();
        auto w = sc.create_worker();
        const rxsc::test::messages<int> on;

        auto xs = sc.make_cold_observable({
            on.on_next(100, 1),
            on.on_next(150, 2),
            on.on_next(200, 3),
            on.on_completed(250)
        });

        WHEN("infinite repeat is launched"){

            auto res = w.start(
                [&]() {
                    return xs
                        .repeat()
                        // forget type to workaround lambda deduction bug on msvc 2013
                        .as_dynamic();
                }
            );
示例#2
0
文件: filter.cpp 项目: gamako/RxCpp
            return false;
    }
    return true;
}
}

SCENARIO("filter stops on completion", "[filter][operators]"){
    GIVEN("a test hot observable of ints"){
        auto sc = rxsc::make_test();
        auto w = sc.create_worker();
        const rxsc::test::messages<int> on;

        long invoked = 0;

        auto xs = sc.make_hot_observable({
            on.on_next(110, 1),
            on.on_next(180, 2),
            on.on_next(230, 3),
            on.on_next(270, 4),
            on.on_next(340, 5),
            on.on_next(380, 6),
            on.on_next(390, 7),
            on.on_next(450, 8),
            on.on_next(470, 9),
            on.on_next(560, 10),
            on.on_next(580, 11),
            on.on_completed(600),
            on.on_next(610, 12),
            on.on_error(620, std::runtime_error("error in unsubscribed stream")),
            on.on_completed(630)
        });
示例#3
0
namespace rxu=rxcpp::util;
namespace rxsc=rxcpp::schedulers;
namespace rxn=rx::notifications;

#include "rxcpp/rx-test.hpp"
#include "catch.hpp"

SCENARIO("switch_on_next - some changes", "[switch_on_next][operators]"){
    GIVEN("a source"){
        auto sc = rxsc::make_test();
        auto w = sc.create_worker();
        const rxsc::test::messages<int> on;
        const rxsc::test::messages<rx::observable<int>> o_on;

        auto ys1 = sc.make_cold_observable({
            on.on_next(10, 101),
            on.on_next(20, 102),
            on.on_next(110, 103),
            on.on_next(120, 104),
            on.on_next(210, 105),
            on.on_next(220, 106),
            on.on_completed(230)
        });

        auto ys2 = sc.make_cold_observable({
            on.on_next(10, 201),
            on.on_next(20, 202),
            on.on_next(30, 203),
            on.on_next(40, 204),
            on.on_completed(50)
        });