geolib2
test_shape.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 
3 #include <geolib/Shape.h>
4 
5 #include "box_test.h"
6 
7 
8 class ShapeTest : public BoxTest
9 {
10 protected:
12  {
13  }
14 
15  virtual ~ShapeTest()
16  {
17  }
18 
20 };
21 
22 TEST_F(ShapeTest, Contains)
23 {
24  ASSERT_TRUE(shape.contains(origin));
25 
26  ASSERT_TRUE(shape.contains(min));
27  ASSERT_TRUE(shape.contains(max));
28 
29  ASSERT_TRUE(shape.contains(side_center));
30  ASSERT_TRUE(shape.contains(side_center_triangle));
31 
32  ASSERT_FALSE(shape.contains(side_center_distance));
33 
34  ASSERT_FALSE(shape.contains(side_center_close));
35 }
36 
37 TEST_F(ShapeTest, Intersect)
38 {
39  ASSERT_TRUE(shape.intersect(origin, 0));
40  ASSERT_TRUE(shape.intersect(origin, 0.1));
41 
42  ASSERT_TRUE(shape.intersect(min, 0));
43  ASSERT_TRUE(shape.intersect(min, 0.1));
44  ASSERT_TRUE(shape.intersect(max, 0));
45  ASSERT_TRUE(shape.intersect(max, 0.1));
46 
47  ASSERT_TRUE(shape.intersect(side_center, 0));
48  ASSERT_TRUE(shape.intersect(side_center, 0.1));
49  ASSERT_TRUE(shape.intersect(side_center_triangle, 0));
50  ASSERT_TRUE(shape.intersect(side_center_triangle, 0.1));
51 
52  ASSERT_FALSE(shape.intersect(side_center_distance, 0));
53  ASSERT_FALSE(shape.intersect(side_center_distance, 0.1));
54  ASSERT_TRUE(shape.intersect(side_center_distance, 0.5));
55  ASSERT_TRUE(shape.intersect(side_center_distance, 0.6));
56 
57  ASSERT_FALSE(shape.intersect(side_center_close, 0));
58  ASSERT_FALSE(shape.intersect(side_center_close, 0.1));
59  ASSERT_TRUE(shape.intersect(side_center_close, 0.2));
60  ASSERT_TRUE(shape.intersect(side_center_close, 0.25));
61 }
62 
63 int main(int argc, char **argv) {
64  testing::InitGoogleTest(&argc, argv);
65  return RUN_ALL_TESTS();
66 }
Shape.h
ShapeTest::ShapeTest
ShapeTest()
Definition: test_shape.cpp:11
TEST_F
TEST_F(ShapeTest, Contains)
Definition: test_shape.cpp:22
ShapeTest
Definition: test_shape.cpp:8
BoxTest
Definition: box_test.h:6
BoxTest::box
geo::Box box
Definition: box_test.h:22
ShapeTest::~ShapeTest
virtual ~ShapeTest()
Definition: test_shape.cpp:15
main
int main(int argc, char **argv)
Definition: test_shape.cpp:63
box_test.h
ShapeTest::shape
geo::Shape shape
Definition: test_shape.cpp:19
geo::Shape
A geometric description of a shape.
Definition: Shape.h:19