FIT_TEST_CASE() { FIT_TEST_CHECK(find_positive_max() == 0); FIT_TEST_CHECK(find_positive_max(5) == 5); FIT_STATIC_TEST_CHECK(find_positive_max() == 0); FIT_STATIC_TEST_CHECK(find_positive_max(5) == 5); }
FIT_TEST_CASE() { FIT_TEST_CHECK(fit::compress(max_f(), 0)() == 0); FIT_TEST_CHECK(fit::compress(max_f(), 0)(5) == 5); FIT_STATIC_TEST_CHECK(fit::compress(max_f(), 0)() == 0); FIT_STATIC_TEST_CHECK(fit::compress(max_f(), 0)(5) == 5); }
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); FIT_STATIC_TEST_CHECK(sum_f()(1, 2) == 3); FIT_STATIC_TEST_CHECK(sum_f()("", "") == 0); }
FIT_TEST_CASE() { FIT_TEST_CHECK(fun(1) == 1); FIT_TEST_CHECK(fun(foo()) == 2); FIT_STATIC_TEST_CHECK(fun(1) == 1); FIT_STATIC_TEST_CHECK(fun(foo()) == 2); };
FIT_TEST_CASE() { FIT_TEST_CHECK(fit::reveal(fun)(1) == 1); FIT_TEST_CHECK(fit::reveal(fun)(foo()) == 2); FIT_STATIC_TEST_CHECK(fit::reveal(fun)(1) == 1); FIT_STATIC_TEST_CHECK(fit::reveal(fun)(foo()) == 2); };
FIT_TEST_CASE() { FIT_TEST_CHECK(3 == fit::fuse(unary_class())(std::make_tuple(3))); FIT_TEST_CHECK(3 == unary_fuse(std::make_tuple(3))); int ifu = 3; FIT_TEST_CHECK(3 == unary_fuse(std::tuple<int&>(ifu))); FIT_STATIC_TEST_CHECK(3 == fit::fuse(unary_class())(std::make_tuple(3))); FIT_STATIC_TEST_CHECK(3 == unary_fuse_constexpr(std::make_tuple(3))); }
FIT_TEST_CASE() { FIT_TEST_CHECK(fit::compress(max_f())(2, 3, 4, 5) == 5); FIT_TEST_CHECK(fit::compress(max_f())(5, 4, 3, 2) == 5); FIT_TEST_CHECK(fit::compress(max_f())(2, 3, 5, 4) == 5); FIT_STATIC_TEST_CHECK(fit::compress(max_f())(2, 3, 4, 5) == 5); FIT_STATIC_TEST_CHECK(fit::compress(max_f())(5, 4, 3, 2) == 5); FIT_STATIC_TEST_CHECK(fit::compress(max_f())(2, 3, 5, 4) == 5); }
FIT_TEST_CASE() { void_pipable_constexpr(1); 1 | void_pipable_constexpr; FIT_STATIC_TEST_CHECK(3 == (1 | binary_pipable_constexpr(2))); FIT_STATIC_TEST_CHECK(3 == (binary_pipable_constexpr(1, 2))); FIT_STATIC_TEST_CHECK(3 == (3 | unary_pipable_constexpr)); FIT_STATIC_TEST_CHECK(3 == (3 | unary_pipable_constexpr())); FIT_STATIC_TEST_CHECK(3 == (unary_pipable_constexpr(3))); }
FIT_TEST_CASE() { FIT_TEST_CHECK(max_f()(3, 4) == std::max(3, 4)); FIT_TEST_CHECK(sum_f()(1, 2) == 3); FIT_STATIC_TEST_CHECK(sum_f()(1, 2) == 3); }
FIT_TEST_CASE() { auto x = 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); }
FIT_TEST_CASE() { FIT_TEST_CHECK(filter_integers()(fit::pack(1, 2, 2.0, 3)) == std::make_tuple(1, 2, 3)); #if FIT_HAS_CONSTEXPR_TUPLE FIT_STATIC_TEST_CHECK(filter_integers()(fit::pack(1, 2, 2.0, 3)) == std::make_tuple(1, 2, 3)); #endif }
FIT_TEST_CASE() { constexpr auto f = fit::compose(increment(), decrement()); static_assert(std::is_empty<decltype(f)>::value, "Compose function not empty"); int r = f(3); FIT_TEST_CHECK(r == 3); FIT_STATIC_TEST_CHECK(f(3) == 3); }
FIT_TEST_CASE() { auto t = 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)); // 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)); #endif }
FIT_TEST_CASE() { int const x = 1; int const y = 2; FIT_TEST_CHECK( fit::lazy(f_1())( fit::lazy(f_1())(std::placeholders::_1))(x) == 1L ); FIT_TEST_CHECK( fit::lazy(f_1())( fit::lazy(f_2())(std::placeholders::_1, std::placeholders::_2))(x, y) == 21L ); FIT_TEST_CHECK( fit::lazy(f_2())( fit::lazy(f_1())(std::placeholders::_1), fit::lazy(f_1())(std::placeholders::_1))(x) == 11L ); FIT_TEST_CHECK( fit::lazy(f_2())( fit::lazy(f_1())(std::placeholders::_1), fit::lazy(f_1())( std::placeholders::_2))(x, y) == 21L ); FIT_TEST_CHECK( fit::lazy(f_1())( fit::lazy(f_0())())() == 17041L ); FIT_STATIC_TEST_CHECK( fit::lazy(f_1())( fit::lazy(f_1())(test_placeholder<1>()))(x) == 1L ); FIT_STATIC_TEST_CHECK( fit::lazy(f_1())( fit::lazy(f_2())(test_placeholder<1>(), test_placeholder<2>()))(x, y) == 21L ); FIT_STATIC_TEST_CHECK( fit::lazy(f_2())( fit::lazy(f_1())(test_placeholder<1>()), fit::lazy(f_1())(test_placeholder<1>()))(x) == 11L ); FIT_STATIC_TEST_CHECK( fit::lazy(f_2())( fit::lazy(f_1())(test_placeholder<1>()), fit::lazy(f_1())( test_placeholder<2>()))(x, y) == 21L ); FIT_STATIC_TEST_CHECK( fit::lazy(f_1())( fit::lazy(f_0())())() == 17041L ); FIT_TEST_CHECK( (fit::lazy(fv_1())( fit::lazy(f_1())(std::placeholders::_1))(x), (global_result == 1L)) ); FIT_TEST_CHECK( (fit::lazy(fv_1())( fit::lazy(f_2())(std::placeholders::_1, std::placeholders::_2))(x, y), (global_result == 21L)) ); FIT_TEST_CHECK( (fit::lazy(fv_2())( fit::lazy(f_1())(std::placeholders::_1), fit::lazy(f_1())(std::placeholders::_1))(x), (global_result == 11L)) ); FIT_TEST_CHECK( (fit::lazy(fv_2())( fit::lazy(f_1())(std::placeholders::_1), fit::lazy(f_1())( std::placeholders::_2))(x, y), (global_result == 21L)) ); FIT_TEST_CHECK( (fit::lazy(fv_1())( fit::lazy(f_0())())(), (global_result == 17041L)) ); }
FIT_TEST_CASE() { FIT_TEST_CHECK( fit::combine( fit::construct<mini_pair>(), fit::capture(1)(fit::construct<mini_pair>()), fit::capture(2)(fit::construct<mini_pair>()) )(2, 4) == make_mini_pair(make_mini_pair(1, 2), make_mini_pair(2, 4))); FIT_STATIC_TEST_CHECK( fit::combine( fit::construct<mini_pair>(), fit::capture(1)(fit::construct<mini_pair>()), fit::capture(2)(fit::construct<mini_pair>()) )(2, 4) == make_mini_pair(make_mini_pair(1, 2), make_mini_pair(2, 4))); }
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)); 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)); 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)); 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)); }
FIT_TEST_CASE() { FIT_STATIC_TEST_CHECK(fit::capture(1, 2)(binary_class())() == 3); FIT_TEST_CHECK(fit::capture(1, 2)(binary_class())() == 3); FIT_STATIC_TEST_CHECK(fit::capture(1)(binary_class())(2) == 3); FIT_TEST_CHECK(fit::capture(1)(binary_class())(2) == 3); static const int one = 1; static const int two = 2; FIT_STATIC_TEST_CHECK(fit::capture_forward(one, two)(binary_class())() == 3); FIT_TEST_CHECK(fit::capture_forward(one, two)(binary_class())() == 3); FIT_TEST_CHECK(fit::capture_forward(1, 2)(binary_class())() == 3); FIT_STATIC_TEST_CHECK(fit::capture_forward(one)(binary_class())(two) == 3); FIT_TEST_CHECK(fit::capture_forward(1)(binary_class())(2) == 3); FIT_STATIC_TEST_CHECK(fit::capture_decay(1, 2)(binary_class())() == 3); FIT_TEST_CHECK(fit::capture_decay(1, 2)(binary_class())() == 3); FIT_STATIC_TEST_CHECK(fit::capture_decay(1)(binary_class())(2) == 3); FIT_TEST_CHECK(fit::capture_decay(1)(binary_class())(2) == 3); }
FIT_TEST_CASE() { int r = fit::compose(increment(), negate(), decrement(), decrement())(3); FIT_TEST_CHECK(r == 0); FIT_STATIC_TEST_CHECK(fit::compose(increment(), negate(), decrement(), decrement())(3) == 0); }
FIT_TEST_CASE() { FIT_TEST_CHECK(3 == fit::limit_c<2>(binary_pipable_constexpr)(1, 2)); FIT_STATIC_TEST_CHECK(3 == fit::limit_c<2>(binary_pipable_constexpr)(1, 2)); }
FIT_TEST_CASE() { FIT_STATIC_TEST_CHECK(fit::apply(binary_class(), 1, 2) == 3); FIT_TEST_CHECK(fit::apply(binary_class(), 1, 2) == 3); }
FIT_TEST_CASE() { FIT_TEST_CHECK(3 == (1 <sum> 2)); FIT_STATIC_TEST_CHECK(3 == (1 <sum> 2)); }
FIT_TEST_CASE() { STATIC_ASSERT_SAME(decltype(unary_int(false)), int); FIT_TEST_CHECK(unary_int(false) == 0); FIT_STATIC_TEST_CHECK(unary_int(false) == 0); }
FIT_TEST_CASE() { FIT_STATIC_TEST_CHECK(fit::apply_eval(binary_class(), fit::always(1), fit::always(2)) == 3); FIT_TEST_CHECK(fit::apply_eval(binary_class(), []{ return 1; }, []{ return 2;}) == 3); }