pfor/tests/index/traits.cpp

76 lines
2.2 KiB
C++

#include <catch.hpp>
#include "../common.h"
#include <pfor/index/traits.h>
#include <pfor/index/operators.h>
TEST_CASE("Index/Traits") {
pfor::Index it;
pfor::index::Index<2> c2;
pfor::index::Index<3> c3;
pfor::index::Index<4> c4;
pfor::index::Index<5> c5;
std::size_t i = 5;
using C2 = decltype(c2);
using C3 = decltype(c3);
using C4 = decltype(c4);
using C5 = decltype(c5);
using E0 = decltype(it);
using E1 = decltype(it+c3);
using E2 = decltype(it*c3);
using E3 = decltype(it*c3+c5);
using E4 = decltype((it+c3)*c5);
using E5 = decltype(((it+c3)*c5+c4)*c2);
using E6 = decltype(((it+it)+c3)+(c2*it+c5));
using E7 = decltype(((c2+c3)*c4)*(it+c5));
using F1 = decltype(it*it);
using F2 = decltype((it+c3)*(it+c2));
using F3 = decltype((it*it+c3)*(c2+it*it));
SECTION("IsConstant") {
REQUIRE(pfor::index::isConstant<C2>);
REQUIRE(pfor::index::isConstant<C3>);
REQUIRE(pfor::index::isConstant<C4>);
REQUIRE(pfor::index::isConstant<C5>);
REQUIRE_FALSE(pfor::index::isConstant<E0>);
REQUIRE_FALSE(pfor::index::isConstant<E1>);
REQUIRE_FALSE(pfor::index::isConstant<E2>);
REQUIRE_FALSE(pfor::index::isConstant<E3>);
REQUIRE_FALSE(pfor::index::isConstant<E4>);
REQUIRE_FALSE(pfor::index::isConstant<E5>);
REQUIRE_FALSE(pfor::index::isConstant<E6>);
REQUIRE_FALSE(pfor::index::isConstant<E7>);
}
SECTION("IsLinear") {
REQUIRE(pfor::index::isLinear<C2>);
REQUIRE(pfor::index::isLinear<C3>);
REQUIRE(pfor::index::isLinear<C4>);
REQUIRE(pfor::index::isLinear<C5>);
REQUIRE(pfor::index::isLinear<E0>);
REQUIRE(pfor::index::isLinear<E1>);
REQUIRE(pfor::index::isLinear<E2>);
REQUIRE(pfor::index::isLinear<E3>);
REQUIRE(pfor::index::isLinear<E4>);
REQUIRE(pfor::index::isLinear<E5>);
REQUIRE(pfor::index::isLinear<E6>);
REQUIRE(pfor::index::isLinear<E7>);
REQUIRE_FALSE(pfor::index::isLinear<F1>);
REQUIRE_FALSE(pfor::index::isLinear<F2>);
REQUIRE_FALSE(pfor::index::isLinear<F3>);
}
SECTION("AllLinear") {
TEST(REQUIRE, pfor::index::allLinear<C2, C3, C4, C5>);
TEST(REQUIRE, pfor::index::allLinear<E0, E1, E2, E3, E4, E5, E6, E7>);
TEST(REQUIRE_FALSE, pfor::index::allLinear<E0, E1, E2, F1, E3, E4, E5, E6>);
}
}