Test: Add unit test to read in 3MF file

This commit is contained in:
wmayer
2024-11-20 14:35:10 +01:00
committed by wwmayer
parent d6ae5d2d25
commit c07df6b392
3 changed files with 33 additions and 0 deletions

BIN
data/tests/mesh.3mf Normal file

Binary file not shown.

View File

@@ -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
)

View 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-*)