diff options
Diffstat (limited to 'src/boost/libs/hof/test/repeat.cpp')
-rw-r--r-- | src/boost/libs/hof/test/repeat.cpp | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/src/boost/libs/hof/test/repeat.cpp b/src/boost/libs/hof/test/repeat.cpp new file mode 100644 index 00000000..19b3b51d --- /dev/null +++ b/src/boost/libs/hof/test/repeat.cpp @@ -0,0 +1,66 @@ +/*============================================================================= + Copyright (c) 2017 Paul Fultz II + repeat.cpp + Distributed under the Boost Software License, Version 1.0. (See accompanying + file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) +==============================================================================*/ +#include <boost/hof/repeat.hpp> +#include <limits> +#include "test.hpp" + +// TODO: Add tests for multiple parameters + +struct increment +{ + template<class T> + constexpr T operator()(T x) const noexcept + { + return x + 1; + } +}; + +#if BOOST_HOF_HAS_NOEXCEPT_DEDUCTION +BOOST_HOF_TEST_CASE() +{ + static_assert(noexcept(boost::hof::repeat(std::integral_constant<int, 5>())(increment())(1)), "noexcept repeat"); + static_assert(noexcept(boost::hof::repeat(5)(increment())(1)), "noexcept repeat"); +} +#endif + +BOOST_HOF_TEST_CASE() +{ + BOOST_HOF_TEST_CHECK(boost::hof::repeat(std::integral_constant<int, 5>())(increment())(1) == 6); + BOOST_HOF_STATIC_TEST_CHECK(boost::hof::repeat(std::integral_constant<int, 5>())(increment())(1) == 6); +} + +BOOST_HOF_TEST_CASE() +{ + BOOST_HOF_TEST_CHECK(boost::hof::repeat(5)(increment())(1) == 6); + BOOST_HOF_STATIC_TEST_CHECK(boost::hof::repeat(5)(increment())(1) == 6); +} + +BOOST_HOF_TEST_CASE() +{ + int i = 5; + BOOST_HOF_TEST_CHECK(boost::hof::repeat(i)(increment())(1) == 6); +} + +BOOST_HOF_TEST_CASE() +{ + static const int i = 5; + BOOST_HOF_TEST_CHECK(boost::hof::repeat(i)(increment())(1) == 6); + BOOST_HOF_STATIC_TEST_CHECK(boost::hof::repeat(i)(increment())(1) == 6); +} + +// BOOST_HOF_TEST_CASE() +// { +// BOOST_HOF_TEST_CHECK(boost::hof::repeat(std::numeric_limits<int>::max()/4)(increment())(0) == std::numeric_limits<int>::max()/4); +// } + +BOOST_HOF_TEST_CASE() +{ + BOOST_HOF_TEST_CHECK(boost::hof::repeat(BOOST_HOF_RECURSIVE_CONSTEXPR_DEPTH+4)(increment())(0) == BOOST_HOF_RECURSIVE_CONSTEXPR_DEPTH+4); +#if BOOST_HOF_HAS_RELAXED_CONSTEXPR + BOOST_HOF_STATIC_TEST_CHECK(boost::hof::repeat(BOOST_HOF_RECURSIVE_CONSTEXPR_DEPTH+4)(increment())(0) == BOOST_HOF_RECURSIVE_CONSTEXPR_DEPTH+4); +#endif +} |