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
File diff suppressed because it is too large
Load diff
|
|
@ -9,68 +9,68 @@
|
|||
#include <turtle/detail/invocation.hpp>
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
BOOST_AUTO_TEST_CASE( unlimited )
|
||||
BOOST_AUTO_TEST_CASE(unlimited)
|
||||
{
|
||||
mock::detail::unlimited invocation;
|
||||
BOOST_CHECK( invocation.verify() );
|
||||
BOOST_CHECK( ! invocation.exhausted() );
|
||||
BOOST_CHECK( invocation.invoke() );
|
||||
BOOST_CHECK( invocation.verify() );
|
||||
BOOST_CHECK( ! invocation.exhausted() );
|
||||
BOOST_CHECK( invocation.invoke() );
|
||||
BOOST_CHECK(invocation.verify());
|
||||
BOOST_CHECK(!invocation.exhausted());
|
||||
BOOST_CHECK(invocation.invoke());
|
||||
BOOST_CHECK(invocation.verify());
|
||||
BOOST_CHECK(!invocation.exhausted());
|
||||
BOOST_CHECK(invocation.invoke());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( once )
|
||||
BOOST_AUTO_TEST_CASE(once)
|
||||
{
|
||||
mock::detail::once invocation;
|
||||
BOOST_CHECK( ! invocation.verify() );
|
||||
BOOST_CHECK( ! invocation.exhausted() );
|
||||
BOOST_CHECK( invocation.invoke() );
|
||||
BOOST_CHECK( invocation.verify() );
|
||||
BOOST_CHECK( invocation.exhausted() );
|
||||
BOOST_CHECK( ! invocation.invoke() );
|
||||
BOOST_CHECK(!invocation.verify());
|
||||
BOOST_CHECK(!invocation.exhausted());
|
||||
BOOST_CHECK(invocation.invoke());
|
||||
BOOST_CHECK(invocation.verify());
|
||||
BOOST_CHECK(invocation.exhausted());
|
||||
BOOST_CHECK(!invocation.invoke());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( never )
|
||||
BOOST_AUTO_TEST_CASE(never)
|
||||
{
|
||||
mock::detail::never invocation;
|
||||
BOOST_CHECK( invocation.verify() );
|
||||
BOOST_CHECK( invocation.exhausted() );
|
||||
BOOST_CHECK( ! invocation.invoke() );
|
||||
BOOST_CHECK(invocation.verify());
|
||||
BOOST_CHECK(invocation.exhausted());
|
||||
BOOST_CHECK(!invocation.invoke());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( at_most )
|
||||
BOOST_AUTO_TEST_CASE(at_most)
|
||||
{
|
||||
mock::detail::at_most invocation( 1 );
|
||||
BOOST_CHECK( invocation.verify() );
|
||||
BOOST_CHECK( ! invocation.exhausted() );
|
||||
BOOST_CHECK( invocation.invoke() );
|
||||
BOOST_CHECK( invocation.verify() );
|
||||
BOOST_CHECK( invocation.exhausted() );
|
||||
BOOST_CHECK( ! invocation.invoke() );
|
||||
mock::detail::at_most invocation(1);
|
||||
BOOST_CHECK(invocation.verify());
|
||||
BOOST_CHECK(!invocation.exhausted());
|
||||
BOOST_CHECK(invocation.invoke());
|
||||
BOOST_CHECK(invocation.verify());
|
||||
BOOST_CHECK(invocation.exhausted());
|
||||
BOOST_CHECK(!invocation.invoke());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( at_least )
|
||||
BOOST_AUTO_TEST_CASE(at_least)
|
||||
{
|
||||
mock::detail::at_least invocation( 1 );
|
||||
BOOST_CHECK( ! invocation.verify() );
|
||||
BOOST_CHECK( ! invocation.exhausted() );
|
||||
BOOST_CHECK( invocation.invoke() );
|
||||
BOOST_CHECK( invocation.verify() );
|
||||
BOOST_CHECK( ! invocation.exhausted() );
|
||||
BOOST_CHECK( invocation.invoke() );
|
||||
mock::detail::at_least invocation(1);
|
||||
BOOST_CHECK(!invocation.verify());
|
||||
BOOST_CHECK(!invocation.exhausted());
|
||||
BOOST_CHECK(invocation.invoke());
|
||||
BOOST_CHECK(invocation.verify());
|
||||
BOOST_CHECK(!invocation.exhausted());
|
||||
BOOST_CHECK(invocation.invoke());
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( between )
|
||||
BOOST_AUTO_TEST_CASE(between)
|
||||
{
|
||||
mock::detail::between invocation( 1, 2 );
|
||||
BOOST_CHECK( ! invocation.verify() );
|
||||
BOOST_CHECK( ! invocation.exhausted() );
|
||||
BOOST_CHECK( invocation.invoke() );
|
||||
BOOST_CHECK( invocation.verify() );
|
||||
BOOST_CHECK( ! invocation.exhausted() );
|
||||
BOOST_CHECK( invocation.invoke() );
|
||||
BOOST_CHECK( invocation.verify() );
|
||||
BOOST_CHECK( invocation.exhausted() );
|
||||
BOOST_CHECK( ! invocation.invoke() );
|
||||
mock::detail::between invocation(1, 2);
|
||||
BOOST_CHECK(!invocation.verify());
|
||||
BOOST_CHECK(!invocation.exhausted());
|
||||
BOOST_CHECK(invocation.invoke());
|
||||
BOOST_CHECK(invocation.verify());
|
||||
BOOST_CHECK(!invocation.exhausted());
|
||||
BOOST_CHECK(invocation.invoke());
|
||||
BOOST_CHECK(invocation.verify());
|
||||
BOOST_CHECK(invocation.exhausted());
|
||||
BOOST_CHECK(!invocation.invoke());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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&) {});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,18 +10,17 @@
|
|||
#include <boost/test/unit_test.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace
|
||||
namespace {
|
||||
struct base
|
||||
{
|
||||
struct base
|
||||
{
|
||||
void method_1();
|
||||
float method_2( int ) const;
|
||||
};
|
||||
typedef base base_type;
|
||||
}
|
||||
void method_1();
|
||||
float method_2(int) const;
|
||||
};
|
||||
typedef base base_type;
|
||||
} // namespace
|
||||
|
||||
BOOST_AUTO_TEST_CASE( mock_signature_generates_signature )
|
||||
BOOST_AUTO_TEST_CASE(mock_signature_generates_signature)
|
||||
{
|
||||
static_assert( std::is_same< void(), MOCK_SIGNATURE(method_1) >::value, "!");
|
||||
static_assert( std::is_same< float( int ), MOCK_SIGNATURE(method_2) >::value, "!");
|
||||
static_assert(std::is_same<void(), MOCK_SIGNATURE(method_1)>::value, "!");
|
||||
static_assert(std::is_same<float(int), MOCK_SIGNATURE(method_2)>::value, "!");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,218 +10,216 @@
|
|||
#include <boost/test/unit_test.hpp>
|
||||
#include <sstream>
|
||||
|
||||
namespace
|
||||
namespace {
|
||||
template<typename T>
|
||||
std::string to_string(const T& t)
|
||||
{
|
||||
template< typename T >
|
||||
std::string to_string( const T& t)
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << mock::detail::make_type_name(t);
|
||||
return s.str();
|
||||
}
|
||||
std::ostringstream s;
|
||||
s << mock::detail::make_type_name(t);
|
||||
return s.str();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_base_type_is_extracted )
|
||||
BOOST_AUTO_TEST_CASE(name_of_base_type_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "char", to_string( 'a' ) );
|
||||
BOOST_CHECK_EQUAL( "bool", to_string( true ) );
|
||||
BOOST_CHECK_EQUAL( "int", to_string< int >( 0 ) );
|
||||
BOOST_CHECK_EQUAL( "short", to_string< short >( 0 ) );
|
||||
BOOST_CHECK_EQUAL( "long", to_string< long >( 0 ) );
|
||||
BOOST_CHECK_EQUAL( "unsigned int", to_string< unsigned int >( 0 ) );
|
||||
BOOST_CHECK_EQUAL( "unsigned short", to_string< unsigned short >( 0 ) );
|
||||
BOOST_CHECK_EQUAL( "unsigned long", to_string< unsigned long >( 0 ) );
|
||||
BOOST_CHECK_EQUAL("char", to_string('a'));
|
||||
BOOST_CHECK_EQUAL("bool", to_string(true));
|
||||
BOOST_CHECK_EQUAL("int", to_string<int>(0));
|
||||
BOOST_CHECK_EQUAL("short", to_string<short>(0));
|
||||
BOOST_CHECK_EQUAL("long", to_string<long>(0));
|
||||
BOOST_CHECK_EQUAL("unsigned int", to_string<unsigned int>(0));
|
||||
BOOST_CHECK_EQUAL("unsigned short", to_string<unsigned short>(0));
|
||||
BOOST_CHECK_EQUAL("unsigned long", to_string<unsigned long>(0));
|
||||
}
|
||||
|
||||
struct my_type_in_default_namespace
|
||||
{
|
||||
struct inner {};
|
||||
struct inner
|
||||
{};
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_type_in_default_namespace_is_extracted )
|
||||
BOOST_AUTO_TEST_CASE(name_of_type_in_default_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "my_type_in_default_namespace", to_string( my_type_in_default_namespace() ) );
|
||||
BOOST_CHECK_EQUAL("my_type_in_default_namespace", to_string(my_type_in_default_namespace()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_inner_type_from_type_in_default_namespace_is_extracted )
|
||||
BOOST_AUTO_TEST_CASE(name_of_inner_type_from_type_in_default_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( my_type_in_default_namespace::inner() ) );
|
||||
BOOST_CHECK_EQUAL("inner", to_string(my_type_in_default_namespace::inner()));
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
template<typename T>
|
||||
struct my_template_type_in_default_namespace
|
||||
{
|
||||
struct inner {};
|
||||
struct inner
|
||||
{};
|
||||
};
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_template_type_in_default_namespace_is_extracted )
|
||||
BOOST_AUTO_TEST_CASE(name_of_template_type_in_default_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "my_template_type_in_default_namespace<int>", to_string( my_template_type_in_default_namespace<int>() ) );
|
||||
BOOST_CHECK_EQUAL("my_template_type_in_default_namespace<int>",
|
||||
to_string(my_template_type_in_default_namespace<int>()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_inner_type_from_template_type_in_default_namespace_is_extracted )
|
||||
BOOST_AUTO_TEST_CASE(name_of_inner_type_from_template_type_in_default_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( my_template_type_in_default_namespace<int>::inner() ) );
|
||||
BOOST_CHECK_EQUAL("inner", to_string(my_template_type_in_default_namespace<int>::inner()));
|
||||
}
|
||||
|
||||
namespace
|
||||
namespace {
|
||||
struct my_type_in_anonymous_namespace
|
||||
{};
|
||||
} // namespace
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_type_in_anonymous_namespace_is_extracted)
|
||||
{
|
||||
struct my_type_in_anonymous_namespace {};
|
||||
BOOST_CHECK_EQUAL("my_type_in_anonymous_namespace", to_string(my_type_in_anonymous_namespace()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_type_in_anonymous_namespace_is_extracted )
|
||||
namespace nm {
|
||||
struct my_type_from_named_namespace
|
||||
{};
|
||||
} // namespace nm
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_type_from_named_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "my_type_in_anonymous_namespace", to_string( my_type_in_anonymous_namespace() ) );
|
||||
BOOST_CHECK_EQUAL("my_type_from_named_namespace", to_string(nm::my_type_from_named_namespace()));
|
||||
}
|
||||
|
||||
namespace nm
|
||||
{
|
||||
struct my_type_from_named_namespace {};
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_type_from_named_namespace_is_extracted )
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "my_type_from_named_namespace", to_string( nm::my_type_from_named_namespace() ) );
|
||||
}
|
||||
|
||||
namespace nm
|
||||
{
|
||||
namespace inner
|
||||
{
|
||||
struct my_type_in_named_inner_namespace {};
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_type_in_named_inner_namespace_is_extracted )
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "my_type_in_named_inner_namespace", to_string( nm::inner::my_type_in_named_inner_namespace() ) );
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
namespace inner
|
||||
{
|
||||
struct my_type_in_unnamed_inner_namespace {};
|
||||
}
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_type_in_unnamed_inner_namespace_is_extracted )
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "my_type_in_unnamed_inner_namespace", to_string( inner::my_type_in_unnamed_inner_namespace() ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_local_type_is_extracted )
|
||||
{
|
||||
struct my_local_type {};
|
||||
BOOST_CHECK_EQUAL( "my_local_type", to_string( my_local_type() ) );
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
template< typename T >
|
||||
struct my_template_type
|
||||
{
|
||||
struct inner {};
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_template_type_in_anonymous_namespace_is_extracted )
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "my_template_type<int>", to_string( my_template_type< int >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<exception>", to_string( my_template_type< std::exception >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<int const&>", to_string( my_template_type< int const& >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<exception const&>", to_string( my_template_type< std::exception const& >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<int const*>", to_string( my_template_type< int const* >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<exception const*>", to_string( my_template_type< std::exception const* >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<int const*&>", to_string( my_template_type< int const*& >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<exception const*&>", to_string( my_template_type< std::exception const*& >() ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_inner_type_from_template_type_in_anonymous_namespace_is_extracted )
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( my_template_type< int >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( my_template_type< std::exception >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( my_template_type< int const& >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( my_template_type< std::exception const& >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( my_template_type< int const* >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( my_template_type< std::exception const* >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( my_template_type< int const*& >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( my_template_type< std::exception const*& >::inner() ) );
|
||||
}
|
||||
|
||||
namespace nm
|
||||
{
|
||||
template< typename T >
|
||||
struct my_template_type
|
||||
{
|
||||
struct inner {};
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_template_type_in_named_namespace_is_extracted )
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "my_template_type<int>", to_string( nm::my_template_type< int >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<exception>", to_string( nm::my_template_type< std::exception >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<int const&>", to_string( nm::my_template_type< int const& >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<exception const&>", to_string( nm::my_template_type< std::exception const& >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<int const*>", to_string( nm::my_template_type< int const* >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<exception const*>", to_string( nm::my_template_type< std::exception const* >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<int const*&>", to_string( nm::my_template_type< int const*& >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_template_type<exception const*&>", to_string( nm::my_template_type< std::exception const*& >() ) );
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_inner_type_from_template_type_in_named_namespace_is_extracted )
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( nm::my_template_type< int >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( nm::my_template_type< std::exception >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( nm::my_template_type< int const& >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( nm::my_template_type< std::exception const& >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( nm::my_template_type< int const* >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( nm::my_template_type< std::exception const* >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( nm::my_template_type< int const*& >::inner() ) );
|
||||
BOOST_CHECK_EQUAL( "inner", to_string( nm::my_template_type< std::exception const*& >::inner() ) );
|
||||
}
|
||||
|
||||
namespace nm2
|
||||
{
|
||||
template< typename T >
|
||||
struct my_template_type
|
||||
{
|
||||
template< typename U >
|
||||
struct inner {};
|
||||
};
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_template_inner_type_from_template_type_in_named_namespace_is_extracted )
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "inner<int>", to_string( nm2::my_template_type< int >::inner< int >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int>", to_string( nm2::my_template_type< std::exception >::inner< int >() ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( "inner<int>", to_string( nm2::my_template_type< int const& >::inner< int >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int>", to_string( nm2::my_template_type< std::exception const& >::inner< int >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int>", to_string( nm2::my_template_type< int const* >::inner< int >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int>", to_string( nm2::my_template_type< std::exception const* >::inner< int >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int>", to_string( nm2::my_template_type< int const*& >::inner< int >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int>", to_string( nm2::my_template_type< std::exception const*& >::inner< int >() ) );
|
||||
|
||||
BOOST_CHECK_EQUAL( "inner<int const&>", to_string( nm2::my_template_type< int >::inner< int const& >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int const&>", to_string( nm2::my_template_type< std::exception >::inner< int const& >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int const*>", to_string( nm2::my_template_type< int >::inner< int const* >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int const*>", to_string( nm2::my_template_type< std::exception >::inner< int const* >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int const*&>", to_string( nm2::my_template_type< int >::inner< int const*& >() ) );
|
||||
BOOST_CHECK_EQUAL( "inner<int const*&>", to_string( nm2::my_template_type< std::exception >::inner< int const*& >() ) );
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
template< typename T1, typename T2, typename T3 >
|
||||
struct my_tpl
|
||||
namespace nm { namespace inner {
|
||||
struct my_type_in_named_inner_namespace
|
||||
{};
|
||||
}} // namespace nm::inner
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_type_in_named_inner_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL("my_type_in_named_inner_namespace", to_string(nm::inner::my_type_in_named_inner_namespace()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE( name_of_nested_template_with_multiple_arguments_is_extracted )
|
||||
namespace { namespace inner {
|
||||
struct my_type_in_unnamed_inner_namespace
|
||||
{};
|
||||
}} // namespace ::inner
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_type_in_unnamed_inner_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL( "vector<int, allocator<int>>", to_string( std::vector< int >() ) );
|
||||
BOOST_CHECK_EQUAL( "vector<vector<int, allocator<int>>, allocator<vector<int, allocator<int>>>>", to_string( std::vector< std::vector< int > >() ) );
|
||||
BOOST_CHECK_EQUAL( "my_tpl<my_tpl<int, int, int>, my_tpl<int, int, int>, my_tpl<int, int, int>>", to_string( my_tpl< my_tpl< int, int, int >, my_tpl< int, int, int >, my_tpl< int, int, int > >() ) );
|
||||
BOOST_CHECK_EQUAL("my_type_in_unnamed_inner_namespace", to_string(inner::my_type_in_unnamed_inner_namespace()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_local_type_is_extracted)
|
||||
{
|
||||
struct my_local_type
|
||||
{};
|
||||
BOOST_CHECK_EQUAL("my_local_type", to_string(my_local_type()));
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename T>
|
||||
struct my_template_type
|
||||
{
|
||||
struct inner
|
||||
{};
|
||||
};
|
||||
} // namespace
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_template_type_in_anonymous_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL("my_template_type<int>", to_string(my_template_type<int>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<exception>", to_string(my_template_type<std::exception>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<int const&>", to_string(my_template_type<int const&>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<exception const&>", to_string(my_template_type<std::exception const&>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<int const*>", to_string(my_template_type<int const*>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<exception const*>", to_string(my_template_type<std::exception const*>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<int const*&>", to_string(my_template_type<int const*&>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<exception const*&>", to_string(my_template_type<std::exception const*&>()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_inner_type_from_template_type_in_anonymous_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL("inner", to_string(my_template_type<int>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(my_template_type<std::exception>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(my_template_type<int const&>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(my_template_type<std::exception const&>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(my_template_type<int const*>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(my_template_type<std::exception const*>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(my_template_type<int const*&>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(my_template_type<std::exception const*&>::inner()));
|
||||
}
|
||||
|
||||
namespace nm {
|
||||
template<typename T>
|
||||
struct my_template_type
|
||||
{
|
||||
struct inner
|
||||
{};
|
||||
};
|
||||
} // namespace nm
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_template_type_in_named_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL("my_template_type<int>", to_string(nm::my_template_type<int>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<exception>", to_string(nm::my_template_type<std::exception>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<int const&>", to_string(nm::my_template_type<int const&>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<exception const&>", to_string(nm::my_template_type<std::exception const&>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<int const*>", to_string(nm::my_template_type<int const*>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<exception const*>", to_string(nm::my_template_type<std::exception const*>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<int const*&>", to_string(nm::my_template_type<int const*&>()));
|
||||
BOOST_CHECK_EQUAL("my_template_type<exception const*&>", to_string(nm::my_template_type<std::exception const*&>()));
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_inner_type_from_template_type_in_named_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL("inner", to_string(nm::my_template_type<int>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(nm::my_template_type<std::exception>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(nm::my_template_type<int const&>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(nm::my_template_type<std::exception const&>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(nm::my_template_type<int const*>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(nm::my_template_type<std::exception const*>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(nm::my_template_type<int const*&>::inner()));
|
||||
BOOST_CHECK_EQUAL("inner", to_string(nm::my_template_type<std::exception const*&>::inner()));
|
||||
}
|
||||
|
||||
namespace nm2 {
|
||||
template<typename T>
|
||||
struct my_template_type
|
||||
{
|
||||
template<typename U>
|
||||
struct inner
|
||||
{};
|
||||
};
|
||||
} // namespace nm2
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_template_inner_type_from_template_type_in_named_namespace_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL("inner<int>", to_string(nm2::my_template_type<int>::inner<int>()));
|
||||
BOOST_CHECK_EQUAL("inner<int>", to_string(nm2::my_template_type<std::exception>::inner<int>()));
|
||||
|
||||
BOOST_CHECK_EQUAL("inner<int>", to_string(nm2::my_template_type<int const&>::inner<int>()));
|
||||
BOOST_CHECK_EQUAL("inner<int>", to_string(nm2::my_template_type<std::exception const&>::inner<int>()));
|
||||
BOOST_CHECK_EQUAL("inner<int>", to_string(nm2::my_template_type<int const*>::inner<int>()));
|
||||
BOOST_CHECK_EQUAL("inner<int>", to_string(nm2::my_template_type<std::exception const*>::inner<int>()));
|
||||
BOOST_CHECK_EQUAL("inner<int>", to_string(nm2::my_template_type<int const*&>::inner<int>()));
|
||||
BOOST_CHECK_EQUAL("inner<int>", to_string(nm2::my_template_type<std::exception const*&>::inner<int>()));
|
||||
|
||||
BOOST_CHECK_EQUAL("inner<int const&>", to_string(nm2::my_template_type<int>::inner<int const&>()));
|
||||
BOOST_CHECK_EQUAL("inner<int const&>", to_string(nm2::my_template_type<std::exception>::inner<int const&>()));
|
||||
BOOST_CHECK_EQUAL("inner<int const*>", to_string(nm2::my_template_type<int>::inner<int const*>()));
|
||||
BOOST_CHECK_EQUAL("inner<int const*>", to_string(nm2::my_template_type<std::exception>::inner<int const*>()));
|
||||
BOOST_CHECK_EQUAL("inner<int const*&>", to_string(nm2::my_template_type<int>::inner<int const*&>()));
|
||||
BOOST_CHECK_EQUAL("inner<int const*&>", to_string(nm2::my_template_type<std::exception>::inner<int const*&>()));
|
||||
}
|
||||
|
||||
namespace {
|
||||
template<typename T1, typename T2, typename T3>
|
||||
struct my_tpl
|
||||
{};
|
||||
} // namespace
|
||||
|
||||
BOOST_AUTO_TEST_CASE(name_of_nested_template_with_multiple_arguments_is_extracted)
|
||||
{
|
||||
BOOST_CHECK_EQUAL("vector<int, allocator<int>>", to_string(std::vector<int>()));
|
||||
BOOST_CHECK_EQUAL("vector<vector<int, allocator<int>>, allocator<vector<int, allocator<int>>>>",
|
||||
to_string(std::vector<std::vector<int>>()));
|
||||
BOOST_CHECK_EQUAL("my_tpl<my_tpl<int, int, int>, my_tpl<int, int, int>, my_tpl<int, int, int>>",
|
||||
to_string(my_tpl<my_tpl<int, int, int>, my_tpl<int, int, int>, my_tpl<int, int, int>>()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue