summaryrefslogtreecommitdiff
path: root/Rx/v2/test/sources/empty.cpp
blob: a57be9f3d81d3e8892979ba403147e1579d1d0c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "../test.h"

SCENARIO("empty emits no items", "[empty][sources]"){
    GIVEN("an empty source"){
        auto sc = rxsc::make_test();
        auto w = sc.create_worker();
        const rxsc::test::messages<int> on;

        WHEN("created"){

            auto res = w.start(
                []() {
                    return rx::observable<>::empty<int>()
                        // forget type to workaround lambda deduction bug on msvc 2013
                        .as_dynamic();
                }
            );

            THEN("the output only contains the completion message"){
                auto required = rxu::to_vector({
                    on.completed(200)
                });
                auto actual = res.get_observer().messages();
                REQUIRE(required == actual);
            }

        }
    }
}

SCENARIO("empty emits no items (rx::sources)", "[empty][sources]"){
    GIVEN("an empty source"){
        auto sc = rxsc::make_test();
        auto w = sc.create_worker();
        const rxsc::test::messages<int> on;

        WHEN("created"){
            using namespace rx::sources;

            auto res = w.start(
                    []() {
                        return empty<int>()
                                // forget type to workaround lambda deduction bug on msvc 2013
                                .as_dynamic();
                    }
            );

            THEN("the output only contains the completion message"){
                auto required = rxu::to_vector({
                                                       on.completed(200)
                                               });
                auto actual = res.get_observer().messages();
                REQUIRE(required == actual);
            }

        }
    }
}