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,68 +7,66 @@
// http://www.boost.org/LICENSE_1_0.txt)
//[ async_call_problem
namespace mock_test
namespace mock_test {
class base_class
{
class base_class
{
public:
virtual void method() = 0;
};
public:
virtual void method() = 0;
};
class my_class
{
base_class& b;
public:
explicit my_class( base_class& );
class my_class
{
base_class& b;
void flush(); // repetitively calling this method will in turn call base_class::method at some point
};
}
public:
explicit my_class(base_class&);
void flush(); // repetitively calling this method will in turn call base_class::method at some point
};
} // namespace mock_test
//]
namespace mock_test
namespace mock_test {
my_class::my_class(base_class& b) : b(b) {}
void my_class::flush()
{
my_class::my_class( base_class& b): b(b){}
void my_class::flush()
{
static int counter = 7;
if(--counter == 0)
b.method();
}
static int counter = 7;
if(--counter == 0)
b.method();
}
} // namespace mock_test
//[ async_call_solution
#include <turtle/mock.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
#include <turtle/mock.hpp>
namespace mock_test
namespace mock_test {
template<typename F>
void check(bool& condition, F flush, int attempts = 100, int sleep = 100)
{
template< typename F >
void check( bool& condition, F flush, int attempts = 100, int sleep = 100 )
while(!condition && attempts > 0)
{
while( !condition && attempts > 0 )
{
--attempts;
boost::this_thread::sleep( boost::posix_time::milliseconds( sleep ) );
flush();
}
--attempts;
boost::this_thread::sleep(boost::posix_time::milliseconds(sleep));
flush();
}
}
MOCK_BASE_CLASS( mock_base_class, base_class )
{
MOCK_METHOD( method, 0 )
};
MOCK_BASE_CLASS(mock_base_class, base_class)
{
MOCK_METHOD(method, 0)
};
BOOST_AUTO_TEST_CASE( method_is_called )
BOOST_AUTO_TEST_CASE(method_is_called)
{
mock_base_class m;
my_class c( m );
my_class c(m);
bool done = false;
MOCK_EXPECT( m.method ).once().calls( [&done](){ done = true; } );
check( done, [&c](){ c.flush(); } ); // just wait on done, flushing from time to time
MOCK_EXPECT(m.method).once().calls([&done]() { done = true; });
check(done, [&c]() { c.flush(); }); // just wait on done, flushing from time to time
}
}
} // namespace mock_test
//]