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 
29 
30 class PolyhedralMeshBase: public testing::Test {
31 
32 protected:
33 
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 
67 
68 class HexahedralMeshBase: public testing::Test {
69 
70 protected:
71 
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 
106 
107 class TetrahedralMeshBase: public testing::Test {
108 
109 protected:
110 
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