37 lines
932 B
C++
37 lines
932 B
C++
#include <cxxtest/TestSuite.h>
|
|
|
|
#include "minmax.hh"
|
|
|
|
class MinMax_test: public CxxTest::TestSuite
|
|
{
|
|
public:
|
|
|
|
void test_trilaterate(void)
|
|
{
|
|
Point3D start(0,0,0), stop(10,10,4) ;
|
|
float step = 0.5 ;
|
|
TrilaterationMethod *minmax = new MinMax(start, stop, step) ;
|
|
|
|
AccessPoint
|
|
ap1(Point3D(0,0,0)),
|
|
ap2(Point3D(10,0,0)),
|
|
ap3(Point3D(0,10,0)),
|
|
ap4(Point3D(5,5,4)) ;
|
|
std::tr1::unordered_map<AccessPoint*, float> ap_distances ;
|
|
ap_distances[&ap1] = 7.071 ;
|
|
ap_distances[&ap2] = 7.071 ;
|
|
ap_distances[&ap3] = 7.071 ;
|
|
ap_distances[&ap4] = 4 ;
|
|
Point3D wanted_result(5,5,0) ;
|
|
|
|
Point3D result = minmax->trilaterate(ap_distances) ;
|
|
// Wrong with a step of 0.1 (for this test case):
|
|
TS_ASSERT_EQUALS(result, wanted_result) ;
|
|
// We can then use something like that:
|
|
//TS_ASSERT_LESS_THAN(result.distance(wanted_result), 0.01) ;
|
|
|
|
delete minmax ;
|
|
}
|
|
|
|
} ;
|