예제 #1
0
파일: lift.cpp 프로젝트: MORTAL2000/Fit
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);
}
예제 #2
0
파일: construct.cpp 프로젝트: sakishum/Fit
FIT_TEST_CASE()
{
    auto make = fit::construct<std::vector<int>>().by(fit::_1 * 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});
}
예제 #3
0
파일: alias.cpp 프로젝트: MORTAL2000/Fit
FIT_TEST_CASE()
{
    fit::alias<int> ai = 5;
    FIT_TEST_CHECK(fit::alias_value(ai) == 5);
    fit::alias_inherit<foo> af = foo{5};
    FIT_TEST_CHECK(fit::alias_value(af).i == 5);
}
예제 #4
0
파일: lift.cpp 프로젝트: MORTAL2000/Fit
FIT_TEST_CASE()
{
    auto my_max = FIT_LIFT(std::max);
    FIT_TEST_CHECK(my_max(3, 4) == std::max(3, 4));
    
    FIT_TEST_CHECK(FIT_LIFT(std::max)(3, 4) == std::max(3, 4));
    FIT_TEST_CHECK(FIT_LIFT(sum)(1, 2) == 3);
}
예제 #5
0
파일: pipable.cpp 프로젝트: MORTAL2000/Fit
FIT_TEST_CASE()
{
    FIT_TEST_CHECK(3 == (move_class()(1, 2)));
    FIT_TEST_CHECK(3 == (move_pipable(1, 2)));
    FIT_TEST_CHECK(3 == (1 | move_pipable(2)));
    FIT_TEST_CHECK(3 == (1 | fit::pipable(move_class())(2)));
    FIT_TEST_CHECK(3 == (fit::pipable(move_class())(1, 2)));
}
예제 #6
0
파일: lazy.cpp 프로젝트: wildpea/Fit
FIT_TEST_CASE()
{
    int i = 5;

    FIT_TEST_CHECK(fit::detail::id_transformer()(i)(0,0,0) == i);
    FIT_TEST_CHECK(fit::detail::pick_transformer(i)(0,0,0) == i);
    FIT_TEST_CHECK(fit::detail::lazy_transform(i, fit::pack(0,0,0)) == i);
}
예제 #7
0
파일: compress.cpp 프로젝트: wildpea/Fit
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);
}
예제 #8
0
파일: compress.cpp 프로젝트: wildpea/Fit
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);
}
예제 #9
0
파일: match.cpp 프로젝트: dopic/Fit
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);
};
예제 #10
0
파일: if.cpp 프로젝트: lllhhhqqq/Fit
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);
}
예제 #11
0
파일: match.cpp 프로젝트: dopic/Fit
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);
};
예제 #12
0
파일: implicit.cpp 프로젝트: dopic/Fit
FIT_TEST_CASE()
{
    float f = 1.5;
    int i = auto_cast(f);
    // auto_caster_foo x = 1;
    auto_caster_foo x = auto_cast(1);
    FIT_TEST_CHECK(1 == i);
    FIT_TEST_CHECK(1 == x.i);

}
예제 #13
0
파일: compress.cpp 프로젝트: wildpea/Fit
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);
}
예제 #14
0
파일: fuse.cpp 프로젝트: dopic/Fit
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)));
}
예제 #15
0
파일: indirect.cpp 프로젝트: MORTAL2000/Fit
FIT_TEST_CASE()
{
    FIT_TEST_CHECK(3 == fit::indirect(std::unique_ptr<binary_class>(new binary_class()))(1, 2));
    FIT_TEST_CHECK(3 == fit::reveal(fit::indirect(std::unique_ptr<binary_class>(new binary_class())))(1, 2));

    binary_class f;

    FIT_TEST_CHECK(3 == fit::indirect(&f)(1, 2));
    FIT_TEST_CHECK(3 == fit::reveal(fit::indirect(&f))(1, 2));
}
예제 #16
0
파일: lazy.cpp 프로젝트: wildpea/Fit
FIT_TEST_CASE()
{
    auto id =[](int i) {
        return i;
    };
    auto fi = std::bind(id, 5);

    FIT_TEST_CHECK(fit::detail::bind_transformer()(fi)(0,0,0) == id(5));
    FIT_TEST_CHECK(fit::detail::pick_transformer(fi)(0,0,0) == id(5));
    FIT_TEST_CHECK(fit::detail::lazy_transform(fi, fit::pack(0,0,0)) == id(5));
}
예제 #17
0
파일: lazy.cpp 프로젝트: wildpea/Fit
FIT_TEST_CASE()
{
    int i = 5;

    static_assert(std::is_reference<decltype(fit::detail::ref_transformer()(std::ref(i))(0,0,0))>::value, "Reference wrapper failed");
    static_assert(std::is_reference<decltype(fit::detail::pick_transformer(std::ref(i))(0,0,0))>::value, "Reference wrapper failed");
    static_assert(std::is_reference<decltype(fit::detail::lazy_transform(std::ref(i), fit::pack(0,0,0)))>::value, "Reference wrapper failed");

    FIT_TEST_CHECK(&fit::detail::ref_transformer()(std::ref(i))(0,0,0) == &i);
    FIT_TEST_CHECK(&fit::detail::pick_transformer(std::ref(i))(0,0,0) == &i);
    FIT_TEST_CHECK(&fit::detail::lazy_transform(std::ref(i), fit::pack(0,0,0)) == &i);
}
예제 #18
0
파일: construct.cpp 프로젝트: sakishum/Fit
FIT_TEST_CASE()
{
    auto make = fit::construct<std::tuple>().by(fit::_1 * 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));
}
예제 #19
0
파일: indirect.cpp 프로젝트: MORTAL2000/Fit
FIT_TEST_CASE()
{
    auto mf = std::make_shared<mutable_function>();
    fit::indirect(mf)(15);
    fit::indirect(mf)(2);
    FIT_TEST_CHECK(mf->value == 17);
}
예제 #20
0
파일: indirect.cpp 프로젝트: MORTAL2000/Fit
FIT_TEST_CASE()
{
    auto mf = mutable_function{};
    fit::indirect(&mf)(15);
    fit::indirect(&mf)(2);
    FIT_TEST_CHECK(mf.value == 17);
}
예제 #21
0
파일: lazy.cpp 프로젝트: wildpea/Fit
FIT_TEST_CASE()
{
    short i(6);

    int const k = 3;

    FIT_TEST_CHECK( fit::lazy(Y())( std::ref(i))() == 7 );
    FIT_TEST_CHECK( fit::lazy(Y())( std::ref(i))() == 8 );
    FIT_TEST_CHECK( fit::lazy(Y())( i,std::placeholders::_1)(k) == 38 );
    FIT_TEST_CHECK( fit::lazy(Y())( i,std::placeholders::_1, 9)(k) == 938 );

    global_result = 0;
    fit::lazy(Y())( i,std::placeholders::_1, 9, 4)(k);
    FIT_TEST_CHECK( global_result == 4938 );

}
예제 #22
0
파일: filter.cpp 프로젝트: MORTAL2000/Fit
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
}
예제 #23
0
파일: construct.cpp 프로젝트: sakishum/Fit
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);
}
예제 #24
0
파일: compose.cpp 프로젝트: jbrownson/Fit
FIT_TEST_CASE()
{
    STATIC_ASSERT_MOVE_ONLY(increment_movable);
    STATIC_ASSERT_MOVE_ONLY(decrement_movable);
    int r = fit::compose(increment_movable(), decrement_movable(), increment_movable())(3);
    FIT_TEST_CHECK(r == 4);
}
예제 #25
0
파일: compose.cpp 프로젝트: jbrownson/Fit
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);
}
예제 #26
0
파일: compose.cpp 프로젝트: jbrownson/Fit
FIT_TEST_CASE()
{
    const auto f = fit::compose([](int i) { return i+1; }, [](int i) { return i-1; }, [](int i) { return i+1; });
#ifndef _MSC_VER
    static_assert(std::is_empty<decltype(f)>::value, "Compose function not empty");
#endif
    int r = f(3);
    FIT_TEST_CHECK(r == 4);
}
예제 #27
0
파일: construct.cpp 프로젝트: sakishum/Fit
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
}
예제 #28
0
파일: combine.cpp 프로젝트: MORTAL2000/Fit
FIT_TEST_CASE()
{
    FIT_TEST_CHECK(
        fit::combine(
            fit::construct<std::tuple>(),
            fit::capture(1)(fit::construct<std::pair>()),
            fit::capture(2)(fit::construct<std::pair>())
        )(2, 4) 
        == std::make_tuple(std::make_pair(1, 2), std::make_pair(2, 4)));
}
예제 #29
0
파일: lazy.cpp 프로젝트: wildpea/Fit
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)) );
}
예제 #30
0
파일: combine.cpp 프로젝트: MORTAL2000/Fit
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)));
}