owlps/owlps-positioner/tests/minmax_test.hh

50 lines
1.5 KiB
C++

/*
* This file is part of the Owl Positioning System (OwlPS) project.
* It is subject to the copyright notice and license terms in the
* COPYRIGHT.t2t file found in the top-level directory of this
* distribution and at
* https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
* No part of the OwlPS Project, including this file, may be copied,
* modified, propagated, or distributed except according to the terms
* contained in the COPYRIGHT.t2t file; the COPYRIGHT.t2t file must be
* distributed along with this file, either separately or by replacing
* this notice by the COPYRIGHT.t2t file's contents.
*/
#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) ;
CapturePoint
ap1(Point3D(0,0,0)),
ap2(Point3D(10,0,0)),
ap3(Point3D(0,10,0)),
ap4(Point3D(5,5,4)) ;
std::unordered_map<const CapturePoint*, 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 ;
}
} ;