Skip to content

Commit

Permalink
Add tests for GetRequiredNamespaces function in Model class
Browse files Browse the repository at this point in the history
  • Loading branch information
3dJan committed Feb 29, 2024
1 parent 334a8d3 commit 51c0245
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Tests/CPP_Bindings/Source/Model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,4 +175,47 @@ namespace Lib3MF
ASSERT_EQ(oldID, newId);
}

TEST_F(Model, GetRequiredNamespaces_NoExtensions_IsEmpty)
{
auto requiredNamespaces = m_pModel->GetRequiredNameSpaces();
ASSERT_TRUE(requiredNamespaces);
EXPECT_EQ(requiredNamespaces->Count(), 0u);
}

TEST_F(Model, GetRequiredNamespaces_BeamLatticeExtension_ContainsBeamLattice)
{
auto model = wrapper->CreateModel(); // create a new model to avoid interference with other tests
auto mesh = model->AddMeshObject();
auto beamLattice = mesh->BeamLattice();

ASSERT_TRUE(model);
ASSERT_TRUE(mesh);
ASSERT_TRUE(beamLattice);

sPosition p;
p.m_Coordinates[0] = 0;
p.m_Coordinates[1] = 0;
p.m_Coordinates[2] = 0;
mesh->AddVertex(p);

p.m_Coordinates[1] = 1;
mesh->AddVertex(p);

p.m_Coordinates[2] = 1;
mesh->AddVertex(p);

sBeam beam;
beam.m_Radii[0] = 1.0;
beam.m_Radii[1] = 1.0;
beam.m_Indices[0] = 0;
beam.m_Indices[1] = 1;
beamLattice->AddBeam(beam);

auto requiredNamespaces = model->GetRequiredNameSpaces();
ASSERT_TRUE(requiredNamespaces);
EXPECT_EQ(requiredNamespaces->Count(), 1u);
EXPECT_EQ(requiredNamespaces->MoveNext(), true);
EXPECT_EQ(requiredNamespaces->GetCurrent(), "http://schemas.microsoft.com/3dmanufacturing/beamlattice/2017/02");
EXPECT_EQ(requiredNamespaces->MoveNext(), false);
}
}

0 comments on commit 51c0245

Please sign in to comment.