Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 /*
12  * Simple test setting for polyhedral meshes
13  */
14 
16 
17 class PolyhedralMeshBase: public testing::Test {
18 
19 protected:
20 
27 
28  // This function is called before each test is run
29  virtual void SetUp() {
30 
31  // Do some initial stuff with the member data here...
32  mesh_.enable_deferred_deletion(false);
33  mesh_.enable_fast_deletion(false);
34  }
35 
36  // This function is called after all tests are through
37  virtual void TearDown() {
38 
39  // Do some final stuff with the member data here...
40  }
41 
42  // Generate a basic hexahedral mesh
43  void generatePolyhedralMesh(PolyhedralMesh& _mesh);
44 
45  // This member will be accessible in all tests
46  PolyhedralMesh mesh_;
47 };
48 
49 /*
50  * Simple test setting for hexahedral meshes
51  */
52 
54 
55 class HexahedralMeshBase: public testing::Test {
56 
57 protected:
58 
65 
66  // This function is called before each test is run
67  virtual void SetUp() {
68 
69  // Do some initial stuff with the member data here...
70  mesh_.enable_deferred_deletion(false);
71  mesh_.enable_fast_deletion(false);
72  }
73 
74  // This function is called after all tests are through
75  virtual void TearDown() {
76 
77  // Do some final stuff with the member data here...
78  }
79 
80  // Generate a basic hexahedral mesh
81  void generateHexahedralMesh(HexahedralMesh& _mesh);
82 
83  // This member will be accessible in all tests
84  HexahedralMesh mesh_;
85 };
86 
87 
88 /*
89  * Simple test setting for tetrahedral meshes
90  */
91 
93 
94 class TetrahedralMeshBase: public testing::Test {
95 
96 protected:
97 
104 
105  // This function is called before each test is run
106  virtual void SetUp() {
107 
108  // Do some initial stuff with the member data here...
109  mesh_.enable_deferred_deletion(false);
110  mesh_.enable_fast_deletion(false);
111  }
112 
113  // This function is called after all tests are through
114  virtual void TearDown() {
115 
116  // Do some final stuff with the member data here...
117  }
118 
119  // Generate a basic hexahedral mesh
120  void generateTetrahedralMesh(TetrahedralMesh& _mesh);
121 
122  // This member will be accessible in all tests
123  TetrahedralMesh mesh_;
124 };
125 
126 
127 // Printer class (for STL compliance test)
128 class Print {
129 public:
130  Print(bool _mute = false) : mute_(_mute) {}
131  void mute(bool _mute) { mute_ = _mute; }
132  bool mute() const { return mute_; }
133  void operator()(const OpenVolumeMesh::OpenVolumeMeshHandle& _h) const {
134  if(!mute_) std::cerr << "Handle: " << _h.idx() << std::endl;
135  }
136 private:
137  bool mute_;
138 };
139 
140 #endif // INCLUDE GUARD