unittests_common.hh 4.1 KB
Newer Older
1 2 3 4 5 6 7
#ifndef INCLUDE_UNITTESTS_COMMON_HH
#define INCLUDE_UNITTESTS_COMMON_HH

#include <gtest/gtest.h>

#include <OpenVolumeMesh/Mesh/PolyhedralMesh.hh>
#include <OpenVolumeMesh/Mesh/HexahedralMesh.hh>
8
#include <OpenVolumeMesh/Mesh/TetrahedralMesh.hh>
9 10
#include <OpenVolumeMesh/Geometry/VectorT.hh>

11 12 13 14 15 16
#ifdef __clang__
#  pragma GCC diagnostic ignored "-Wglobal-constructors"
#  pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
#  pragma GCC diagnostic ignored "-Wundef"
#endif

17 18 19 20
#define EXPECT_HANDLE_EQ(a, b)  EXPECT_EQ((a).idx(), (b).idx())
#define EXPECT_HANDLE_NE(a, b)  EXPECT_NE((a).idx(), (b).idx())


21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
/*
 * Simple test setting for polyhedral meshes
 */

typedef OpenVolumeMesh::GeometricPolyhedralMeshV3d PolyhedralMesh;

class PolyhedralMeshBase: public testing::Test {

protected:

  typedef OpenVolumeMesh::VertexHandle    VertexHandle;
  typedef OpenVolumeMesh::HalfEdgeHandle  HalfEdgeHandle;
  typedef OpenVolumeMesh::EdgeHandle      EdgeHandle;
  typedef OpenVolumeMesh::HalfFaceHandle  HalfFaceHandle;
  typedef OpenVolumeMesh::FaceHandle      FaceHandle;
  typedef OpenVolumeMesh::CellHandle      CellHandle;

  // This function is called before each test is run
  virtual void SetUp() {

    // Do some initial stuff with the member data here...
Max Lyon's avatar
Max Lyon committed
42 43
    mesh_.enable_deferred_deletion(false);
    mesh_.enable_fast_deletion(false);
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
  }

  // This function is called after all tests are through
  virtual void TearDown() {

    // Do some final stuff with the member data here...
  }

  // Generate a basic hexahedral mesh
  void generatePolyhedralMesh(PolyhedralMesh& _mesh);

  // This member will be accessible in all tests
  PolyhedralMesh mesh_;
};

/*
 * Simple test setting for hexahedral meshes
 */

typedef OpenVolumeMesh::GeometricHexahedralMeshV3d HexahedralMesh;

class HexahedralMeshBase: public testing::Test {

protected:

  typedef OpenVolumeMesh::VertexHandle    VertexHandle;
  typedef OpenVolumeMesh::HalfEdgeHandle  HalfEdgeHandle;
  typedef OpenVolumeMesh::EdgeHandle      EdgeHandle;
  typedef OpenVolumeMesh::HalfFaceHandle  HalfFaceHandle;
  typedef OpenVolumeMesh::FaceHandle      FaceHandle;
  typedef OpenVolumeMesh::CellHandle      CellHandle;

  // This function is called before each test is run
  virtual void SetUp() {

    // Do some initial stuff with the member data here...
Max Lyon's avatar
Max Lyon committed
80 81
    mesh_.enable_deferred_deletion(false);
    mesh_.enable_fast_deletion(false);
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
  }

  // This function is called after all tests are through
  virtual void TearDown() {

    // Do some final stuff with the member data here...
  }

  // Generate a basic hexahedral mesh
  void generateHexahedralMesh(HexahedralMesh& _mesh);

  // This member will be accessible in all tests
  HexahedralMesh mesh_;
};

97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136

/*
 * Simple test setting for tetrahedral meshes
 */

typedef OpenVolumeMesh::GeometricTetrahedralMeshV3d TetrahedralMesh;

class TetrahedralMeshBase: public testing::Test {

protected:

  typedef OpenVolumeMesh::VertexHandle    VertexHandle;
  typedef OpenVolumeMesh::HalfEdgeHandle  HalfEdgeHandle;
  typedef OpenVolumeMesh::EdgeHandle      EdgeHandle;
  typedef OpenVolumeMesh::HalfFaceHandle  HalfFaceHandle;
  typedef OpenVolumeMesh::FaceHandle      FaceHandle;
  typedef OpenVolumeMesh::CellHandle      CellHandle;

  // This function is called before each test is run
  virtual void SetUp() {

    // Do some initial stuff with the member data here...
    mesh_.enable_deferred_deletion(false);
    mesh_.enable_fast_deletion(false);
  }

  // This function is called after all tests are through
  virtual void TearDown() {

    // Do some final stuff with the member data here...
  }

  // Generate a basic hexahedral mesh
  void generateTetrahedralMesh(TetrahedralMesh& _mesh);

  // This member will be accessible in all tests
  TetrahedralMesh mesh_;
};


137 138 139
// Printer class (for STL compliance test)
class Print {
public:
Jan Möbius's avatar
Jan Möbius committed
140
  explicit Print(bool _mute = false) : mute_(_mute) {}
141 142 143 144 145 146 147 148 149 150
  void mute(bool _mute) { mute_ = _mute; }
  bool mute() const { return mute_; }
  void operator()(const OpenVolumeMesh::OpenVolumeMeshHandle& _h) const {
    if(!mute_) std::cerr << "Handle: " << _h.idx() << std::endl;
  }
private:
  bool mute_;
};

#endif // INCLUDE GUARD