diff --git a/src/Unittests/CMakeLists.txt b/src/Unittests/CMakeLists.txt index 133fd41c..8b82a407 100644 --- a/src/Unittests/CMakeLists.txt +++ b/src/Unittests/CMakeLists.txt @@ -39,6 +39,7 @@ unittests_stripifier.cc unittests_subdivider_adaptive.cc unittests_subdivider_uniform.cc unittests_trimesh_circulator_current_halfedge_handle_replacement.cc +unittests_traits.cc unittests_trimesh_circulator_face_edge.cc unittests_trimesh_circulator_face_face.cc unittests_trimesh_circulator_face_halfedge.cc diff --git a/src/Unittests/unittests_traits.cc b/src/Unittests/unittests_traits.cc new file mode 100644 index 00000000..d6d5a0c8 --- /dev/null +++ b/src/Unittests/unittests_traits.cc @@ -0,0 +1,67 @@ +#include +#include +#include + +namespace { + +class OpenMeshPrevHalfedge : public OpenMeshBase { + + protected: + + // This function is called before each test is run + virtual void SetUp() { + + // Do some initial stuff with the member data here... + } + + // This function is called after all tests are through + virtual void TearDown() { + + // Do some final stuff with the member data here... + } + + // Member already defined in OpenMeshBase + //Mesh mesh_; +}; + +/* + * ==================================================================== + * Define tests below + * ==================================================================== + */ + +/* creates a Halfedge WITHOUT the PrevHalfedge Attribute + */ +TEST_F(OpenMeshPrevHalfedge, RemovePrevHalfedge) { + + mesh_.clear(); + + struct MeshTraits : OpenMesh::DefaultTraits { + HalfedgeAttributes(0); + }; + using MeshT = OpenMesh::TriMesh_ArrayKernelT; + + + // Check if Prev Halfedge is referenced + EXPECT_EQ(12u, sizeof(MeshT::Halfedge) ) << "Wrong size of Halfedge"; + EXPECT_EQ(0u, MeshT::HasPrevHalfedge::my_bool ) << "Attribute HasPrevHalfedge is wrong"; +} + +/* creates a Halfedge WITH the PrevHalfedge Attribute + */ +TEST_F(OpenMeshPrevHalfedge, HavePrevHalfedge) { + + mesh_.clear(); + + struct MeshTraits : OpenMesh::DefaultTraits { + //HalfedgeAttributes(0); + }; + using MeshT = OpenMesh::TriMesh_ArrayKernelT; + + + // Check if Prev Halfedge is referenced + EXPECT_EQ(16u, sizeof(MeshT::Halfedge) ) << "Wrong size of Halfedge"; + EXPECT_EQ(1u, MeshT::HasPrevHalfedge::my_bool ) << "Attribute HasPrevHalfedge is wrong"; +} + +}