From 1b23fb68aa42011207f7de79a56ee87fe21deb2d Mon Sep 17 00:00:00 2001 From: Marcus Welander Date: Thu, 11 Jan 2024 21:46:54 +0100 Subject: [PATCH] Add code coverage badge to README And add test case to increase coverage. --- README.md | 2 +- Signal_Test/src/signaltests.cpp | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) 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;