90 lines
1.9 KiB
C++
90 lines
1.9 KiB
C++
#include <cxxtest/TestSuite.h>
|
|
|
|
#include "referencepoint.hh"
|
|
#include "calibrationmeasurement.hh"
|
|
|
|
class ReferencePoint_test: public CxxTest::TestSuite
|
|
{
|
|
public:
|
|
|
|
void test_constructors(void)
|
|
{
|
|
// Default constructor
|
|
ReferencePoint rp00 ;
|
|
ReferencePoint rp01(0, 0, 0) ;
|
|
TS_ASSERT_EQUALS(rp00, rp01) ;
|
|
|
|
// Copy constructor
|
|
ReferencePoint rp1(1, 2, 3) ;
|
|
ReferencePoint rp2(rp1) ;
|
|
TS_ASSERT_EQUALS(rp1, rp2) ;
|
|
|
|
// Point3D copy constructor
|
|
Point3D p0(5, 3, 8) ;
|
|
ReferencePoint rp4(p0) ;
|
|
TS_ASSERT_EQUALS(p0, rp4) ;
|
|
|
|
// 3-float array constructor
|
|
float coord[3] = {1, 2, 3} ;
|
|
ReferencePoint rp3(coord) ;
|
|
TS_ASSERT_EQUALS(rp1, rp3) ;
|
|
}
|
|
|
|
|
|
void test_accessors(void)
|
|
{
|
|
// Simple read accessors
|
|
ReferencePoint rp1(1, 3, 5) ;
|
|
TS_ASSERT_EQUALS(rp1.get_x(), 1) ;
|
|
TS_ASSERT_EQUALS(rp1.get_y(), 3) ;
|
|
TS_ASSERT_EQUALS(rp1.get_z(), 5) ;
|
|
|
|
// Write & read accessors
|
|
CalibrationMeasurement cm1, cm2, cm3 ;
|
|
rp1.add_measurement(&cm1) ;
|
|
rp1.add_measurement(&cm2) ;
|
|
rp1.add_measurement(&cm3) ;
|
|
std::vector<CalibrationMeasurement*> vcm1 ;
|
|
vcm1.push_back(&cm1) ;
|
|
vcm1.push_back(&cm2) ;
|
|
vcm1.push_back(&cm3) ;
|
|
TS_ASSERT_EQUALS(rp1.get_measurements(), vcm1) ;
|
|
rp1.set_x(42) ;
|
|
TS_ASSERT_EQUALS(rp1.get_x(), 42) ;
|
|
rp1.set_y(321) ;
|
|
TS_ASSERT_EQUALS(rp1.get_y(), 321) ;
|
|
rp1.set_z(98) ;
|
|
TS_ASSERT_EQUALS(rp1.get_z(), 98) ;
|
|
}
|
|
|
|
|
|
void test_operators(void)
|
|
{
|
|
// ==
|
|
ReferencePoint rp1(42, 21, 19) ;
|
|
ReferencePoint rp2(42, 21, 19) ;
|
|
TS_ASSERT_EQUALS(rp1, rp2) ;
|
|
|
|
// !=
|
|
ReferencePoint rp3(1, 4, 7) ;
|
|
TS_ASSERT_DIFFERS(rp1, rp3) ;
|
|
|
|
// =
|
|
rp2 = rp3 ;
|
|
TS_ASSERT_EQUALS(rp2, rp3) ;
|
|
|
|
// <
|
|
TS_ASSERT_LESS_THAN(rp2, rp1) ;
|
|
|
|
// <=
|
|
TS_ASSERT_LESS_THAN_EQUALS(rp2, rp1) ;
|
|
|
|
// >
|
|
TS_ASSERT(rp1 > rp2) ;
|
|
|
|
// >=
|
|
TS_ASSERT(rp1 >= rp2) ;
|
|
}
|
|
|
|
} ;
|