-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathconnection_user_data_test.cpp
37 lines (33 loc) · 1 KB
/
connection_user_data_test.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) 2015-2021 Emil Dotchevski and Reverge Studios, Inc.
//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 <boost/synapse/connect.hpp>
#include <boost/synapse/connection.hpp>
#include "boost/core/lightweight_test.hpp"
namespace synapse=boost::synapse;
namespace
{
struct my_emitter_type { };
typedef struct my_signal_(*my_signal)();
void noop()
{
}
}
int main( int argc, char const * argv[] )
{
{
my_emitter_type e;
std::shared_ptr<synapse::connection> c=synapse::connect<my_signal>(&e,&noop);
BOOST_TEST(!c->get_user_data<int>());
c->set_user_data(42);
BOOST_TEST_EQ(*c->get_user_data<int>(), 42);
}
{
auto e = std::make_shared<my_emitter_type>();
std::shared_ptr<synapse::pconnection> c=synapse::connect<my_signal>(e,&noop).lock();
BOOST_TEST(!c->get_user_data<int>());
c->set_user_data(42);
BOOST_TEST_EQ(*c->get_user_data<int>(), 42);
}
return boost::report_errors();
}