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