Skip to content

Commit

Permalink
Include both the 3d builder cases to unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vijaiaeroastro committed Aug 7, 2024
1 parent f113766 commit 1c8f124
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions Tests/CPP_Bindings/Source/Reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,48 @@ namespace Lib3MF
CheckReaderWarnings(Reader::reader3MF, 0);
}

TEST_F(Reader, 3MFReadFromFileAndAddMeshObjects)
{
auto reader = model->QueryReader("3mf");
reader->ReadFromFile(sTestFilesPath + "/Reader/" + "Box.3mf");
ASSERT_NO_THROW(model->AddMeshObject());
ASSERT_NO_THROW(model->AddMeshObject());
ASSERT_NO_THROW(model->AddMeshObject());
std::vector<Lib3MF_uint32> resourceIDs;
std::vector<Lib3MF_uint32> modelResourceIDs;
std::vector<Lib3MF_uint32> expectedModelResourceIDs({2,3,5,6,7});
std::vector<Lib3MF_uint32> expectedResourceIDs({2,3,4,5,6});
auto objectIterator = model->GetObjects();
while (objectIterator->MoveNext()) {
auto object = objectIterator->GetCurrentObject();
modelResourceIDs.push_back(object->GetModelResourceID());
resourceIDs.push_back(object->GetResourceID());
}
ASSERT_EQ(modelResourceIDs, expectedModelResourceIDs);
ASSERT_EQ(resourceIDs, expectedResourceIDs);
}

TEST_F(Reader, 3MFReadFromFileAndAddComponents)
{
auto reader = model->QueryReader("3mf");
reader->ReadFromFile(sTestFilesPath + "/Reader/" + "Globo.3mf");
ASSERT_NO_THROW(model->AddComponentsObject());
ASSERT_NO_THROW(model->AddComponentsObject());
ASSERT_NO_THROW(model->AddComponentsObject());
std::vector<Lib3MF_uint32> resourceIDs;
std::vector<Lib3MF_uint32> modelResourceIDs;
std::vector<Lib3MF_uint32> expectedModelResourceIDs({2,3,4,5,6,7,8,9});
std::vector<Lib3MF_uint32> expectedResourceIDs({1,2,3,4,5,6,7,8});
auto objectIterator = model->GetObjects();
while (objectIterator->MoveNext()) {
auto object = objectIterator->GetCurrentObject();
modelResourceIDs.push_back(object->GetModelResourceID());
resourceIDs.push_back(object->GetResourceID());
}
ASSERT_EQ(modelResourceIDs, expectedModelResourceIDs);
ASSERT_EQ(resourceIDs, expectedResourceIDs);
}

TEST_F(Reader, STLReadFromFile)
{
Reader::readerSTL->ReadFromFile(sTestFilesPath + "/Reader/" + "Pyramid.stl");
Expand Down
Binary file added Tests/TestFiles/Reader/Box.3mf
Binary file not shown.
Binary file added Tests/TestFiles/Reader/Globo.3mf
Binary file not shown.

0 comments on commit 1c8f124

Please sign in to comment.