Skip to content

Commit

Permalink
Split Signal unit tests (one expectation per test)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanRStevens committed Jan 2, 2025
1 parent 1bfa17b commit 9e58ab1
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions test/Signal/Signal.test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +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(1);
signal.connect(delegate);
signal.emit();
signal.disconnect(delegate);
signal.emit();
}

0 comments on commit 9e58ab1

Please sign in to comment.