/*
 * 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 "realposition.hh"

class RealPosition_test: public CxxTest::TestSuite
{
public:

  void test_compute(void)
  {
    Point3D null_point(0,0,0) ;
    ReferencePoint reference_point(1,2,3) ;
    Direction direction(Direction::south) ;
    Request request ;
    CalibrationRequest calibration_request(request, &reference_point,
                                           direction) ;

    PositioningAlgorithm *algo = new RealPosition() ;
    Result res ;

    // Empty request
    res = algo->compute(request) ;
    TS_ASSERT_EQUALS(res.get_position(), null_point) ;

    // Non-empty request
    Point3D point(3,2,1) ;
    request.set_real_position(point) ;
    res = algo->compute(request) ;
    TS_ASSERT_EQUALS(res.get_position(), point) ;

    // Calibration request
    res = algo->compute(calibration_request) ;
    TS_ASSERT_EQUALS(res.get_position(), reference_point) ;

    // CalibrationRequest casted to Request
    Request *request_ptr = static_cast<Request*>(&calibration_request) ;
    res = algo->compute(*request_ptr) ;
    TS_ASSERT_EQUALS(res.get_position(), reference_point) ;

    delete algo ;
  }

} ;
