Skip to content

Commit

Permalink
Add code coverage badge to README
Browse files Browse the repository at this point in the history
And add test case to increase coverage.
  • Loading branch information
mwthinker committed Jan 11, 2024
1 parent f3c7b69 commit 1b23fb6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# mw::Signal [![CI build](https://github.com/mwthinker/Signal/actions/workflows/ci.yml/badge.svg)](https://github.com/mwthinker/Signal/actions/workflows/ci.yml)
# mw::Signal [![CI build](https://github.com/mwthinker/Signal/actions/workflows/ci.yml/badge.svg)](https://github.com/mwthinker/Signal/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/mwthinker/Signal/graph/badge.svg?token=6JHBM2BKC4)](https://codecov.io/gh/mwthinker/Signal)

A header only Signal Slot library inspired by the corresponding boost library.

Expand Down
34 changes: 34 additions & 0 deletions Signal_Test/src/signaltests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,40 @@ TEST_F(SignalTest, connectionAdded_thenSignalNotEmpty) {
EXPECT_EQ(1, signal.size());
}

TEST_F(SignalTest, connectionAssignedCopiedAndDisconnected_thenCopiedConnectionIsDisconnected) {
// Given.
mw::Signal signal;

// When.
auto connection = signal.connect(emptyCallback);
EXPECT_TRUE(connection.connected());
mw::signals::Connection copiedConnection;
EXPECT_FALSE(copiedConnection.connected());
copiedConnection = connection;
EXPECT_TRUE(copiedConnection.connected());
copiedConnection.disconnect();

// Then.
EXPECT_FALSE(connection.connected());
EXPECT_FALSE(copiedConnection.connected());
}

TEST_F(SignalTest, connectionConstuctorCopiedAndDisconnected_thenCopiedConnectionIsDisconnected) {
// Given.
mw::Signal signal;

// When.
auto connection = signal.connect(emptyCallback);
EXPECT_TRUE(connection.connected());
mw::signals::Connection copiedConnection = connection;
EXPECT_TRUE(copiedConnection.connected());
copiedConnection.disconnect();

// Then.
EXPECT_FALSE(connection.connected());
EXPECT_FALSE(copiedConnection.connected());
}

TEST_F(SignalTest, connectionsAdded_thenSignalHasCorrectSize) {
// Given.
mw::Signal signal;
Expand Down

0 comments on commit 1b23fb6

Please sign in to comment.