This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/tests/geo/TestHeading.cpp
FrankE 2e2c1a3004 new test cases
worked on all walkers
new helper methods
new distributions
some bugfixes
2016-02-02 21:43:15 +01:00

65 lines
1.2 KiB
C++

#ifdef WITH_TESTS
#include "../Tests.h"
#include "../../geo/Heading.h"
TEST(Heading, diff) {
// 180 degree turn
{
// Heading h1(0,0, 0,+1);
// Heading h2(0,0, 0,-1);
// ASSERT_NEAR(h1.getDiffHalfRAD(h2), M_PI, 0.001);
// ASSERT_NEAR(h2.getDiffHalfRAD(h1), M_PI, 0.001);
}
// ~180 degree turn
{
Heading h1(0,0, 0.00,+1);
Heading h2(0,1, -0.01,-1);
Heading h3(0,1, +0.01,-1);
ASSERT_NEAR(h1.getDiffHalfRAD(h2), M_PI, 0.01);
ASSERT_NEAR(h2.getDiffHalfRAD(h1), M_PI, 0.01);
ASSERT_NEAR(h1.getDiffHalfRAD(h3), M_PI, 0.01);
ASSERT_NEAR(h3.getDiffHalfRAD(h1), M_PI, 0.01);
}
}
TEST(Heading, ctor) {
// OK
Heading(0);
Heading(1);
Heading(2);
Heading(3);
Heading(4);
Heading(5);
Heading(6);
Heading(2*M_PI-0.0001);
// out of range
ASSERT_THROW(Heading(-0.0001), std::exception);
ASSERT_THROW(Heading(2*M_PI+0.0001), std::exception);
}
TEST(Heading, eq) {
ASSERT_EQ(Heading(0), Heading(0));
ASSERT_EQ(Heading(1), Heading(1));
ASSERT_EQ(Heading(2), Heading(2));
}
TEST(Heading, random) {
// two random values must not be equal
ASSERT_NE(Heading::rnd(), Heading::rnd());
ASSERT_NE(Heading::rnd(), Heading::rnd());
ASSERT_NE(Heading::rnd(), Heading::rnd());
}
#endif