alsk/tests/skeleton/link/args.cpp

72 lines
2.6 KiB
C++
Raw Normal View History

2021-05-10 16:14:13 +00:00
#include <catch.hpp>
#include <alsk/skeleton/link/args.h>
#include <alsk/context/context.h>
using namespace alsk;
using tmp::Pack;
TEST_CASE("ArgType") {
using P = Pack<struct A, struct B, struct C>;
using R = Pack<struct D, struct E, struct F>;
using X = Pack<struct G, struct H>;
using Placeholders = arg::Placeholders<P, R, X>;
REQUIRE(std::is_same<struct A, ArgType<arg::P<0>, Placeholders>>{});
REQUIRE(std::is_same<struct B, ArgType<arg::P<1>, Placeholders>>{});
REQUIRE(std::is_same<struct C, ArgType<arg::P<2>, Placeholders>>{});
REQUIRE(std::is_same<struct D, ArgType<arg::R<0>, Placeholders>>{});
REQUIRE(std::is_same<struct E, ArgType<arg::R<1>, Placeholders>>{});
REQUIRE(std::is_same<struct F, ArgType<arg::R<2>, Placeholders>>{});
REQUIRE(std::is_same<struct H, ArgType<arg::RNG, Placeholders>>{});
}
TEST_CASE("ArgGet") {
std::tuple<int, int, int> p{0, 1, 2};
std::tuple<int, int, int> r{3, 4, 5};
std::tuple<int, int> x{6, 7};
REQUIRE(std::get<0>(p) == ArgGet<arg::P<0>>::get(p, r, x));
REQUIRE(std::get<1>(p) == ArgGet<arg::P<1>>::get(p, r, x));
REQUIRE(std::get<2>(p) == ArgGet<arg::P<2>>::get(p, r, x));
REQUIRE(std::get<0>(r) == ArgGet<arg::R<0>>::get(p, r, x));
REQUIRE(std::get<1>(r) == ArgGet<arg::R<1>>::get(p, r, x));
REQUIRE(std::get<2>(r) == ArgGet<arg::R<2>>::get(p, r, x));
REQUIRE(std::get<1>(x) == ArgGet<arg::RNG>::get(p, r, x));
}
TEST_CASE("PRFilter") {}
TEST_CASE("RealType") {
using P = Pack<struct A, struct B, struct C>;
using R = Pack<struct D, struct E, struct F>;
using X = Pack<struct G, struct H>;
using Placeholders = arg::Placeholders<P, R, X>;
REQUIRE(std::is_same<struct A, RealType<arg::P<0>, Placeholders>>{});
REQUIRE(std::is_same<struct B, RealType<arg::P<1>, Placeholders>>{});
REQUIRE(std::is_same<struct C, RealType<arg::P<2>, Placeholders>>{});
REQUIRE(std::is_same<struct D, RealType<arg::R<0>, Placeholders>>{});
REQUIRE(std::is_same<struct E, RealType<arg::R<1>, Placeholders>>{});
REQUIRE(std::is_same<struct F, RealType<arg::R<2>, Placeholders>>{});
REQUIRE(std::is_same<struct H, RealType<arg::RNG, Placeholders>>{});
REQUIRE(std::is_same<struct _, RealType<struct _, Placeholders>>{});
}
TEST_CASE("RealSignature") {
using P = Pack<struct A, struct B, struct C>;
using R = Pack<struct D, struct E, struct F>;
using X = Pack<struct G, struct H>;
using Placeholders = arg::Placeholders<P, R, X>;
using S = int&(arg::P<0>, arg::R<1>, arg::P<2>, arg::RNG, struct _);
using Q = std::function<int&(struct A, struct E, struct C, struct H, struct _)>;
REQUIRE(std::is_same<Q, RealSignature<S, Placeholders>>{});
}
TEST_CASE("Returns") {}
TEST_CASE("Execute") {}