#include #include using namespace alsk; using tmp::Pack; struct Int { int v; Int(int v): v{v} {} operator int() const { return v; } }; struct A: Int {}; struct B: Int {}; struct C: Int {}; struct D: Int {}; struct E: Int {}; struct F: Int {}; struct G: Int {}; struct H: Int {}; struct I: Int {}; template struct Unary { template R operator()(T a) { return{a+1}; } }; template struct Binary { template R operator()(T a, U b) { return{a+b}; } }; template<> struct Binary { template void operator()(T, U) {} }; using S_ = S, Binary>, Unary, S, S, Binary>, Unary > >; using L1 = L(arg::P<1>, arg::P<2>), D(arg::P<1>), E(arg::R<0>, arg::P<0>) >; using L2 = F(arg::P<2>); using L31 = G(arg::P<0>, arg::P<2>); using L32 = L(arg::R<0>, arg::P<1>), H(arg::P<0>), void(arg::P<0>, arg::P<1>) >; using L33 = I(arg::R<0>); using L3 = L(arg::R<1>, arg::P<0>, arg::R<0>), L31, L32, L33 >; using L_ = L(A, B, C), L1, L2, L3 >; TEST_CASE("LinksToReturnTypes") { REQUIRE(std::is_same, impl::LinksToReturnTypes::type>{}); REQUIRE(std::is_same, impl::LinksToReturnTypes::type>{}); REQUIRE(std::is_same, impl::LinksToReturnTypes::type>{}); REQUIRE(std::is_same, impl::LinksToReturnTypes::type>{}); REQUIRE(std::is_same, impl::LinksToReturnTypes::type>{}); REQUIRE(std::is_same, impl::LinksToReturnTypes::type>{}); REQUIRE(std::is_same, impl::LinksToReturnTypes::type>{}); REQUIRE(std::is_same, impl::LinksToReturnTypes::type>{}); } using T_ = Serial(A, B, C), // 1 Fun(B, C), Fun, D(arg::P<1>)>, Fun, E(arg::R<0>, arg::P<0>)> >, E(arg::P<1>, arg::P<2>)>, // 2 Fun, F(arg::P<2>)>, // 3 Fun(F, A, E), Fun, G(arg::P<0>, arg::P<2>)>, Fun(G, A), Fun, H(arg::P<0>)>, Fun, void(arg::P<0>, arg::P<1>)> >, H(arg::R<0>, arg::P<1>)>, Fun, I(arg::R<0>)> >, I(arg::R<1>, arg::P<0>, arg::R<0>)> >; template using TS_ = S_; template using TL_ = L_; TEST_CASE("BuildSkeleton") { using T1 = BuildSkeleton::skeleton, Pack<>>; using T2 = BuildSkeletonT; REQUIRE(std::is_same{}); REQUIRE(std::is_same{}); } TEST_CASE("TreeFromSkeleton") { SECTION("simple") { struct F {}; using Struct = S; using Links = L; using Skel = BuildSkeletonT; using Expected = tmp::Tree< Branch, tmp::Tree> >; using Result = TreeFromSkeleton; REQUIRE(std::is_same{}); } SECTION("with links") { struct F {}; struct G {}; using Struct = S>; using Links = L(int&, int), L(arg::P<1>, arg::P<0>), long(arg::P<1>, arg::P<0>), int(arg::R<0>)>>; using Skel = BuildSkeletonT; using Expected = tmp::Tree< Branch(int&, int)>, tmp::Tree< Branch(int, int&), int(arg::P<1>, arg::P<0>)>, tmp::Tree, arg::P<0>)>>, tmp::Tree)>> > >; using Result = TreeFromSkeleton; REQUIRE(std::is_same{}); } SECTION("complex") { struct A0 {}; struct A1 {}; struct A2 {}; struct A3 {}; struct R {}; using Struct = S>, A0, S>; using Links = L>, R(), L>; using Skel = BuildSkeletonT; using Expected = tmp::Tree< Branch, tmp::Tree>, tmp::Tree< Branch, tmp::Tree< Branch, tmp::Tree>, tmp::Tree> > >, tmp::Tree>, tmp::Tree< Branch, tmp::Tree>, tmp::Tree> > >; using Result = TreeFromSkeleton; REQUIRE(std::is_same{}); } } TEST_CASE("ToSkeleton") { struct A0 {}; struct A1 {}; struct A2 {}; struct A3 {}; struct R {}; using Struct = S>, A0, S>; using Links = L>, R(), L>; using Expected = BuildSkeletonT; using Input = tmp::Tree< Branch, tmp::Tree>, tmp::Tree< Branch, tmp::Tree< Branch, tmp::Tree>, tmp::Tree> > >, tmp::Tree>, tmp::Tree< Branch, tmp::Tree>, tmp::Tree> > >; using Result = SkeletonFromTree; REQUIRE(std::is_same{}); REQUIRE(std::is_same>>{}); } TEST_CASE("SkeletonParallelHeight") { SECTION("serial") { struct F {}; struct G {}; using Struct = S>; using Links = L(int&, int), L(arg::P<1>, arg::P<0>), long(arg::P<1>, arg::P<0>), int(arg::R<0>)>>; using Skel = BuildSkeletonT; REQUIRE(skeletonParallelHeight == 0); } SECTION("par2") { struct A0 {}; struct A1 {}; struct A2 {}; using Struct = S>, S>; using Links = L>, L>; using Skel = BuildSkeletonT; REQUIRE(skeletonParallelHeight == 2); } SECTION("par4") { struct A0 {}; using Struct = S>>>; using Links = L>>>; using Skel = BuildSkeletonT; REQUIRE(skeletonParallelHeight == 4); } SECTION("complex") { struct A0 {}; using Struct = S>, S>>>>; using Links = L>, L>>>>; using Skel = BuildSkeletonT; REQUIRE(skeletonParallelHeight == 3); } }