-
Notifications
You must be signed in to change notification settings - Fork 10
/
event_emitter.cpp
37 lines (32 loc) · 934 Bytes
/
event_emitter.cpp
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
//
// Copyright (C) 2020-2023 Krylov Yaroslav.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#include "ureact/utility/event_emitter.hpp"
#include <algorithm>
#include "catch2_extra.hpp"
TEST_CASE( "ureact::event_emitter<E>" )
{
std::vector<int> data;
ureact::event_emitter<int> emitter{ data };
auto _2 = 2;
SECTION( "operator =" )
{
emitter = 1; // R-value
emitter = _2; // L-value
}
SECTION( "stream" )
{
emitter << 1 // R-value
<< _2; // L-value
}
SECTION( "stl iterator" )
{
std::generate_n( emitter, 1, [] { return 1; } ); // R-value
std::generate_n( emitter, 1, [&]() -> const int& { return _2; } ); // L-value
}
CHECK( data == std::vector<int>{ 1, 2 } );
}