mirror of
https://github.com/boostorg/hof.git
synced 2026-01-23 05:32:13 +00:00
64 lines
1.6 KiB
C++
64 lines
1.6 KiB
C++
#include <fit/compress.h>
|
|
#include "test.h"
|
|
|
|
struct max_f
|
|
{
|
|
template<class T, class U>
|
|
constexpr T operator()(T x, U y) const
|
|
{
|
|
return x > y ? x : y;
|
|
}
|
|
};
|
|
|
|
struct sum_f
|
|
{
|
|
template<class T, class U>
|
|
constexpr T operator()(T x, U y) const
|
|
{
|
|
return x + y;
|
|
}
|
|
};
|
|
|
|
FIT_TEST_CASE()
|
|
{
|
|
FIT_TEST_CHECK(fit::compress(max_f(), 0)(2, 3, 4, 5) == 5);
|
|
FIT_TEST_CHECK(fit::compress(max_f(), 0)(5, 4, 3, 2) == 5);
|
|
FIT_TEST_CHECK(fit::compress(max_f(), 0)(2, 3, 5, 4) == 5);
|
|
|
|
FIT_STATIC_TEST_CHECK(fit::compress(max_f(), 0)(2, 3, 4, 5) == 5);
|
|
FIT_STATIC_TEST_CHECK(fit::compress(max_f(), 0)(5, 4, 3, 2) == 5);
|
|
FIT_STATIC_TEST_CHECK(fit::compress(max_f(), 0)(2, 3, 5, 4) == 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(fit::compress(max_f())(5) == 5);
|
|
|
|
FIT_STATIC_TEST_CHECK(fit::compress(max_f())(5) == 5);
|
|
}
|
|
|
|
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()
|
|
{
|
|
FIT_TEST_CHECK(fit::compress(sum_f(), std::string())("hello", "-", "world") == "hello-world");
|
|
}
|