mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Format code using Clang-Format 10 and enforce via CI
Makes the format of the code base uniform.
This commit is contained in:
parent
b5bb500bd2
commit
ee72e8b9d8
97 changed files with 11189 additions and 10842 deletions
|
|
@ -9,110 +9,115 @@
|
|||
#include <turtle/detail/is_functor.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning( push, 0 )
|
||||
# pragma warning(push, 0)
|
||||
#endif
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/phoenix/phoenix.hpp>
|
||||
#ifdef BOOST_MSVC
|
||||
#pragma warning( pop )
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/bind/bind.hpp>
|
||||
#include <boost/bind/placeholders.hpp>
|
||||
#include <boost/function.hpp>
|
||||
#include <boost/version.hpp>
|
||||
#include <functional>
|
||||
|
||||
namespace
|
||||
namespace {
|
||||
struct declared_but_not_defined;
|
||||
static_assert(!mock::detail::is_functor<declared_but_not_defined, int>::value, "Should not be a functor");
|
||||
|
||||
template<typename T>
|
||||
void is_functor(T)
|
||||
{
|
||||
struct declared_but_not_defined;
|
||||
static_assert( !mock::detail::is_functor< declared_but_not_defined, int >::value, "Should not be a functor" );
|
||||
|
||||
template< typename T >
|
||||
void is_functor( T )
|
||||
{
|
||||
static_assert( mock::detail::is_functor< T, int >::value, "Should be a functor taking an int");
|
||||
}
|
||||
template< typename T >
|
||||
void is_not_functor( T )
|
||||
{
|
||||
static_assert( !mock::detail::is_functor< T, int >::value, "Should not be a functor taking an int" );
|
||||
}
|
||||
|
||||
void f0() {}
|
||||
bool f1( int ) { return false; }
|
||||
bool f2( std::string, int ) { return false; }
|
||||
static_assert(mock::detail::is_functor<T, int>::value, "Should be a functor taking an int");
|
||||
}
|
||||
template<typename T>
|
||||
void is_not_functor(T)
|
||||
{
|
||||
static_assert(!mock::detail::is_functor<T, int>::value, "Should not be a functor taking an int");
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( data_is_not_functor )
|
||||
void f0() {}
|
||||
bool f1(int)
|
||||
{
|
||||
is_not_functor( 42 );
|
||||
return false;
|
||||
}
|
||||
bool f2(std::string, int)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
BOOST_AUTO_TEST_CASE(data_is_not_functor)
|
||||
{
|
||||
is_not_functor(42);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( function_is_functor )
|
||||
BOOST_AUTO_TEST_CASE(function_is_functor)
|
||||
{
|
||||
is_not_functor( f0 );
|
||||
is_functor( f1 );
|
||||
is_not_functor( f2 );
|
||||
is_not_functor(f0);
|
||||
is_functor(f1);
|
||||
is_not_functor(f2);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( function_pointer_is_functor )
|
||||
BOOST_AUTO_TEST_CASE(function_pointer_is_functor)
|
||||
{
|
||||
is_not_functor( &f0 );
|
||||
is_functor( &f1 );
|
||||
is_not_functor( &f2 );
|
||||
is_not_functor(&f0);
|
||||
is_functor(&f1);
|
||||
is_not_functor(&f2);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( std_ptr_fun_is_functor )
|
||||
BOOST_AUTO_TEST_CASE(std_ptr_fun_is_functor)
|
||||
{
|
||||
is_functor( std::ptr_fun( &f1 ) );
|
||||
is_not_functor( std::ptr_fun( &f2 ) );
|
||||
is_functor(std::ptr_fun(&f1));
|
||||
is_not_functor(std::ptr_fun(&f2));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( std_bind_first_is_functor )
|
||||
BOOST_AUTO_TEST_CASE(std_bind_first_is_functor)
|
||||
{
|
||||
is_functor( std::bind1st( std::ptr_fun( &f2 ), "" ) );
|
||||
is_functor(std::bind1st(std::ptr_fun(&f2), ""));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( bind_is_functor )
|
||||
BOOST_AUTO_TEST_CASE(bind_is_functor)
|
||||
{
|
||||
{
|
||||
#if BOOST_VERSION >= 106000
|
||||
using namespace boost::placeholders;
|
||||
#endif
|
||||
is_functor( boost::bind( &f0 ) );
|
||||
is_functor( boost::bind( &f1, _1 ) );
|
||||
is_functor( boost::bind( &f2, "", _1 ) );
|
||||
is_functor(boost::bind(&f0));
|
||||
is_functor(boost::bind(&f1, _1));
|
||||
is_functor(boost::bind(&f2, "", _1));
|
||||
}
|
||||
is_functor( std::bind( &f0 ) );
|
||||
is_functor( std::bind( &f1, std::placeholders::_1 ) );
|
||||
is_functor( std::bind( &f2, "", std::placeholders::_1 ) );
|
||||
is_functor(std::bind(&f0));
|
||||
is_functor(std::bind(&f1, std::placeholders::_1));
|
||||
is_functor(std::bind(&f2, "", std::placeholders::_1));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( boost_lambda_is_functor )
|
||||
BOOST_AUTO_TEST_CASE(boost_lambda_is_functor)
|
||||
{
|
||||
is_functor( boost::lambda::_1 < 42 );
|
||||
is_functor(boost::lambda::_1 < 42);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( boost_phoenix_is_functor )
|
||||
BOOST_AUTO_TEST_CASE(boost_phoenix_is_functor)
|
||||
{
|
||||
is_functor( boost::phoenix::arg_names::arg1 < 42 );
|
||||
is_functor( boost::phoenix::arg_names::_1 < 42 );
|
||||
is_functor(boost::phoenix::arg_names::arg1 < 42);
|
||||
is_functor(boost::phoenix::arg_names::_1 < 42);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( boost_function_is_functor )
|
||||
BOOST_AUTO_TEST_CASE(boost_function_is_functor)
|
||||
{
|
||||
is_functor( boost::function< void(int) >() );
|
||||
is_functor(boost::function<void(int)>());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( std_function_is_functor )
|
||||
BOOST_AUTO_TEST_CASE(std_function_is_functor)
|
||||
{
|
||||
is_functor( std::function< void(int) >() );
|
||||
is_functor(std::function<void(int)>());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( cxx11_lambda_is_functor )
|
||||
BOOST_AUTO_TEST_CASE(cxx11_lambda_is_functor)
|
||||
{
|
||||
is_not_functor( []() {} );
|
||||
is_functor( []( int ) {} );
|
||||
is_not_functor( []( const std::string&, int ) {} );
|
||||
is_not_functor( []( int, const std::string& ) {} );
|
||||
is_not_functor([]() {});
|
||||
is_functor([](int) {});
|
||||
is_not_functor([](const std::string&, int) {});
|
||||
is_not_functor([](int, const std::string&) {});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue