/* * 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 #include "area.hh" #include "building.hh" class Area_test: public CxxTest::TestSuite { public: void test_constructors(void) { // Default constructor Area a1 ; Area a2(nullptr, "Unnamed area", Point3D(0,0,0), Point3D(0,0,0)) ; TS_ASSERT_EQUALS(a1, a2) ; // Copy constructor Building b1 ; Area a3(&b1, "My Area", Point3D(3,2,1), Point3D(0,1,2)) ; Area a4(a3) ; TS_ASSERT_EQUALS(a3, a4) ; } void test_accessors(void) { // Simple read accessors Building b1("Numerica") ; Area a1(&b1, "My Area", Point3D(1,3,5), Point3D(8,7,4)) ; TS_ASSERT_EQUALS(a1.get_building(), &b1) ; TS_ASSERT_EQUALS(a1.get_name(), "My Area") ; TS_ASSERT_EQUALS(a1.get_p_min(), Point3D(1,3,4)) ; TS_ASSERT_EQUALS(a1.get_p_max(), Point3D(8,7,5)) ; // 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") ; 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)) ; } void test_contains_point(void) { Building b1("Numerica") ; Area a1(&b1, "My Area", Point3D(0,0,0), Point3D(3,3,3)) ; 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") ; Point3D point3d1(1,3,5) ; Point3D point3d2(8,7,4) ; Area a1(&b1, "My Area", point3d1, point3d2) ; Area a2(&b1, "My Area", point3d1, point3d2) ; TS_ASSERT_EQUALS(a1, a2) ; // != Area a3(&b1, "My Area", Point3D(1,0,5), Point3D(8,7,4)) ; TS_ASSERT(a1 != a3) ; // = a2 = a3 ; TS_ASSERT_EQUALS(a2, a3) ; } } ;