From c4d6ee2da6d332f068b191f2ffac49c58d149aec Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Wed, 9 Feb 2022 15:23:14 +0100 Subject: [PATCH] Add some more cases for the serialization test of expectations Make sure the various constraint names/values are kept (they are stored type-erased!) --- test/detail/test_function.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/test/detail/test_function.cpp b/test/detail/test_function.cpp index 1e0706e4..69ded5f8 100644 --- a/test/detail/test_function.cpp +++ b/test/detail/test_function.cpp @@ -750,11 +750,18 @@ BOOST_FIXTURE_TEST_CASE(expectation_can_be_serialized_to_be_human_readable, mock { mock::detail::function 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();