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/Geometry/VectorT.hh>
9 
10 /*
11  * Simple test setting for polyhedral meshes
12  */
13 
15 
16 class PolyhedralMeshBase: public testing::Test {
17 
18 protected:
19 
26 
27  // This function is called before each test is run
28  virtual void SetUp() {
29 
30  // Do some initial stuff with the member data here...
31  mesh_.enable_deferred_deletion(false);
32  mesh_.enable_fast_deletion(false);
33  }
34 
35  // This function is called after all tests are through
36  virtual void TearDown() {
37 
38  // Do some final stuff with the member data here...
39  }
40 
41  // Generate a basic hexahedral mesh
42  void generatePolyhedralMesh(PolyhedralMesh& _mesh);
43 
44  // This member will be accessible in all tests
45  PolyhedralMesh mesh_;
46 };
47 
48 /*
49  * Simple test setting for hexahedral meshes
50  */
51 
53 
54 class HexahedralMeshBase: public testing::Test {
55 
56 protected:
57 
64 
65  // This function is called before each test is run
66  virtual void SetUp() {
67 
68  // Do some initial stuff with the member data here...
69  mesh_.enable_deferred_deletion(false);
70  mesh_.enable_fast_deletion(false);
71  }
72 
73  // This function is called after all tests are through
74  virtual void TearDown() {
75 
76  // Do some final stuff with the member data here...
77  }
78 
79  // Generate a basic hexahedral mesh
80  void generateHexahedralMesh(HexahedralMesh& _mesh);
81 
82  // This member will be accessible in all tests
83  HexahedralMesh mesh_;
84 };
85 
86 // Printer class (for STL compliance test)
87 class Print {
88 public:
89  Print(bool _mute = false) : mute_(_mute) {}
90  void mute(bool _mute) { mute_ = _mute; }
91  bool mute() const { return mute_; }
92  void operator()(const OpenVolumeMesh::OpenVolumeMeshHandle& _h) const {
93  if(!mute_) std::cerr << "Handle: " << _h.idx() << std::endl;
94  }
95 private:
96  bool mute_;
97 };
98 
99 #endif // INCLUDE GUARD