Developer Documentation

unittests_common.hh
1 #ifndef INCLUDE_UNITTESTS_COMMON_HH
2 #define INCLUDE_UNITTESTS_COMMON_HH
3
4
5 #include <OpenVolumeMesh/Mesh/PolyhedralMesh.hh>
6 #include <OpenVolumeMesh/Mesh/HexahedralMesh.hh>
7 #include <OpenVolumeMesh/Mesh/TetrahedralMesh.hh>
8 #include <OpenVolumeMesh/Geometry/VectorT.hh>
9
10 #ifdef __clang__
11 # pragma GCC diagnostic ignored "-Weverything"
12 # pragma GCC diagnostic ignored "-Wundef"
13 # pragma GCC diagnostic ignored "-Wglobal-constructors"
14 # pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
15 # pragma GCC diagnostic ignored "-Wmissing-noreturn"
16 #endif
17
18 #include <gtest/gtest.h>
19
20 #define EXPECT_HANDLE_EQ(a, b) EXPECT_EQ((a).idx(), (b).idx())
21 #define EXPECT_HANDLE_NE(a, b) EXPECT_NE((a).idx(), (b).idx())
22
23
24 /*
25 * Simple test setting for polyhedral meshes
26 */
27
28 typedef OpenVolumeMesh::GeometricPolyhedralMeshV3d PolyhedralMesh;
29
30 class PolyhedralMeshBase: public testing::Test {
31
32 protected:
33
34 typedef OpenVolumeMesh::VertexHandle VertexHandle;
35 typedef OpenVolumeMesh::HalfEdgeHandle HalfEdgeHandle;
36 typedef OpenVolumeMesh::EdgeHandle EdgeHandle;
37 typedef OpenVolumeMesh::HalfFaceHandle HalfFaceHandle;
38 typedef OpenVolumeMesh::FaceHandle FaceHandle;
39 typedef OpenVolumeMesh::CellHandle CellHandle;
40
41 // This function is called before each test is run
42 virtual void SetUp() {
43
44 // Do some initial stuff with the member data here...
45 mesh_.enable_deferred_deletion(false);
46 mesh_.enable_fast_deletion(false);
47 }
48
49 // This function is called after all tests are through
50 virtual void TearDown() {
51
52 // Do some final stuff with the member data here...
53 }
54
55 // Generate a basic hexahedral mesh
56 void generatePolyhedralMesh(PolyhedralMesh& _mesh);
57
58 // This member will be accessible in all tests
59 PolyhedralMesh mesh_;
60 };
61
62 /*
63 * Simple test setting for hexahedral meshes
64 */
65
66 typedef OpenVolumeMesh::GeometricHexahedralMeshV3d HexahedralMesh;
67
68 class HexahedralMeshBase: public testing::Test {
69
70 protected:
71
72 typedef OpenVolumeMesh::VertexHandle VertexHandle;
73 typedef OpenVolumeMesh::HalfEdgeHandle HalfEdgeHandle;
74 typedef OpenVolumeMesh::EdgeHandle EdgeHandle;
75 typedef OpenVolumeMesh::HalfFaceHandle HalfFaceHandle;
76 typedef OpenVolumeMesh::FaceHandle FaceHandle;
77 typedef OpenVolumeMesh::CellHandle CellHandle;
78
79 // This function is called before each test is run
80 virtual void SetUp() {
81
82 // Do some initial stuff with the member data here...
83 mesh_.enable_deferred_deletion(false);
84 mesh_.enable_fast_deletion(false);
85 }
86
87 // This function is called after all tests are through
88 virtual void TearDown() {
89
90 // Do some final stuff with the member data here...
91 }
92
93 // Generate a basic hexahedral mesh
94 void generateHexahedralMesh(HexahedralMesh& _mesh);
95
96 // This member will be accessible in all tests
97 HexahedralMesh mesh_;
98 };
99
100
101 /*
102 * Simple test setting for tetrahedral meshes
103 */
104
105 typedef OpenVolumeMesh::GeometricTetrahedralMeshV3d TetrahedralMesh;
106
107 class TetrahedralMeshBase: public testing::Test {
108
109 protected:
110
111 typedef OpenVolumeMesh::VertexHandle VertexHandle;
112 typedef OpenVolumeMesh::HalfEdgeHandle HalfEdgeHandle;
113 typedef OpenVolumeMesh::EdgeHandle EdgeHandle;
114 typedef OpenVolumeMesh::HalfFaceHandle HalfFaceHandle;
115 typedef OpenVolumeMesh::FaceHandle FaceHandle;
116 typedef OpenVolumeMesh::CellHandle CellHandle;
117
118 // This function is called before each test is run
119 virtual void SetUp() {
120
121 // Do some initial stuff with the member data here...
122 mesh_.enable_deferred_deletion(false);
123 mesh_.enable_fast_deletion(false);
124 }
125
126 // This function is called after all tests are through
127 virtual void TearDown() {
128
129 // Do some final stuff with the member data here...
130 }
131
132 // Generate a basic hexahedral mesh
133 void generateTetrahedralMesh(TetrahedralMesh& _mesh);
134
135 // This member will be accessible in all tests
136 TetrahedralMesh mesh_;
137 };
138
139
140 // Printer class (for STL compliance test)
141 class Print {
142 public:
143 explicit Print(bool _mute = false) : mute_(_mute) {}
144 void mute(bool _mute) { mute_ = _mute; }
145 bool mute() const { return mute_; }
146 void operator()(const OpenVolumeMesh::OpenVolumeMeshHandle& _h) const {
147 if(!mute_) std::cerr << "Handle: " << _h.idx() << std::endl;
148 }
149 private:
150 bool mute_;
151 };
152
153 #endif // INCLUDE GUARD
OpenVolumeMesh::HandleT< Entity::Vertex >
HexahedralMeshBase
Definition: unittests_common.hh:68
Print
Definition: unittests_common.hh:141
OpenVolumeMesh::OpenVolumeMeshHandle
Definition: OpenVolumeMeshHandle.hh:50
OpenVolumeMesh::GeometryKernel
Definition: GeometryKernel.hh:47
PolyhedralMeshBase
Definition: unittests_common.hh:30
TetrahedralMeshBase
Definition: unittests_common.hh:107