53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
|
#include <catch.hpp>
|
||
|
#include <alsk/alsk.h>
|
||
|
|
||
|
using namespace alsk::edsl;
|
||
|
|
||
|
struct Generate { int operator()() { return 0; } };
|
||
|
struct Select { int operator()(int a, int b) { return std::max(a, b); } };
|
||
|
|
||
|
TEST_CASE("edsl::IterSel") {
|
||
|
auto generate = makeOperand<int(), Generate>();
|
||
|
auto select = makeOperand<int(int, int), Select>();
|
||
|
|
||
|
auto e0 = iter(generate, 10).select(select);
|
||
|
using E0 = decltype(e0);
|
||
|
using S0 = alsk::S<alsk::IterSel, Generate, Select>;
|
||
|
using L0 = alsk::L<alsk::IterSel, int(), int(), int(int, int)>;
|
||
|
|
||
|
auto e1 = &(link<void(int)>(*generate) ->* select);
|
||
|
using E1 = decltype(e1);
|
||
|
using S1 = alsk::S<alsk::IterSel, Generate, Select>;
|
||
|
using L1 = alsk::L<alsk::IterSel, int(int), int(), int(int, int)>;
|
||
|
|
||
|
auto e2 = seq(link<void(int)>(*generate) ->* select);
|
||
|
using E2 = decltype(e2);
|
||
|
using S2 = alsk::S<alsk::IterSel, Generate, Select>;
|
||
|
using L2 = alsk::L<alsk::IterSel, int(int), int(), int(int, int)>;
|
||
|
|
||
|
SECTION("Construction") {
|
||
|
REQUIRE(std::is_same<E0::Struct, S0>{});
|
||
|
REQUIRE(std::is_same<E0::Links, L0>{});
|
||
|
REQUIRE(std::is_same<E0::Signature, int()>{});
|
||
|
|
||
|
REQUIRE(std::is_same<E1::Struct, S1>{});
|
||
|
REQUIRE(std::is_same<E1::Links, L1>{});
|
||
|
REQUIRE(std::is_same<E1::Signature, int(int)>{});
|
||
|
|
||
|
REQUIRE(std::is_same<E2::Struct, S2>{});
|
||
|
REQUIRE(std::is_same<E2::Links, L2>{});
|
||
|
REQUIRE(std::is_same<E2::Signature, int(int)>{});
|
||
|
}
|
||
|
|
||
|
SECTION("Setup") {
|
||
|
auto f0 = implement<alsk::exec::DynamicPool>(e0);
|
||
|
REQUIRE(f0.skeleton.n == 10);
|
||
|
|
||
|
auto f1 = implement<alsk::exec::DynamicPool>(e1);
|
||
|
REQUIRE(f1.skeleton.n == 0);
|
||
|
|
||
|
auto f2 = implement<alsk::exec::DynamicPool>(e2);
|
||
|
REQUIRE(f2.skeleton.n == 0);
|
||
|
}
|
||
|
}
|