47 lines
1.1 KiB
C++
47 lines
1.1 KiB
C++
|
#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&)>{});
|
||
|
}
|
||
|
}
|
||
|
}
|