mirror of
https://github.com/boostorg/hof.git
synced 2026-02-26 04:42:17 +00:00
Boostify
This commit is contained in:
122
test/if.cpp
122
test/if.cpp
@@ -1,8 +1,8 @@
|
||||
#include <fit/if.hpp>
|
||||
#include <boost/fit/if.hpp>
|
||||
#include "test.hpp"
|
||||
|
||||
#include <fit/conditional.hpp>
|
||||
#include <fit/placeholders.hpp>
|
||||
#include <boost/fit/conditional.hpp>
|
||||
#include <boost/fit/placeholders.hpp>
|
||||
|
||||
|
||||
struct is_5
|
||||
@@ -29,34 +29,34 @@ struct test_int
|
||||
template<class T>
|
||||
constexpr bool operator()(T x) const
|
||||
{
|
||||
return fit::conditional(
|
||||
fit::if_(std::is_integral<T>())(F()),
|
||||
fit::always(true)
|
||||
return boost::fit::conditional(
|
||||
boost::fit::if_(std::is_integral<T>())(F()),
|
||||
boost::fit::always(true)
|
||||
)(x);
|
||||
}
|
||||
};
|
||||
|
||||
FIT_TEST_CASE()
|
||||
BOOST_FIT_TEST_CASE()
|
||||
{
|
||||
FIT_TEST_CHECK(test_int<is_5>()(5));
|
||||
FIT_TEST_CHECK(test_int<is_5>()(5L));
|
||||
FIT_TEST_CHECK(test_int<is_5>()(5.0));
|
||||
FIT_TEST_CHECK(test_int<is_5>()(6.0));
|
||||
BOOST_FIT_TEST_CHECK(test_int<is_5>()(5));
|
||||
BOOST_FIT_TEST_CHECK(test_int<is_5>()(5L));
|
||||
BOOST_FIT_TEST_CHECK(test_int<is_5>()(5.0));
|
||||
BOOST_FIT_TEST_CHECK(test_int<is_5>()(6.0));
|
||||
|
||||
FIT_TEST_CHECK(test_int<is_not_5>()(6));
|
||||
FIT_TEST_CHECK(test_int<is_not_5>()(6L));
|
||||
FIT_TEST_CHECK(test_int<is_not_5>()(5.0));
|
||||
FIT_TEST_CHECK(test_int<is_not_5>()(6.0));
|
||||
BOOST_FIT_TEST_CHECK(test_int<is_not_5>()(6));
|
||||
BOOST_FIT_TEST_CHECK(test_int<is_not_5>()(6L));
|
||||
BOOST_FIT_TEST_CHECK(test_int<is_not_5>()(5.0));
|
||||
BOOST_FIT_TEST_CHECK(test_int<is_not_5>()(6.0));
|
||||
|
||||
FIT_STATIC_TEST_CHECK(test_int<is_5>()(5));
|
||||
FIT_STATIC_TEST_CHECK(test_int<is_5>()(5L));
|
||||
FIT_STATIC_TEST_CHECK(test_int<is_5>()(5.0));
|
||||
FIT_STATIC_TEST_CHECK(test_int<is_5>()(6.0));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int<is_5>()(5));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int<is_5>()(5L));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int<is_5>()(5.0));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int<is_5>()(6.0));
|
||||
|
||||
FIT_STATIC_TEST_CHECK(test_int<is_not_5>()(6));
|
||||
FIT_STATIC_TEST_CHECK(test_int<is_not_5>()(6L));
|
||||
FIT_STATIC_TEST_CHECK(test_int<is_not_5>()(5.0));
|
||||
FIT_STATIC_TEST_CHECK(test_int<is_not_5>()(6.0));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int<is_not_5>()(6));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int<is_not_5>()(6L));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int<is_not_5>()(5.0));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int<is_not_5>()(6.0));
|
||||
}
|
||||
|
||||
template<class F>
|
||||
@@ -65,34 +65,34 @@ struct test_int_c
|
||||
template<class T>
|
||||
constexpr bool operator()(T x) const
|
||||
{
|
||||
return fit::conditional(
|
||||
fit::if_c<std::is_integral<T>::value>(F()),
|
||||
fit::always(true)
|
||||
return boost::fit::conditional(
|
||||
boost::fit::if_c<std::is_integral<T>::value>(F()),
|
||||
boost::fit::always(true)
|
||||
)(x);
|
||||
}
|
||||
};
|
||||
|
||||
FIT_TEST_CASE()
|
||||
BOOST_FIT_TEST_CASE()
|
||||
{
|
||||
FIT_TEST_CHECK(test_int_c<is_5>()(5));
|
||||
FIT_TEST_CHECK(test_int_c<is_5>()(5L));
|
||||
FIT_TEST_CHECK(test_int_c<is_5>()(5.0));
|
||||
FIT_TEST_CHECK(test_int_c<is_5>()(6.0));
|
||||
BOOST_FIT_TEST_CHECK(test_int_c<is_5>()(5));
|
||||
BOOST_FIT_TEST_CHECK(test_int_c<is_5>()(5L));
|
||||
BOOST_FIT_TEST_CHECK(test_int_c<is_5>()(5.0));
|
||||
BOOST_FIT_TEST_CHECK(test_int_c<is_5>()(6.0));
|
||||
|
||||
FIT_TEST_CHECK(test_int_c<is_not_5>()(6));
|
||||
FIT_TEST_CHECK(test_int_c<is_not_5>()(6L));
|
||||
FIT_TEST_CHECK(test_int_c<is_not_5>()(5.0));
|
||||
FIT_TEST_CHECK(test_int_c<is_not_5>()(6.0));
|
||||
BOOST_FIT_TEST_CHECK(test_int_c<is_not_5>()(6));
|
||||
BOOST_FIT_TEST_CHECK(test_int_c<is_not_5>()(6L));
|
||||
BOOST_FIT_TEST_CHECK(test_int_c<is_not_5>()(5.0));
|
||||
BOOST_FIT_TEST_CHECK(test_int_c<is_not_5>()(6.0));
|
||||
|
||||
FIT_STATIC_TEST_CHECK(test_int_c<is_5>()(5));
|
||||
FIT_STATIC_TEST_CHECK(test_int_c<is_5>()(5L));
|
||||
FIT_STATIC_TEST_CHECK(test_int_c<is_5>()(5.0));
|
||||
FIT_STATIC_TEST_CHECK(test_int_c<is_5>()(6.0));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int_c<is_5>()(5));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int_c<is_5>()(5L));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int_c<is_5>()(5.0));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int_c<is_5>()(6.0));
|
||||
|
||||
FIT_STATIC_TEST_CHECK(test_int_c<is_not_5>()(6));
|
||||
FIT_STATIC_TEST_CHECK(test_int_c<is_not_5>()(6L));
|
||||
FIT_STATIC_TEST_CHECK(test_int_c<is_not_5>()(5.0));
|
||||
FIT_STATIC_TEST_CHECK(test_int_c<is_not_5>()(6.0));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int_c<is_not_5>()(6));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int_c<is_not_5>()(6L));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int_c<is_not_5>()(5.0));
|
||||
BOOST_FIT_STATIC_TEST_CHECK(test_int_c<is_not_5>()(6.0));
|
||||
}
|
||||
|
||||
struct sum_f
|
||||
@@ -100,21 +100,21 @@ struct sum_f
|
||||
template<class T>
|
||||
constexpr int operator()(T x, T y) const
|
||||
{
|
||||
return fit::conditional(
|
||||
fit::if_(std::is_integral<T>())(fit::_ + fit::_),
|
||||
fit::always(0)
|
||||
return boost::fit::conditional(
|
||||
boost::fit::if_(std::is_integral<T>())(boost::fit::_ + boost::fit::_),
|
||||
boost::fit::always(0)
|
||||
)(x, y);
|
||||
}
|
||||
};
|
||||
|
||||
FIT_TEST_CASE()
|
||||
BOOST_FIT_TEST_CASE()
|
||||
{
|
||||
FIT_TEST_CHECK(sum_f()(1, 2) == 3);
|
||||
FIT_TEST_CHECK(sum_f()(1.0, 2.0) == 0);
|
||||
FIT_TEST_CHECK(sum_f()("", "") == 0);
|
||||
BOOST_FIT_TEST_CHECK(sum_f()(1, 2) == 3);
|
||||
BOOST_FIT_TEST_CHECK(sum_f()(1.0, 2.0) == 0);
|
||||
BOOST_FIT_TEST_CHECK(sum_f()("", "") == 0);
|
||||
|
||||
FIT_STATIC_TEST_CHECK(sum_f()(1, 2) == 3);
|
||||
FIT_STATIC_TEST_CHECK(sum_f()("", "") == 0);
|
||||
BOOST_FIT_STATIC_TEST_CHECK(sum_f()(1, 2) == 3);
|
||||
BOOST_FIT_STATIC_TEST_CHECK(sum_f()("", "") == 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -123,21 +123,21 @@ struct sum_f_c
|
||||
template<class T>
|
||||
constexpr int operator()(T x, T y) const
|
||||
{
|
||||
return fit::conditional(
|
||||
fit::if_c<std::is_integral<T>::value>(fit::_ + fit::_),
|
||||
fit::always(0)
|
||||
return boost::fit::conditional(
|
||||
boost::fit::if_c<std::is_integral<T>::value>(boost::fit::_ + boost::fit::_),
|
||||
boost::fit::always(0)
|
||||
)(x, y);
|
||||
}
|
||||
};
|
||||
|
||||
FIT_TEST_CASE()
|
||||
BOOST_FIT_TEST_CASE()
|
||||
{
|
||||
FIT_TEST_CHECK(sum_f_c()(1, 2) == 3);
|
||||
FIT_TEST_CHECK(sum_f_c()(1.0, 2.0) == 0);
|
||||
FIT_TEST_CHECK(sum_f_c()("", "") == 0);
|
||||
BOOST_FIT_TEST_CHECK(sum_f_c()(1, 2) == 3);
|
||||
BOOST_FIT_TEST_CHECK(sum_f_c()(1.0, 2.0) == 0);
|
||||
BOOST_FIT_TEST_CHECK(sum_f_c()("", "") == 0);
|
||||
|
||||
FIT_STATIC_TEST_CHECK(sum_f_c()(1, 2) == 3);
|
||||
FIT_STATIC_TEST_CHECK(sum_f_c()("", "") == 0);
|
||||
BOOST_FIT_STATIC_TEST_CHECK(sum_f_c()(1, 2) == 3);
|
||||
BOOST_FIT_STATIC_TEST_CHECK(sum_f_c()("", "") == 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user