Created first unittest for OpenMesh.
git-svn-id: http://www.openmesh.org/svnrepo/OpenMesh/trunk@405 fdac6126-5c0c-442c-9429-916003d36597
This commit is contained in:
27
src/Unittests/CMakeLists.txt
Normal file
27
src/Unittests/CMakeLists.txt
Normal file
@@ -0,0 +1,27 @@
|
||||
include (ACGCommon)
|
||||
|
||||
include_directories (
|
||||
..
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
|
||||
# Search for gtest headers and libraries
|
||||
find_package(GoogleTest)
|
||||
|
||||
if(GTEST_FOUND)
|
||||
|
||||
# Set correct include paths so that the compiler can find the headers
|
||||
include_directories(${GTEST_INCLUDE_DIRS})
|
||||
# Create new target named unittests_hexmeshing
|
||||
add_executable(unittests EXCLUDE_FROM_ALL unittests.cc)
|
||||
# Link against all necessary libraries
|
||||
target_link_libraries(unittests OpenMeshCore OpenMeshTools gtest gtest_main pthread)
|
||||
# Set output directory to ${BINARY_DIR}/Unittests
|
||||
set_target_properties(unittests PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Unittests)
|
||||
# Set compiler flags
|
||||
set_target_properties(unittests PROPERTIES COMPILE_FLAGS "-g -pedantic -ansi -Wno-long-long")
|
||||
acg_copy_after_build(unittests ${CMAKE_CURRENT_SOURCE_DIR}/TestFiles ${CMAKE_BINARY_DIR}/Unittests/)
|
||||
|
||||
else(GTEST_FOUND)
|
||||
message("Google testing framework was not found!")
|
||||
endif(GTEST_FOUND)
|
||||
22576
src/Unittests/TestFiles/cube1.off
Normal file
22576
src/Unittests/TestFiles/cube1.off
Normal file
File diff suppressed because it is too large
Load Diff
9
src/Unittests/unittests.cc
Normal file
9
src/Unittests/unittests.cc
Normal file
@@ -0,0 +1,9 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "unittests_loading.hh"
|
||||
|
||||
int main(int _argc, char** _argv) {
|
||||
|
||||
testing::InitGoogleTest(&_argc, _argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
59
src/Unittests/unittests_loading.hh
Normal file
59
src/Unittests/unittests_loading.hh
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef INCLUDE_UNITTESTS_LOADING_CC
|
||||
#define INCLUDE_UNITTESTS_LOADING_CC
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <OpenMesh/Core/IO/MeshIO.hh>
|
||||
|
||||
#include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
|
||||
|
||||
struct CustomTraits : public OpenMesh::DefaultTraits {
|
||||
};
|
||||
|
||||
typedef OpenMesh::TriMesh_ArrayKernelT<CustomTraits> Mesh;
|
||||
|
||||
/*
|
||||
* Simple test setting.
|
||||
*/
|
||||
|
||||
class OpenMeshLoader : public testing::Test {
|
||||
|
||||
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...
|
||||
}
|
||||
|
||||
// This member will be accessible in all tests
|
||||
Mesh mesh_;
|
||||
};
|
||||
|
||||
/*
|
||||
* ====================================================================
|
||||
* Define tests below
|
||||
* ====================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
* Just load a simple mesh file in obj format and count whether
|
||||
* the right number of entities has been loaded.
|
||||
*/
|
||||
TEST_F(OpenMeshLoader, LoadSimpleOFFFile) {
|
||||
|
||||
bool ok = OpenMesh::IO::read_mesh(mesh_, "cube1.off");
|
||||
|
||||
EXPECT_TRUE(ok);
|
||||
|
||||
EXPECT_EQ(7526, mesh_.n_vertices()) << "The number of loaded vertices is not correct!";
|
||||
EXPECT_EQ(22572, mesh_.n_edges()) << "The number of loaded edges is not correct!";
|
||||
EXPECT_EQ(15048, mesh_.n_faces()) << "The number of loaded faces is not correct!";
|
||||
}
|
||||
|
||||
#endif // INCLUDE GUARD
|
||||
Reference in New Issue
Block a user