Cleaned up last use of boost::mpl (#7843)
This commit is contained in:
parent
48998ef5d9
commit
5f88022323
1 changed files with 22 additions and 26 deletions
|
@ -20,10 +20,7 @@
|
|||
|
||||
#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 <tuple>
|
||||
|
||||
namespace test_throw {
|
||||
|
||||
|
@ -39,7 +36,7 @@ namespace test_throw {
|
|||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
typedef boost::mpl::vector<
|
||||
using test_match_types = std::tuple<
|
||||
/* note Wesnoth's coding style doesn't allow w_char so ignore them. */
|
||||
|
||||
bool,
|
||||
|
@ -52,17 +49,11 @@ typedef boost::mpl::vector<
|
|||
char, signed char, unsigned char,
|
||||
short, int, long, long long,
|
||||
unsigned short, unsigned int, unsigned long, unsigned long long
|
||||
> test_match_types;
|
||||
>;
|
||||
|
||||
typedef boost::mpl::vector<
|
||||
float, double, long double
|
||||
> test_nomatch_types;
|
||||
|
||||
typedef boost::mpl::copy<
|
||||
test_nomatch_types,
|
||||
boost::mpl::back_inserter<test_match_types>
|
||||
>::type test_types;
|
||||
using test_nomatch_types = std::tuple<float, double, long double>;
|
||||
|
||||
using test_types = decltype(std::tuple_cat(test_nomatch_types{}, test_match_types{}));
|
||||
|
||||
namespace {
|
||||
|
||||
|
@ -79,6 +70,12 @@ bool validate(const char* str)
|
|||
}
|
||||
}
|
||||
|
||||
template<typename Test, typename... Types>
|
||||
constexpr bool contains_type(std::tuple<Types...>)
|
||||
{
|
||||
return (std::is_same_v<Test, Types> || ...);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#define TEST_CASE(type_send, initializer) \
|
||||
|
@ -93,12 +90,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_lexical_cast_throw, T, test_types)
|
|||
{
|
||||
T value = T();
|
||||
|
||||
typedef typename boost::mpl::contains<test_match_types, T>::type test;
|
||||
typedef typename boost::mpl::contains<test_match_types, int >::type match;
|
||||
|
||||
result = typeid(test) == typeid(match)
|
||||
? "specialized - To std::string - From integral (pointer)"
|
||||
: "generic";
|
||||
if constexpr(contains_type<T>(test_match_types{})) {
|
||||
result = "specialized - To std::string - From integral (pointer)";
|
||||
} else {
|
||||
result = "generic";
|
||||
}
|
||||
|
||||
TEST_CASE(T, );
|
||||
TEST_CASE(const T, );
|
||||
|
@ -115,11 +111,11 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(test_lexical_cast_throw, T, test_types)
|
|||
|
||||
#undef TEST_CASE
|
||||
|
||||
typedef boost::mpl::vector<
|
||||
using test_lexical_cast_signed_types = std::tuple<
|
||||
signed char
|
||||
, short
|
||||
, int
|
||||
, long> test_lexical_cast_signed_types;
|
||||
, long>;
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE(
|
||||
test_lexical_cast_signed, T, test_lexical_cast_signed_types)
|
||||
|
@ -154,11 +150,11 @@ BOOST_AUTO_TEST_CASE(test_lexical_cast_long_long)
|
|||
std::string(value)), const char*, validate);
|
||||
}
|
||||
|
||||
typedef boost::mpl::vector<
|
||||
using test_lexical_cast_unsigned_types = std::tuple<
|
||||
unsigned char
|
||||
, unsigned short
|
||||
, unsigned int
|
||||
, unsigned long> test_lexical_cast_unsigned_types;
|
||||
, unsigned long>;
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE(
|
||||
test_lexical_cast_unsigned, T, test_lexical_cast_unsigned_types)
|
||||
|
@ -210,10 +206,10 @@ BOOST_AUTO_TEST_CASE(test_lexical_cast_bool)
|
|||
std::string(value)), const char*, validate);
|
||||
}
|
||||
|
||||
typedef boost::mpl::vector<
|
||||
using test_lexical_cast_floating_point_types = std::tuple<
|
||||
float
|
||||
, double
|
||||
, long double> test_lexical_cast_floating_point_types;
|
||||
, long double>;
|
||||
|
||||
BOOST_AUTO_TEST_CASE_TEMPLATE(
|
||||
test_lexical_cast_floating_point, T, test_lexical_cast_floating_point_types)
|
||||
|
|
Loading…
Add table
Reference in a new issue