sagoma/TestChangeCoord.h
boyska 3f9b48c377 add unit tests support
you need cxxtest or they will be skipped
one bug found using those tests!
2017-01-12 17:13:02 +01:00

48 lines
1.2 KiB
C++

#include <math.h>
#ifdef HAS_OPENCV3
#include <opencv2/core.hpp> //Any OPENCV3 code
#else
#include <opencv2/core/core.hpp> //Any Opencv2 code
#endif
using namespace cv;
#include <cxxtest/TestSuite.h>
#include "geometry.h"
class TestChangeCoord : public CxxTest::TestSuite
{
public:
void testOrigin(void)
{
Point origin = Point(1,2);
//the angle here is actually irrelevant
Point p = map_point(M_PI/2, origin, origin);
TS_ASSERT_EQUALS(p.x, 0);
TS_ASSERT_EQUALS(p.y, 0);
}
void testOnlyTranslation(void)
{
Point origin = Point(1,2);
Point p = map_point(0, origin, Point(0,0));
TS_ASSERT_EQUALS(p.x, -1);
TS_ASSERT_EQUALS(p.y, -2);
}
void testOnlyRotationOrigin(void)
{
Point origin = Point(0,0);
Point p = map_point(M_PI, origin, origin);
TS_ASSERT_EQUALS(p.x, 0);
TS_ASSERT_EQUALS(p.y, 0);
}
void testOnlyRotation(void)
{
Point origin = Point(0,0);
Point p = map_point(M_PI, origin, Point(1,2));
TS_ASSERT_EQUALS(p.x, -1);
TS_ASSERT_EQUALS(p.y, -2);
}
};