2
0
mirror of https://github.com/boostorg/hof.git synced 2026-01-24 18:02:20 +00:00
Files
hof/test/function.cpp

39 lines
686 B
C++

#include <fit/function.h>
#include <fit/partial.h>
#include <fit/infix.h>
#include <fit/pipable.h>
#include <memory>
#include "test.h"
FIT_STATIC_FUNCTION(sum_partial) = fit::partial([](int x, int y)
{
return x + y;
});
FIT_TEST_CASE()
{
FIT_TEST_CHECK(3 == sum_partial(1, 2));
FIT_TEST_CHECK(3 == sum_partial(1)(2));
}
FIT_STATIC_FUNCTION(add_one_pipable) = fit::pipable([](int x)
{
return x + 1;
});
FIT_TEST_CASE()
{
FIT_TEST_CHECK(3 == add_one_pipable(2));
FIT_TEST_CHECK(3 == (2 | add_one_pipable));
}
FIT_STATIC_FUNCTION(sum_infix) = fit::infix([](int x, int y)
{
return x + y;
});
FIT_TEST_CASE()
{
FIT_TEST_CHECK(3 == (1 <sum_infix> 2));
}