alsk/tests/edsl/op/operand.cpp

47 lines
1.1 KiB
C++
Raw Normal View History

2021-05-10 16:14:13 +00:00
#include <catch.hpp>
#include <alsk/alsk.h>
using namespace alsk::edsl;
struct A { void operator()() {} };
struct B { int operator()(float) { return {}; } };
void f() {}
TEST_CASE("edsl::Operand") {
SECTION("from function-object") {
{
auto x = makeOperand<A>();
using X = decltype(x);
REQUIRE(std::is_same<X::Struct, A>{});
REQUIRE(std::is_same<X::Links, void()>{});
}
{
auto x = makeOperand<int(alsk::arg::P<0>), B>();
using X = decltype(x);
REQUIRE(std::is_same<X::Struct, B>{});
REQUIRE(std::is_same<X::Links, int(alsk::arg::P<0>)>{});
}
}
SECTION("from function") {
{
auto x = alskMakeOperand(f);
using X = decltype(x);
REQUIRE(std::is_same<X::Struct, Fn<void(&)(), f>>{});
REQUIRE(std::is_same<X::Links, void()>{});
}
{
using Signature = int const&(&)(int const&, int const&);
auto x = makeOperand<Signature, std::min<int>>();
using X = decltype(x);
REQUIRE(std::is_same<X::Struct, Fn<Signature, std::min<int>>>{});
REQUIRE(std::is_same<X::Links, int const&(int const&, int const&)>{});
}
}
}