mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Improve tests
- Check callability of function.expect.with(...) - Check serialization of MOCK_CONSTRAINT - Actually test some variations of MOCK_CONSTRAINT usages - Add more test for unique_ptr (move-only class) - Remove redundant stuff from test_log and change a few values to catch mistakes - Add test for *-matcher serialization
This commit is contained in:
parent
50ea9982ed
commit
1a81536f3c
5 changed files with 168 additions and 50 deletions
|
|
@ -8,16 +8,39 @@
|
|||
|
||||
#include <turtle/constraint.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
namespace {
|
||||
MOCK_CONSTRAINT(constraint_0, actual == 0)
|
||||
MOCK_CONSTRAINT(constraint_1, expected, actual == expected)
|
||||
MOCK_CONSTRAINT(constraint_2, expected_0, expected_1, actual == expected_0 || actual == expected_1)
|
||||
|
||||
template<typename T>
|
||||
std::string to_string(const mock::constraint<T>& t)
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << t.c_;
|
||||
return s.str();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
BOOST_AUTO_TEST_CASE(mock_constraint_is_supported_by_compilers_with_variadic_macros)
|
||||
BOOST_AUTO_TEST_CASE(mock_constraint_works_for_0_to_2_args)
|
||||
{
|
||||
BOOST_CHECK(constraint_0.c_(0));
|
||||
BOOST_CHECK(constraint_1(0).c_(0));
|
||||
BOOST_CHECK(constraint_2(0, 0).c_(0));
|
||||
BOOST_TEST(constraint_0.c_(0));
|
||||
BOOST_TEST(!constraint_0.c_(42));
|
||||
|
||||
BOOST_TEST(constraint_1(0).c_(0));
|
||||
BOOST_TEST(!constraint_1(1).c_(0));
|
||||
BOOST_TEST(!constraint_1(42).c_(1337));
|
||||
|
||||
BOOST_TEST(constraint_2(42, 1337).c_(42));
|
||||
BOOST_TEST(constraint_2(42, 1337).c_(1337));
|
||||
BOOST_TEST(!constraint_2(42, 1337).c_(99));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(mock_constraint_outputs_human_readable_representation)
|
||||
{
|
||||
BOOST_TEST(to_string(constraint_0) == "constraint_0");
|
||||
BOOST_TEST(to_string(constraint_1(42)) == "constraint_1( 42 )");
|
||||
BOOST_TEST(to_string(constraint_2(42, 1337)) == "constraint_2( 42, 1337 )");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue