diff --git a/README.md b/README.md index 0bbd40d..98b848c 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/Signal_Test/src/signaltests.cpp b/Signal_Test/src/signaltests.cpp index 5a4c022..65ebebb 100644 --- a/Signal_Test/src/signaltests.cpp +++ b/Signal_Test/src/signaltests.cpp @@ -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;