2
0
mirror of https://github.com/boostorg/hof.git synced 2026-02-01 20:42:14 +00:00
This commit is contained in:
Paul
2016-03-02 01:46:17 -06:00
parent ec7a043522
commit d7b6c67f3d
140 changed files with 3721 additions and 3721 deletions

View File

@@ -1,9 +1,9 @@
#include <fit/construct.hpp>
#include <boost/fit/construct.hpp>
#include "test.hpp"
#include <fit/conditional.hpp>
#include <fit/by.hpp>
#include <fit/placeholders.hpp>
#include <boost/fit/conditional.hpp>
#include <boost/fit/by.hpp>
#include <boost/fit/placeholders.hpp>
#include <tuple>
#include <type_traits>
@@ -32,108 +32,108 @@ struct tuple_meta_class
};
};
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto v = fit::construct<std::vector<int>>()(5, 5);
FIT_TEST_CHECK(v.size() == 5);
FIT_TEST_CHECK(v == std::vector<int>{5, 5, 5, 5, 5});
auto v = boost::fit::construct<std::vector<int>>()(5, 5);
BOOST_FIT_TEST_CHECK(v.size() == 5);
BOOST_FIT_TEST_CHECK(v == std::vector<int>{5, 5, 5, 5, 5});
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto make = fit::construct<std::vector<int>>().by(fit::_1 * fit::_1);
auto make = boost::fit::construct<std::vector<int>>().by(boost::fit::_1 * boost::fit::_1);
auto v = make(3, 3);
FIT_TEST_CHECK(v.size() == 9);
FIT_TEST_CHECK(v == std::vector<int>{9, 9, 9, 9, 9, 9, 9, 9, 9});
BOOST_FIT_TEST_CHECK(v.size() == 9);
BOOST_FIT_TEST_CHECK(v == std::vector<int>{9, 9, 9, 9, 9, 9, 9, 9, 9});
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto v = fit::construct<std::vector<int>>()({5, 5, 5, 5, 5});
FIT_TEST_CHECK(v.size() == 5);
FIT_TEST_CHECK(v == std::vector<int>{5, 5, 5, 5, 5});
auto v = boost::fit::construct<std::vector<int>>()({5, 5, 5, 5, 5});
BOOST_FIT_TEST_CHECK(v.size() == 5);
BOOST_FIT_TEST_CHECK(v == std::vector<int>{5, 5, 5, 5, 5});
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto t = fit::construct<std::tuple>()(1, 2, 3);
auto t = boost::fit::construct<std::tuple>()(1, 2, 3);
static_assert(std::is_same<std::tuple<int, int, int>, decltype(t)>::value, "");
FIT_TEST_CHECK(t == std::make_tuple(1, 2, 3));
BOOST_FIT_TEST_CHECK(t == std::make_tuple(1, 2, 3));
// GCC 4.7 doesn't have fully constexpr tuple
#if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 7
FIT_STATIC_TEST_CHECK(std::make_tuple(1, 2, 3) == fit::construct<std::tuple>()(1, 2, 3));
BOOST_FIT_STATIC_TEST_CHECK(std::make_tuple(1, 2, 3) == boost::fit::construct<std::tuple>()(1, 2, 3));
#endif
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto t = fit::construct<std::pair>()(1, 2);
auto t = boost::fit::construct<std::pair>()(1, 2);
static_assert(std::is_same<std::pair<int, int>, decltype(t)>::value, "");
FIT_TEST_CHECK(t == std::make_pair(1, 2));
BOOST_FIT_TEST_CHECK(t == std::make_pair(1, 2));
// GCC 4.7 doesn't have fully constexpr pair
#if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 7
FIT_STATIC_TEST_CHECK(std::make_pair(1, 2) == fit::construct<std::pair>()(1, 2));
BOOST_FIT_STATIC_TEST_CHECK(std::make_pair(1, 2) == boost::fit::construct<std::pair>()(1, 2));
#endif
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto make = fit::construct<std::tuple>().by(fit::_1 * fit::_1);
auto make = boost::fit::construct<std::tuple>().by(boost::fit::_1 * boost::fit::_1);
auto t = make(1, 2, 3);
static_assert(std::is_same<std::tuple<int, int, int>, decltype(t)>::value, "");
FIT_TEST_CHECK(t == std::make_tuple(1, 4, 9));
BOOST_FIT_TEST_CHECK(t == std::make_tuple(1, 4, 9));
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto f = fit::conditional(fit::construct<std::pair>(), fit::identity);
FIT_TEST_CHECK(f(1, 2) == std::make_pair(1, 2));
FIT_TEST_CHECK(f(1) == 1);
auto f = boost::fit::conditional(boost::fit::construct<std::pair>(), boost::fit::identity);
BOOST_FIT_TEST_CHECK(f(1, 2) == std::make_pair(1, 2));
BOOST_FIT_TEST_CHECK(f(1) == 1);
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto x = fit::construct<ac>()(1);
auto x = boost::fit::construct<ac>()(1);
static_assert(std::is_same<ac<int>, decltype(x)>::value, "");
FIT_TEST_CHECK(x.value == ac<int>(1).value);
FIT_STATIC_TEST_CHECK(ac<int>(1).value == fit::construct<ac>()(1).value);
BOOST_FIT_TEST_CHECK(x.value == ac<int>(1).value);
BOOST_FIT_STATIC_TEST_CHECK(ac<int>(1).value == boost::fit::construct<ac>()(1).value);
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto t = fit::construct_meta<tuple_meta>()(1, 2, 3);
auto t = boost::fit::construct_meta<tuple_meta>()(1, 2, 3);
static_assert(std::is_same<std::tuple<int, int, int>, decltype(t)>::value, "");
FIT_TEST_CHECK(t == std::make_tuple(1, 2, 3));
BOOST_FIT_TEST_CHECK(t == std::make_tuple(1, 2, 3));
// GCC 4.7 doesn't have fully constexpr tuple
#if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 7
FIT_STATIC_TEST_CHECK(std::make_tuple(1, 2, 3) == fit::construct_meta<tuple_meta>()(1, 2, 3));
BOOST_FIT_STATIC_TEST_CHECK(std::make_tuple(1, 2, 3) == boost::fit::construct_meta<tuple_meta>()(1, 2, 3));
#endif
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto t = fit::construct_meta<tuple_meta_class>()(1, 2, 3);
auto t = boost::fit::construct_meta<tuple_meta_class>()(1, 2, 3);
static_assert(std::is_same<std::tuple<int, int, int>, decltype(t)>::value, "");
FIT_TEST_CHECK(t == std::make_tuple(1, 2, 3));
BOOST_FIT_TEST_CHECK(t == std::make_tuple(1, 2, 3));
// GCC 4.7 doesn't have fully constexpr tuple
#if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 7
FIT_STATIC_TEST_CHECK(std::make_tuple(1, 2, 3) == fit::construct_meta<tuple_meta_class>()(1, 2, 3));
BOOST_FIT_STATIC_TEST_CHECK(std::make_tuple(1, 2, 3) == boost::fit::construct_meta<tuple_meta_class>()(1, 2, 3));
#endif
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto make = fit::construct_meta<tuple_meta>().by(fit::_1 * fit::_1);
auto make = boost::fit::construct_meta<tuple_meta>().by(boost::fit::_1 * boost::fit::_1);
auto t = make(1, 2, 3);
static_assert(std::is_same<std::tuple<int, int, int>, decltype(t)>::value, "");
FIT_TEST_CHECK(t == std::make_tuple(1, 4, 9));
BOOST_FIT_TEST_CHECK(t == std::make_tuple(1, 4, 9));
}
FIT_TEST_CASE()
BOOST_FIT_TEST_CASE()
{
auto make = fit::construct_meta<tuple_meta_class>().by(fit::_1 * fit::_1);
auto make = boost::fit::construct_meta<tuple_meta_class>().by(boost::fit::_1 * boost::fit::_1);
auto t = make(1, 2, 3);
static_assert(std::is_same<std::tuple<int, int, int>, decltype(t)>::value, "");
FIT_TEST_CHECK(t == std::make_tuple(1, 4, 9));
BOOST_FIT_TEST_CHECK(t == std::make_tuple(1, 4, 9));
}