66 lines
2.3 KiB
C++
Executable File
66 lines
2.3 KiB
C++
Executable File
#include "catch.hpp"
|
|
#include "simulation/coordinates.h"
|
|
|
|
TEST_CASE("Coordinates", "[Coordinates]") {
|
|
SECTION("Cartesian Coordinates") {
|
|
WHEN("A cartesian Cordinate is created") {
|
|
blitz::TinyVector<double, 3> c_blitz(0., 1., 3.);
|
|
CartesianCoordinate c(c_blitz);
|
|
|
|
THEN("The correct cartesian entries can be reported") {
|
|
REQUIRE(c.cartesianEntries()[0] == c_blitz(0));
|
|
REQUIRE(c.cartesianEntries()[1] == c_blitz(1));
|
|
REQUIRE(c.cartesianEntries()[2] == c_blitz(2));
|
|
}
|
|
|
|
THEN("The correct cylinder entries can be reported") {
|
|
REQUIRE(c.cylinderEntries()[0] == 1.);
|
|
REQUIRE(c.cylinderEntries()[1] == M_PI / 2.);
|
|
REQUIRE(c.cylinderEntries()[2] == c_blitz(2));
|
|
}
|
|
}
|
|
WHEN("A cordinate is added to itself") {
|
|
blitz::TinyVector<double, 3> c_blitz(0., 1., 3.);
|
|
CartesianCoordinate c(c_blitz);
|
|
c.add(c);
|
|
|
|
THEN("double the original cartesian entries are reported") {
|
|
REQUIRE(c.cartesianEntries()[0] == 2 * c_blitz(0));
|
|
REQUIRE(c.cartesianEntries()[1] == 2 * c_blitz(1));
|
|
REQUIRE(c.cartesianEntries()[2] == 2 * c_blitz(2));
|
|
}
|
|
}
|
|
}
|
|
|
|
SECTION("Cylinder Coordinates") {
|
|
WHEN("A cylinder Cordinate is created") {
|
|
blitz::TinyVector<double, 3> c_blitz(1., M_PI / 2., 3.);
|
|
CylinderCoordinate c(c_blitz);
|
|
|
|
THEN("The correct cylinder entries can be reported") {
|
|
REQUIRE(c.cylinderEntries()[0] == c_blitz(0));
|
|
REQUIRE(c.cylinderEntries()[1] == c_blitz(1));
|
|
REQUIRE(c.cylinderEntries()[2] == c_blitz(2));
|
|
}
|
|
|
|
THEN("The correct cartesian entries can be reported") {
|
|
REQUIRE(c.cartesianEntries()[0] == Approx(0).margin(0.0001));
|
|
REQUIRE(c.cartesianEntries()[1] == Approx(1.));
|
|
REQUIRE(c.cartesianEntries()[2] == c_blitz(2));
|
|
}
|
|
}
|
|
|
|
WHEN("A cordinate is added to itself") {
|
|
blitz::TinyVector<double, 3> c_blitz(1., 3 * M_PI / 2., 3.);
|
|
CylinderCoordinate c(c_blitz);
|
|
c.add(c);
|
|
THEN(
|
|
"double the original cartesian entries are reported, exept in "
|
|
"angle") {
|
|
REQUIRE(c.cylinderEntries()[0] == 2 * c_blitz(0));
|
|
REQUIRE(c.cylinderEntries()[1] == Approx(M_PI));
|
|
REQUIRE(c.cylinderEntries()[2] == 2 * c_blitz(2));
|
|
}
|
|
}
|
|
}
|
|
} |