initial version
This commit is contained in:
47
tests/grid/TestBBox.cpp
Executable file
47
tests/grid/TestBBox.cpp
Executable file
@@ -0,0 +1,47 @@
|
||||
#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( Line2D(9, -999, 9, +999) ));
|
||||
ASSERT_TRUE (bb1.intersects( Line2D(11, -999, 11, +999) ));
|
||||
|
||||
// right
|
||||
ASSERT_TRUE (bb1.intersects( Line2D(29, -999, 29, +999) ));
|
||||
ASSERT_FALSE(bb1.intersects( Line2D(31, -999, 31, +999) ));
|
||||
|
||||
// top
|
||||
ASSERT_FALSE(bb1.intersects( Line2D(-999, 9, +999, 9) ));
|
||||
ASSERT_TRUE (bb1.intersects( Line2D(-999, 11, +999, 11) ));
|
||||
|
||||
// bottom
|
||||
ASSERT_TRUE (bb1.intersects( Line2D(-999, 29, +999, 29) ));
|
||||
ASSERT_FALSE(bb1.intersects( Line2D(-999, 31, +999, 31) ));
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user