Preview of clang-format changes and CI

This commit is contained in:
Alexander Grund 2020-09-05 14:37:48 +02:00
parent bfd1701fcb
commit 805e3b02bf
No known key found for this signature in database
GPG key ID: E92C451FC21EF13F
98 changed files with 6339 additions and 11357 deletions

View file

@ -8,31 +8,27 @@
//[ quick_constraint_problem
#define BOOST_AUTO_TEST_MAIN
#include <boost/test/auto_unit_test.hpp>
#include <turtle/mock.hpp>
#include <boost/test/auto_unit_test.hpp>
#include <iostream>
namespace
namespace {
class my_class
{
class my_class
{
public:
explicit my_class( int data )
: data_( data )
{}
int data_;
};
public:
explicit my_class(int data) : data_(data) {}
int data_;
};
std::ostream& operator<<( std::ostream& os, const my_class& c ) // my_class is serializable to an std::ostream
{
return os << "my_class( " << c.data_ << " )";
}
MOCK_CLASS( my_mock )
{
MOCK_METHOD( method, 1, void( const my_class& ) ) // how to simply write a custom constraint ?
};
std::ostream& operator<<(std::ostream& os, const my_class& c) // my_class is serializable to an std::ostream
{
return os << "my_class( " << c.data_ << " )";
}
MOCK_CLASS(my_mock){
MOCK_METHOD(method, 1, void(const my_class&)) // how to simply write a custom constraint ?
};
} // namespace
//]
//[ quick_constraint_solution
@ -40,16 +36,19 @@ namespace
namespace // in the same namespace as 'my_class'
{
bool operator==( const my_class& actual, const std::string& expected ) // the first part of the trick is to compare to a string
{
return boost::lexical_cast< std::string >( actual ) == expected;
}
} // mock
bool operator==(const my_class& actual,
const std::string& expected) // the first part of the trick is to compare to a string
{
return boost::lexical_cast<std::string>(actual) == expected;
}
} // namespace
BOOST_AUTO_TEST_CASE( method_is_called )
BOOST_AUTO_TEST_CASE(method_is_called)
{
my_mock mock;
MOCK_EXPECT( mock.method ).once().with( "my_class( 42 )" ); // the second part of the trick is to express the constraint as a string
mock.method( my_class( 42 ) );
MOCK_EXPECT(mock.method)
.once()
.with("my_class( 42 )"); // the second part of the trick is to express the constraint as a string
mock.method(my_class(42));
}
//]