Add some more cases for the serialization test of expectations

Make sure the various constraint names/values are kept (they are stored type-erased!)
This commit is contained in:
Alexander Grund 2022-02-09 15:23:14 +01:00
parent e2687dea1a
commit 23ac665c22
No known key found for this signature in database
GPG key ID: AA48A0760367A42B

View file

@ -751,11 +751,18 @@ BOOST_FIXTURE_TEST_CASE(expectation_can_be_serialized_to_be_human_readable, mock
{ {
mock::detail::function<void(int)> f; mock::detail::function<void(int)> f;
f.expect().once().with(1); 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)); BOOST_CHECK_NO_THROW(f(2));
const std::string expected = "?\n" std::string expected = "?\n"; // Not in a current call context
". once().with( 1 )\n" expected += ". once().with( 1 )\n"; // Unmet/Unverified expectation with value
"v once().with( 2 )"; 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)); BOOST_CHECK_EQUAL(expected, to_string(f));
CHECK_CALLS(1); CHECK_CALLS(1);
f.reset(); f.reset();