The Battle for Wesnoth  1.15.2+dev
Classes | Namespaces | Macros | Typedefs | Functions
test_lexical_cast.cpp File Reference
#include "lexical_cast.hpp"
#include <boost/test/unit_test.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/copy.hpp>
#include <boost/mpl/back_inserter.hpp>
#include <boost/mpl/contains.hpp>
#include <boost/test/test_case_template.hpp>
#include <iostream>
Include dependency graph for test_lexical_cast.cpp:

Go to the source code of this file.

Classes

struct  test_throw::implementation::lexical_caster< To, From, ToEnable, FromEnable >
 Base class for the conversion. More...
 
struct  test_throw::bad_lexical_cast
 Thrown when a lexical_cast fails. More...
 
struct  test_throw::implementation::lexical_caster< To, From, ToEnable, FromEnable >
 Base class for the conversion. More...
 
struct  test_throw::implementation::value >>< From >
 Specialized conversion class. More...
 
struct  test_throw::implementation::lexical_caster< long long, From, void, std::enable_if_t< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From >::value > >
 Specialized conversion class. More...
 
struct  test_throw::implementation::lexical_caster< long long, std::string >
 Specialized conversion class. More...
 
struct  test_throw::implementation::lexical_caster< To, From, std::enable_if_t< std::is_integral< To >::value &&std::is_signed< To >::value &&!std::is_same< To, long long >::value >, std::enable_if_t< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From >::value > >
 Specialized conversion class. More...
 
struct  test_throw::implementation::lexical_caster< To, std::string, std::enable_if_t< std::is_integral< To >::value &&std::is_signed< To >::value &&!std::is_same< To, long long >::value > >
 Specialized conversion class. More...
 
struct  test_throw::implementation::lexical_caster< To, From, std::enable_if_t< std::is_floating_point< To >::value >, std::enable_if_t< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From >::value > >
 Specialized conversion class. More...
 
struct  test_throw::implementation::lexical_caster< To, std::string, std::enable_if_t< std::is_floating_point< To >::value > >
 Specialized conversion class. More...
 
struct  test_throw::implementation::lexical_caster< unsigned long long, From, void, std::enable_if_t< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From >::value > >
 Specialized conversion class. More...
 
struct  test_throw::implementation::lexical_caster< unsigned long long, std::string >
 Specialized conversion class. More...
 
struct  test_throw::implementation::lexical_caster< To, From, std::enable_if_t< std::is_unsigned< To >::value &&!std::is_same< To, unsigned long long >::value >, std::enable_if_t< boost::mpl::has_key< boost::mpl::set< char *, const char * >, From >::value > >
 Specialized conversion class. More...
 
struct  test_throw::implementation::lexical_caster< To, std::string, std::enable_if_t< std::is_unsigned< To >::value > >
 Specialized conversion class. More...
 

Namespaces

 test_throw
 
 implementation
 Contains the implementation details for lexical_cast and shouldn't be used directly.
 
 test_throw::implementation
 

Macros

#define GETTEXT_DOMAIN   "wesnoth-test"
 
#define LEXICAL_CAST_DEBUG
 
#define TEST_CASE(type_send, initializer)
 

Typedefs

typedef boost::mpl::vector< bool, char, signed char, unsigned char, short, int, long, long long, unsigned short, unsigned int, unsigned long, unsigned long long > test_throw::test_match_types
 
typedef boost::mpl::vector< float, double, long double > test_throw::test_nomatch_types
 
typedef boost::mpl::copy< test_nomatch_types, boost::mpl::back_inserter< test_match_types > >::type test_throw::test_types
 
typedef boost::mpl::vector< signed char, short, int, long > test_throw::test_lexical_cast_signed_types
 
typedef boost::mpl::vector< bool, unsigned char, unsigned short, unsigned int, unsigned long > test_throw::test_lexical_cast_unsigned_types
 
typedef boost::mpl::vector< float, double, long double > test_throw::test_lexical_cast_floating_point_types
 

Functions

template<typename To , typename From >
To test_throw::lexical_cast (From value)
 Lexical cast converts one type to another. More...
 
template<typename To , typename From >
To test_throw::lexical_cast_default (From value, To fallback=To())
 Lexical cast converts one type to another with a fallback. More...
 
 test_throw::BOOST_AUTO_TEST_CASE_TEMPLATE (test_lexical_cast_throw, T, test_types)
 
 test_throw::BOOST_AUTO_TEST_CASE_TEMPLATE (test_lexical_cast_signed, T, test_lexical_cast_signed_types)
 
 test_throw::BOOST_AUTO_TEST_CASE (test_lexical_cast_long_long)
 
 test_throw::BOOST_AUTO_TEST_CASE_TEMPLATE (test_lexical_cast_unsigned, T, test_lexical_cast_unsigned_types)
 
 test_throw::BOOST_AUTO_TEST_CASE (test_lexical_cast_unsigned_long_long)
 
 test_throw::BOOST_AUTO_TEST_CASE_TEMPLATE (test_lexical_cast_floating_point, T, test_lexical_cast_floating_point_types)
 
 BOOST_AUTO_TEST_CASE (test_lexical_cast_result)
 

Macro Definition Documentation

◆ GETTEXT_DOMAIN

#define GETTEXT_DOMAIN   "wesnoth-test"

Definition at line 15 of file test_lexical_cast.cpp.

◆ LEXICAL_CAST_DEBUG

#define LEXICAL_CAST_DEBUG

Definition at line 36 of file test_lexical_cast.cpp.

◆ TEST_CASE

#define TEST_CASE (   type_send,
  initializer 
)
Value:
{ \
type_send val = initializer value; \
\
BOOST_CHECK_EXCEPTION( \
lexical_cast<std::string>(val), const char*, validate); \
}
static void validate(boost::any &v, const std::vector< std::string > &values, two_strings *, int)

Definition at line 85 of file test_lexical_cast.cpp.

Referenced by test_throw::lexical_cast().

Function Documentation

◆ BOOST_AUTO_TEST_CASE()

BOOST_AUTO_TEST_CASE ( test_lexical_cast_result  )

Definition at line 223 of file test_lexical_cast.cpp.