This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/tests/grid/TestBBox.cpp
2016-01-21 20:01:20 +01:00

48 lines
1.1 KiB
C++
Executable File

#ifdef WITH_TESTS
#include "../Tests.h"
#include "../../grid/GridNodeBBox.h"
TEST(BBox, equals) {
GridNodeBBox bb1(GridPoint(2,2,2), 2);
GridNodeBBox bb2(GridPoint(2,2,2), 2);
GridNodeBBox bb3(GridPoint(3,2,2), 2);
GridNodeBBox bb4(GridPoint(2,3,2), 2);
GridNodeBBox bb5(GridPoint(2,2,3), 2);
GridNodeBBox bb6(GridPoint(2,2,2), 4);
ASSERT_TRUE(bb1 == bb2);
ASSERT_TRUE(bb1 == bb5); // z doesnt matter for the bbox
ASSERT_FALSE(bb1 == bb3);
ASSERT_FALSE(bb1 == bb4);
ASSERT_FALSE(bb1 == bb6);
}
TEST(BBox, intersect) {
GridNodeBBox bb1(GridPoint(20,20,20), 20);
// left
ASSERT_FALSE(bb1.intersects( Line2(9, -999, 9, +999) ));
ASSERT_TRUE (bb1.intersects( Line2(11, -999, 11, +999) ));
// right
ASSERT_TRUE (bb1.intersects( Line2(29, -999, 29, +999) ));
ASSERT_FALSE(bb1.intersects( Line2(31, -999, 31, +999) ));
// top
ASSERT_FALSE(bb1.intersects( Line2(-999, 9, +999, 9) ));
ASSERT_TRUE (bb1.intersects( Line2(-999, 11, +999, 11) ));
// bottom
ASSERT_TRUE (bb1.intersects( Line2(-999, 29, +999, 29) ));
ASSERT_FALSE(bb1.intersects( Line2(-999, 31, +999, 31) ));
}
#endif