Developer Documentation
unittests_common.hh
1 #ifndef INCLUDE_UNITTESTS_COMMON_HH
2 #define INCLUDE_UNITTESTS_COMMON_HH
3 
4 #include <gtest/gtest.h>
5 
6 #include <OpenVolumeMesh/Mesh/PolyhedralMesh.hh>
7 #include <OpenVolumeMesh/Mesh/HexahedralMesh.hh>
8 #include <OpenVolumeMesh/Mesh/TetrahedralMesh.hh>
9 #include <OpenVolumeMesh/Geometry/VectorT.hh>
10 
11 #define EXPECT_HANDLE_EQ(a, b) EXPECT_EQ((a).idx(), (b).idx())
12 #define EXPECT_HANDLE_NE(a, b) EXPECT_NE((a).idx(), (b).idx())
13 
14 
15 /*
16  * Simple test setting for polyhedral meshes
17  */
18 
20 
21 class PolyhedralMeshBase: public testing::Test {
22 
23 protected:
24 
31 
32  // This function is called before each test is run
33  virtual void SetUp() {
34 
35  // Do some initial stuff with the member data here...
36  mesh_.enable_deferred_deletion(false);
37  mesh_.enable_fast_deletion(false);
38  }
39 
40  // This function is called after all tests are through
41  virtual void TearDown() {
42 
43  // Do some final stuff with the member data here...
44  }
45 
46  // Generate a basic hexahedral mesh
47  void generatePolyhedralMesh(PolyhedralMesh& _mesh);
48 
49  // This member will be accessible in all tests
50  PolyhedralMesh mesh_;
51 };
52 
53 /*
54  * Simple test setting for hexahedral meshes
55  */
56 
58 
59 class HexahedralMeshBase: public testing::Test {
60 
61 protected:
62 
69 
70  // This function is called before each test is run
71  virtual void SetUp() {
72 
73  // Do some initial stuff with the member data here...
74  mesh_.enable_deferred_deletion(false);
75  mesh_.enable_fast_deletion(false);
76  }
77 
78  // This function is called after all tests are through
79  virtual void TearDown() {
80 
81  // Do some final stuff with the member data here...
82  }
83 
84  // Generate a basic hexahedral mesh
85  void generateHexahedralMesh(HexahedralMesh& _mesh);
86 
87  // This member will be accessible in all tests
88  HexahedralMesh mesh_;
89 };
90 
91 
92 /*
93  * Simple test setting for tetrahedral meshes
94  */
95 
97 
98 class TetrahedralMeshBase: public testing::Test {
99 
100 protected:
101 
108 
109  // This function is called before each test is run
110  virtual void SetUp() {
111 
112  // Do some initial stuff with the member data here...
113  mesh_.enable_deferred_deletion(false);
114  mesh_.enable_fast_deletion(false);
115  }
116 
117  // This function is called after all tests are through
118  virtual void TearDown() {
119 
120  // Do some final stuff with the member data here...
121  }
122 
123  // Generate a basic hexahedral mesh
124  void generateTetrahedralMesh(TetrahedralMesh& _mesh);
125 
126  // This member will be accessible in all tests
127  TetrahedralMesh mesh_;
128 };
129 
130 
131 // Printer class (for STL compliance test)
132 class Print {
133 public:
134  explicit Print(bool _mute = false) : mute_(_mute) {}
135  void mute(bool _mute) { mute_ = _mute; }
136  bool mute() const { return mute_; }
137  void operator()(const OpenVolumeMesh::OpenVolumeMeshHandle& _h) const {
138  if(!mute_) std::cerr << "Handle: " << _h.idx() << std::endl;
139  }
140 private:
141  bool mute_;
142 };
143 
144 #endif // INCLUDE GUARD