15 #include <gtest/gtest.h> 17 #include "../../include/ecl/sigslots/signal.hpp" 18 #include "../../include/ecl/sigslots/slot.hpp" 45 A() : f_count(0), g_count(0) {}
47 void f(
const int &i) {
62 static int f_count = 0;
63 static int g_count = 0;
85 using namespace ecl::sigslots::tests;
94 TEST(SigSlotsTests, voidSigSlots) {
99 Slot<> slot_void0(
g,
"void_test");
100 Slot<> slot_void1(&A::g,a);
104 slot_void1.
connect(
"void_test");
112 EXPECT_EQ(1,a.g_count);
113 EXPECT_EQ(1,g_count);
126 sig_relay.
connect(
"final_goal");
127 slot_relayed_goal.
connect(
"final_goal");
132 EXPECT_EQ(2,g_count);
135 TEST(SigSlotsTests,dataSigSlots) {
149 EXPECT_EQ(1,a.f_count);
150 EXPECT_EQ(1,f_count);
153 TEST(SigSlotsTests, disconnect) {
163 data_signal.
connect(
"disconnect");
164 data_slot.
connect(
"disconnect");
169 EXPECT_EQ(3,g_count);
170 EXPECT_EQ(2,f_count);
177 int main(
int argc,
char **argv) {
179 testing::InitGoogleTest(&argc,argv);
180 return RUN_ALL_TESTS();
void connectAsSlot(const std::string &topic)
Connect as a slot, with the emit function loaded.
int main(int argc, char **argv)
void connect(const std::string &topic)
Make a connection to the specified topic.
void disconnect()
Disconnect the slot from all topics.
TEST(SigSlotsTests, voidSigSlots)
void f(int i) ecl_debug_throw_decl(StandardException)
Signalling component of a callback system.
void connect(const std::string &topic)
Make a connection to the specified topic.
void emit(Data data)
The primary purpose of the signal, to emit!
Function loading component of a callback system.