2013-06-22 23:30:17 +02:00
|
|
|
/*
|
|
|
|
* 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
|
2016-11-03 05:10:34 +01:00
|
|
|
* https://code.lm7.fr/mcy/owlps/src/master/COPYRIGHT.t2t
|
2013-06-22 23:30:17 +02:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2010-02-02 12:51:50 +01:00
|
|
|
#include <cxxtest/TestSuite.h>
|
|
|
|
|
|
|
|
#include "area.hh"
|
|
|
|
#include "building.hh"
|
|
|
|
|
|
|
|
class Area_test: public CxxTest::TestSuite
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
void test_constructors(void)
|
|
|
|
{
|
|
|
|
// Default constructor
|
|
|
|
Area a1 ;
|
2014-05-13 23:50:53 +02:00
|
|
|
Area a2(nullptr, "Unnamed area", Point3D(0,0,0), Point3D(0,0,0)) ;
|
2010-02-02 12:51:50 +01:00
|
|
|
TS_ASSERT_EQUALS(a1, a2) ;
|
|
|
|
|
|
|
|
// Copy constructor
|
|
|
|
Building b1 ;
|
2010-02-04 18:46:23 +01:00
|
|
|
Area a3(&b1, "My Area", Point3D(3,2,1), Point3D(0,1,2)) ;
|
2010-02-02 12:51:50 +01:00
|
|
|
Area a4(a3) ;
|
|
|
|
TS_ASSERT_EQUALS(a3, a4) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_accessors(void)
|
|
|
|
{
|
|
|
|
// Simple read accessors
|
|
|
|
Building b1("Numerica") ;
|
2010-02-04 18:46:23 +01:00
|
|
|
Area a1(&b1, "My Area", Point3D(1,3,5), Point3D(8,7,4)) ;
|
2010-02-02 12:51:50 +01:00
|
|
|
TS_ASSERT_EQUALS(a1.get_building(), &b1) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_name(), "My Area") ;
|
2010-02-04 18:46:23 +01:00
|
|
|
TS_ASSERT_EQUALS(a1.get_p_min(), Point3D(1,3,4)) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_p_max(), Point3D(8,7,5)) ;
|
2010-02-02 12:51:50 +01:00
|
|
|
|
|
|
|
// Write & read accessors
|
|
|
|
Building b2("Numerica 2") ;
|
|
|
|
a1.set_building(&b2) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_building(), &b2) ;
|
|
|
|
a1.set_name("My new Area") ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_name(), "My new Area") ;
|
|
|
|
|
2010-02-04 18:46:23 +01:00
|
|
|
Point3D point3d1(56,32,49) ;
|
|
|
|
Point3D point3d2(99,44,77) ;
|
|
|
|
a1.set_coordinates(point3d1, point3d2) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_p_min(), point3d1) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_p_max(), point3d2) ;
|
|
|
|
|
|
|
|
a1.set_coordinates(point3d2, point3d1) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_p_min(), point3d1) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_p_max(), point3d2) ;
|
|
|
|
|
|
|
|
Point3D point3d3(9,4,2) ;
|
|
|
|
Point3D point3d4(1,7,1) ;
|
|
|
|
a1.set_coordinates(point3d3, point3d4) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_p_min(), Point3D(1,4,1)) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_p_max(), Point3D(9,7,2)) ;
|
|
|
|
|
|
|
|
a1.set_coordinates(point3d4, point3d3) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_p_min(), Point3D(1,4,1)) ;
|
|
|
|
TS_ASSERT_EQUALS(a1.get_p_max(), Point3D(9,7,2)) ;
|
2010-02-02 12:51:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_contains_point(void)
|
|
|
|
{
|
|
|
|
Building b1("Numerica") ;
|
2010-02-04 18:46:23 +01:00
|
|
|
Area a1(&b1, "My Area", Point3D(0,0,0), Point3D(3,3,3)) ;
|
2010-02-02 12:51:50 +01:00
|
|
|
|
|
|
|
Point3D p01(0,0,0) ;
|
|
|
|
TS_ASSERT(a1.contains_point(p01)) ;
|
|
|
|
Point3D p02(3,3,3) ;
|
|
|
|
TS_ASSERT(a1.contains_point(p02)) ;
|
|
|
|
Point3D p03(2,2,2) ;
|
|
|
|
TS_ASSERT(a1.contains_point(p03)) ;
|
|
|
|
Point3D p04(0,2,1) ;
|
|
|
|
TS_ASSERT(a1.contains_point(p04)) ;
|
|
|
|
|
|
|
|
Point3D p11(-1,0,0) ;
|
|
|
|
TS_ASSERT(! a1.contains_point(p11)) ;
|
|
|
|
Point3D p12(3.1,3.2,3.3) ;
|
|
|
|
TS_ASSERT(! a1.contains_point(p12)) ;
|
|
|
|
Point3D p13(2,3.3,2) ;
|
|
|
|
TS_ASSERT(! a1.contains_point(p13)) ;
|
|
|
|
Point3D p14(2,2,3.5) ;
|
|
|
|
TS_ASSERT(! a1.contains_point(p14)) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void test_operators(void)
|
|
|
|
{
|
|
|
|
// ==
|
|
|
|
Building b1("Numerica") ;
|
2010-02-04 18:46:23 +01:00
|
|
|
Point3D point3d1(1,3,5) ;
|
|
|
|
Point3D point3d2(8,7,4) ;
|
|
|
|
Area a1(&b1, "My Area", point3d1, point3d2) ;
|
|
|
|
Area a2(&b1, "My Area", point3d1, point3d2) ;
|
2010-02-02 12:51:50 +01:00
|
|
|
TS_ASSERT_EQUALS(a1, a2) ;
|
|
|
|
|
|
|
|
// !=
|
2010-02-04 18:46:23 +01:00
|
|
|
Area a3(&b1, "My Area", Point3D(1,0,5), Point3D(8,7,4)) ;
|
2010-03-05 09:30:29 +01:00
|
|
|
TS_ASSERT(a1 != a3) ;
|
2010-02-02 12:51:50 +01:00
|
|
|
|
|
|
|
// =
|
|
|
|
a2 = a3 ;
|
|
|
|
TS_ASSERT_EQUALS(a2, a3) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
} ;
|