Test: Add unit test to read in 3MF file
This commit is contained in:
BIN
data/tests/mesh.3mf
Normal file
BIN
data/tests/mesh.3mf
Normal file
Binary file not shown.
@@ -1,8 +1,11 @@
|
||||
target_compile_definitions(Mesh_tests_run PRIVATE DATADIR="${CMAKE_SOURCE_DIR}/data")
|
||||
|
||||
target_sources(
|
||||
Mesh_tests_run
|
||||
PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Core/KDTree.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Exporter.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Importer.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Mesh.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/MeshFeature.cpp
|
||||
)
|
||||
|
||||
30
tests/src/Mod/Mesh/App/Importer.cpp
Normal file
30
tests/src/Mod/Mesh/App/Importer.cpp
Normal file
@@ -0,0 +1,30 @@
|
||||
#include <gtest/gtest.h>
|
||||
#include <Base/FileInfo.h>
|
||||
#include <Mod/Mesh/App/Core/IO/Reader3MF.h>
|
||||
#include <zipios++/fcoll.h>
|
||||
|
||||
// NOLINTBEGIN(cppcoreguidelines-*,readability-*)
|
||||
TEST(ImporterTest, Test3MF)
|
||||
{
|
||||
std::string file(DATADIR);
|
||||
file.append("/tests/mesh.3mf");
|
||||
|
||||
MeshCore::Reader3MF reader(file);
|
||||
EXPECT_EQ(reader.Load(), true);
|
||||
|
||||
std::vector<int> ids = reader.GetMeshIds();
|
||||
std::sort(ids.begin(), ids.end());
|
||||
|
||||
EXPECT_EQ(ids.size(), 2);
|
||||
|
||||
const MeshCore::MeshKernel& mesh1 = reader.GetMesh(ids[0]);
|
||||
EXPECT_EQ(mesh1.CountPoints(), 8);
|
||||
EXPECT_EQ(mesh1.CountEdges(), 18);
|
||||
EXPECT_EQ(mesh1.CountFacets(), 12);
|
||||
|
||||
const MeshCore::MeshKernel& mesh2 = reader.GetMesh(ids[1]);
|
||||
EXPECT_EQ(mesh2.CountPoints(), 652);
|
||||
EXPECT_EQ(mesh2.CountEdges(), 1950);
|
||||
EXPECT_EQ(mesh2.CountFacets(), 1300);
|
||||
}
|
||||
// NOLINTEND(cppcoreguidelines-*,readability-*)
|
||||
Reference in New Issue
Block a user