From 600f6b46c28b4dccbf61f79ffc867dd4a64ab68d Mon Sep 17 00:00:00 2001 From: FranckRJ Date: Fri, 10 May 2024 00:00:49 +0200 Subject: [PATCH] Add a test with two mocks created from the same function. --- tests/moving_mocks_around.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/tests/moving_mocks_around.cpp b/tests/moving_mocks_around.cpp index 430e99c5..4a0a778c 100644 --- a/tests/moving_mocks_around.cpp +++ b/tests/moving_mocks_around.cpp @@ -18,8 +18,9 @@ struct MovingMocksAround : tpunit::TestFixture TestFixture( TEST(MovingMocksAround::move_mock), TEST(MovingMocksAround::move_mock_then_delete), - TEST(MovingMocksAround::create_mock_from_function) - ) + TEST(MovingMocksAround::create_mock_from_function), + TEST(MovingMocksAround::create_multiple_mocks_from_function) + ) { } @@ -80,4 +81,21 @@ struct MovingMocksAround : tpunit::TestFixture Verify(Method(mock, function).Using(paramString)).Exactly(1); } + void create_multiple_mocks_from_function() + { + const std::string paramString1 = "long param 1 string to not be in SSO ---------------------------------------"; + const std::string returnedString1 = "long returned 1 string to not be in SSO ---------------------------------"; + const std::string paramString2 = "long param 2 string to not be in SSO ---------------------------------------"; + const std::string returnedString2 = "long returned 2 string to not be in SSO ---------------------------------"; + + Mock mock1 = createMock(returnedString1); + Mock mock2 = createMock(returnedString2); + + EXPECT_EQUAL(mock1.get().function(paramString1), returnedString1); + EXPECT_EQUAL(mock2.get().function(paramString2), returnedString2); + + Verify(Method(mock1, function).Using(paramString1)).Exactly(1); + Verify(Method(mock2, function).Using(paramString2)).Exactly(1); + } + } __MovingMocksAround;