Skip to content

Commit

Permalink
Merge pull request #1184 from lairworks/fixSignalUnitTestUndefinedBeh…
Browse files Browse the repository at this point in the history
…avior

Fix `Signal` unit test undefined behavior (`gmock`)
  • Loading branch information
DanRStevens authored Jan 2, 2025
2 parents ab73d3d + 9e58ab1 commit f3614d4
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions test/Signal/Signal.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,38 @@ namespace {
}


TEST(Signal, ConnectEmitDisconnect) {
MockHandler handler{};
auto delegate = NAS2D::Delegate{&handler, &MockHandler::MockMethod};
TEST(Signal, InitEmpty) {
NAS2D::Signal<> signal;

EXPECT_TRUE(signal.empty());
}

TEST(Signal, ConnectNonEmpty) {
NAS2D::Signal<> signal;
MockHandler handler{};
auto delegate = NAS2D::Delegate{&handler, &MockHandler::MockMethod};

signal.connect(delegate);
EXPECT_FALSE(signal.empty());
}

EXPECT_CALL(handler, MockMethod());
signal.emit();
TEST(Signal, DisconnectEmpty) {
NAS2D::Signal<> signal;
MockHandler handler{};
auto delegate = NAS2D::Delegate{&handler, &MockHandler::MockMethod};

signal.connect(delegate);
signal.disconnect(delegate);
EXPECT_TRUE(signal.empty());
}

TEST(Signal, ConnectEmitDisconnect) {
NAS2D::Signal<> signal;
MockHandler handler{};
auto delegate = NAS2D::Delegate{&handler, &MockHandler::MockMethod};

EXPECT_CALL(handler, MockMethod()).Times(0);
EXPECT_CALL(handler, MockMethod()).Times(1);
signal.connect(delegate);
signal.emit();
signal.disconnect(delegate);
signal.emit();
}

0 comments on commit f3614d4

Please sign in to comment.