Skip to content

Commit

Permalink
Mesh_TEST: improve coverage
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
scpeters committed Mar 20, 2024
1 parent f82be1f commit 1b0736e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Mesh_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,14 @@ TEST(DOMMesh, Set)
EXPECT_EQ("convex_decomposition", mesh.OptimizationStr());
EXPECT_EQ(sdf::MeshOptimization::CONVEX_DECOMPOSITION,
mesh.Optimization());
// check invalid inputs
EXPECT_FALSE(mesh.SetOptimization("invalid"));
{
auto invalidMeshOpt = static_cast<sdf::MeshOptimization>(99);
mesh.SetOptimization(invalidMeshOpt);
EXPECT_EQ(invalidMeshOpt, mesh.Optimization());
EXPECT_EQ("", mesh.OptimizationStr());
}

sdf::ConvexDecomposition convexDecomp;
convexDecomp.SetMaxConvexHulls(10u);
Expand Down Expand Up @@ -208,6 +215,7 @@ TEST(DOMMesh, Set)
TEST(DOMMesh, Load)
{
sdf::Mesh mesh;
sdf::ConvexDecomposition convexDecomp;
sdf::Errors errors;

// Null element name
Expand All @@ -216,6 +224,11 @@ TEST(DOMMesh, Load)
EXPECT_EQ(sdf::ErrorCode::ELEMENT_MISSING, errors[0].Code());
EXPECT_EQ(nullptr, mesh.Element());

errors = convexDecomp.Load(nullptr);
ASSERT_EQ(1u, errors.size());
EXPECT_EQ(sdf::ErrorCode::ELEMENT_MISSING, errors[0].Code());
EXPECT_EQ(nullptr, convexDecomp.Element());

// Bad element name
sdf::ElementPtr sdf(new sdf::Element());
sdf->SetName("bad");
Expand All @@ -224,6 +237,11 @@ TEST(DOMMesh, Load)
EXPECT_EQ(sdf::ErrorCode::ELEMENT_INCORRECT_TYPE, errors[0].Code());
EXPECT_NE(nullptr, mesh.Element());

errors = convexDecomp.Load(sdf);
ASSERT_EQ(1u, errors.size());
EXPECT_EQ(sdf::ErrorCode::ELEMENT_INCORRECT_TYPE, errors[0].Code());
EXPECT_NE(nullptr, convexDecomp.Element());

// Missing <uri> element
sdf->SetName("mesh");
errors = mesh.Load(sdf);
Expand Down

0 comments on commit 1b0736e

Please sign in to comment.