Skip to content

Commit

Permalink
Add a test with two mocks created from the same function.
Browse files Browse the repository at this point in the history
  • Loading branch information
FranckRJ committed May 9, 2024
1 parent 66ee9cf commit 600f6b4
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/moving_mocks_around.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
{
}

Expand Down Expand Up @@ -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<Interface> mock1 = createMock(returnedString1);
Mock<Interface> 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;

0 comments on commit 600f6b4

Please sign in to comment.