Format code using Clang-Format 10 and enforce via CI

Makes the format of the code base uniform.
This commit is contained in:
Alexander Grund 2022-01-24 16:11:29 +01:00
parent b5bb500bd2
commit ee72e8b9d8
No known key found for this signature in database
GPG key ID: AA48A0760367A42B
97 changed files with 11189 additions and 10842 deletions

View file

@ -7,55 +7,59 @@
// http://www.boost.org/LICENSE_1_0.txt)
//[ retrieve_cref_problem
namespace
namespace {
class base_class
{
class base_class
{
public:
virtual void method( int value ) = 0;
};
public:
virtual void method(int value) = 0;
};
class my_class
{
public:
explicit my_class( base_class& );
class my_class
{
public:
explicit my_class(base_class&);
void process(); // the processing will call 'method' two times with the same value, but we don't know what value beforehand
};
}
void process(); // the processing will call 'method' two times with the same value, but we don't know what value
// beforehand
};
} // namespace
//]
namespace
namespace {
static base_class* global_b = nullptr;
my_class::my_class(base_class& b)
{
static base_class* global_b = nullptr;
my_class::my_class( base_class& b){ global_b = &b; }
void my_class::process()
{
int secret_value = 42;
global_b->method(secret_value);
global_b->method(secret_value);
}
global_b = &b;
}
void my_class::process()
{
int secret_value = 42;
global_b->method(secret_value);
global_b->method(secret_value);
}
} // namespace
//[ retrieve_cref_solution
#include <boost/test/unit_test.hpp>
#include <turtle/mock.hpp>
#include <boost/test/unit_test.hpp>
namespace
namespace {
MOCK_BASE_CLASS(mock_base_class, base_class)
{
MOCK_BASE_CLASS( mock_base_class, base_class )
{
MOCK_METHOD( method, 1 )
};
}
MOCK_METHOD(method, 1)
};
} // namespace
BOOST_AUTO_TEST_CASE( method_is_called_two_times_with_the_same_value )
BOOST_AUTO_TEST_CASE(method_is_called_two_times_with_the_same_value)
{
mock_base_class mock;
my_class c( mock );
my_class c(mock);
int value;
MOCK_EXPECT( mock.method ).once().with( mock::retrieve( value ) ); // on first call retrieve the value, this expectation takes precedence because it can never fail
MOCK_EXPECT( mock.method ).once().with( std::cref( value ) ); // on second call compare the previously retrieved value with the newly received one
MOCK_EXPECT(mock.method).once().with(mock::retrieve(value)); // on first call retrieve the value, this expectation
// takes precedence because it can never fail
MOCK_EXPECT(mock.method)
.once()
.with(std::cref(value)); // on second call compare the previously retrieved value with the newly received one
c.process();
}
//]