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

@ -12,10 +12,10 @@
#define MOCK_ERROR_POLICY mock_error
#include <turtle/detail/singleton.hpp>
#include <boost/test/unit_test.hpp>
#include <stdexcept>
#include <sstream>
#include <stdexcept>
struct mock_error_data_t : mock::detail::singleton< mock_error_data_t >
struct mock_error_data_t : mock::detail::singleton<mock_error_data_t>
{
void reset()
{
@ -24,10 +24,7 @@ struct mock_error_data_t : mock::detail::singleton< mock_error_data_t >
last_message.clear();
last_context.clear();
}
bool verify()
{
return error_count == 0;
}
bool verify() { return error_count == 0; }
void call()
{
@ -35,9 +32,7 @@ struct mock_error_data_t : mock::detail::singleton< mock_error_data_t >
last_message.clear();
++call_count;
}
void fail( const std::string& message,
const std::string& context,
const char* file, int line )
void fail(const std::string& message, const std::string& context, const char* file, int line)
{
last_context = context;
last_message = message;
@ -52,59 +47,56 @@ struct mock_error_data_t : mock::detail::singleton< mock_error_data_t >
std::string last_context;
std::string last_file;
int last_line;
MOCK_SINGLETON_CONS( mock_error_data_t );
MOCK_SINGLETON_CONS(mock_error_data_t);
};
MOCK_SINGLETON_INST( mock_error_data )
MOCK_SINGLETON_INST(mock_error_data)
template< typename Result >
template<typename Result>
struct mock_error
{
static Result abort()
{
throw std::runtime_error( "aborted" );
}
static Result abort() { throw std::runtime_error("aborted"); }
static void pass( const char* /*file*/, int /*line*/ )
{}
static void pass(const char* /*file*/, int /*line*/) {}
template< typename Context >
static void call( const Context& /*context*/, const char* /*file*/, int /*line*/ )
template<typename Context>
static void call(const Context& /*context*/, const char* /*file*/, int /*line*/)
{
mock_error_data.call();
}
template< typename Context >
static void fail( const std::string& message, const Context& context, const char* file = "", int line = 0 )
template<typename Context>
static void fail(const std::string& message, const Context& context, const char* file = "", int line = 0)
{
std::ostringstream s;
s << context; // Context can be streamed
mock_error_data.fail( message, s.str(), file, line );
mock_error_data.fail(message, s.str(), file, line);
}
};
struct mock_error_fixture
{
mock_error_fixture()
{
mock_error_data.reset();
}
mock_error_fixture() { mock_error_data.reset(); }
~mock_error_fixture()
{
BOOST_CHECK( mock_error_data.verify() );
BOOST_CHECK_EQUAL( 0, mock_error_data.call_count );
BOOST_CHECK(mock_error_data.verify());
BOOST_CHECK_EQUAL(0, mock_error_data.call_count);
}
};
#define CHECK_CALLS( calls ) \
BOOST_CHECK_EQUAL( calls, mock_error_data.call_count ); \
#define CHECK_CALLS(calls) \
BOOST_CHECK_EQUAL(calls, mock_error_data.call_count); \
mock_error_data.call_count = 0;
#define CHECK_ERROR( expr, error, calls, context ) \
BOOST_CHECK( mock_error_data.verify() ); \
try { expr; } catch( ... ) {} \
BOOST_CHECK_EQUAL( 1, mock_error_data.error_count ); \
BOOST_CHECK_EQUAL( error, mock_error_data.last_message ); \
BOOST_CHECK_EQUAL( context, mock_error_data.last_context ); \
CHECK_CALLS( calls ); \
#define CHECK_ERROR(expr, error, calls, context) \
BOOST_CHECK(mock_error_data.verify()); \
try \
{ \
expr; \
} catch(...) \
{} \
BOOST_CHECK_EQUAL(1, mock_error_data.error_count); \
BOOST_CHECK_EQUAL(error, mock_error_data.last_message); \
BOOST_CHECK_EQUAL(context, mock_error_data.last_context); \
CHECK_CALLS(calls); \
mock_error_data.reset();
#endif // MOCK_TEST_MOCK_ERROR_HPP_INCLUDED