Skip to content

Commit

Permalink
Add some more cases for the serialization test of expectations
Browse files Browse the repository at this point in the history
Make sure the various constraint names/values are kept (they are stored type-erased!)
  • Loading branch information
Flamefire committed Feb 9, 2022
1 parent cdfa1c9 commit c4d6ee2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions test/detail/test_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -750,11 +750,18 @@ BOOST_FIXTURE_TEST_CASE(expectation_can_be_serialized_to_be_human_readable, mock
{
mock::detail::function<void(int)> f;
f.expect().once().with(1);
f.expect().once().with(2);
f.expect().once().with(mock::close(3, 1));
int target = 0;
f.expect().once().with(mock::retrieve(target));
f.expect().once().with(mock::same(target));
BOOST_CHECK_NO_THROW(f(2));
const std::string expected = "?\n"
". once().with( 1 )\n"
"v once().with( 2 )";
std::string expected = "?\n"; // Not in a current call context
expected += ". once().with( 1 )\n"; // Unmet/Unverified expectation with value
expected += "v once().with( close( 3, 1 ) )\n"; // Verified expectation with constraint
target = 42;
// (Unverified) expectation with retrieve/same constraint print current value
expected += ". once().with( retrieve( 42 ) )\n";
expected += ". once().with( same( 42 ) )";
BOOST_CHECK_EQUAL(expected, to_string(f));
CHECK_CALLS(1);
f.reset();
Expand Down

0 comments on commit c4d6ee2

Please sign in to comment.