Remove fixture of tests in test_matcher

The fixture is not really required and can be replaced by definitions in
each test which even improves readability.
Also the tests are partially redundant due to implicit conversions so
add test in test_function for actual usage testing of string comparisons.
This commit is contained in:
Alexander Grund 2023-01-03 18:13:00 +01:00
parent fa29eec0bb
commit 700ceb9f4d
No known key found for this signature in database
GPG key ID: AA48A0760367A42B
2 changed files with 63 additions and 20 deletions

View file

@ -158,6 +158,56 @@ BOOST_FIXTURE_TEST_CASE(triggering_several_once_expectations_is_valid, mock_erro
}
}
BOOST_FIXTURE_TEST_CASE(string_likes_are_matched, mock_error_fixture)
{
const char* c_string = "value";
const char c_string2[] = "value";
BOOST_REQUIRE(c_string != c_string2); // Different pointers
const std::string string = c_string;
{
mock::detail::function<void(std::string)> f;
f.expect().once().with(string);
f(string);
BOOST_TEST(f.verify());
f.reset();
f.expect().once().with(c_string);
f(string);
BOOST_TEST(f.verify());
f.reset();
f.expect().once().with(c_string2);
f(string);
BOOST_TEST(f.verify());
CHECK_CALLS(3);
}
{
mock::detail::function<void(const char*)> f;
f.expect().once().with(c_string);
f(c_string);
BOOST_TEST(f.verify());
f.reset();
f.expect().once().with(c_string);
f(c_string2);
BOOST_TEST(f.verify());
f.reset();
f.expect().once().with(c_string2);
f(c_string);
BOOST_TEST(f.verify());
f.reset();
f.expect().once().with(string);
f(c_string);
BOOST_TEST(f.verify());
CHECK_CALLS(4);
}
}
BOOST_FIXTURE_TEST_CASE(triggering_a_once_expectation_calls_unexpected_call_error_after_one_call, mock_error_fixture)
{
{