thesis version
This commit is contained in:
68
tests/index/index.cpp
Normal file
68
tests/index/index.cpp
Normal file
@ -0,0 +1,68 @@
|
||||
#include <catch.hpp>
|
||||
|
||||
#include <pfor/index/index.h>
|
||||
#include <pfor/index/operators.h>
|
||||
|
||||
TEST_CASE("Index") {
|
||||
pfor::Index it;
|
||||
pfor::index::Index<3> c3;
|
||||
|
||||
std::size_t i = 5;
|
||||
|
||||
SECTION("Index") {
|
||||
REQUIRE(it.eval(i) == i);
|
||||
}
|
||||
|
||||
SECTION("Basic operations") {
|
||||
SECTION("Plus") {
|
||||
REQUIRE((+it).eval(i) == i);
|
||||
}
|
||||
|
||||
SECTION("Minus") {
|
||||
REQUIRE((-it).eval(i) == -i);
|
||||
}
|
||||
|
||||
// SECTION("Not") {
|
||||
// REQUIRE((!it).eval(i) == !i);
|
||||
// }
|
||||
|
||||
// SECTION("BitNot") {
|
||||
// REQUIRE((~it).eval(i) == ~i);
|
||||
// }
|
||||
|
||||
SECTION("Addition") {
|
||||
REQUIRE((it+c3).eval(i) == i+3);
|
||||
REQUIRE((it+it).eval(i) == i+i);
|
||||
}
|
||||
|
||||
SECTION("Subtraction") {
|
||||
REQUIRE((it-c3).eval(i) == i-3);
|
||||
REQUIRE((it-it).eval(i) == 0);
|
||||
}
|
||||
|
||||
SECTION("Multiplication") {
|
||||
REQUIRE((it*c3).eval(i) == i*3);
|
||||
REQUIRE((it*it).eval(i) == i*i);
|
||||
}
|
||||
|
||||
// SECTION("Division") {
|
||||
// REQUIRE((it/c3).eval(i) == i/3);
|
||||
// REQUIRE((it/it).eval(i) == 1);
|
||||
// }
|
||||
|
||||
// SECTION("Modulo") {
|
||||
// REQUIRE((it%c3).eval(i) == i%3);
|
||||
// REQUIRE((it%it).eval(i) == 0);
|
||||
// }
|
||||
|
||||
// SECTION("LeftShift") {
|
||||
// REQUIRE((it<<c3).eval(i) == i<<3);
|
||||
// REQUIRE((it<<it).eval(i) == i<<i);
|
||||
// }
|
||||
|
||||
// SECTION("RightShift") {
|
||||
// REQUIRE((it>>c3).eval(i) == i>>3);
|
||||
// REQUIRE((it>>it).eval(i) == i>>i);
|
||||
// }
|
||||
}
|
||||
}
|
75
tests/index/traits.cpp
Normal file
75
tests/index/traits.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
#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>);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user