From 48c52c077b504987248b2958e4fc6251d922d7e5 Mon Sep 17 00:00:00 2001 From: Louis Langholtz Date: Thu, 12 Oct 2023 15:53:58 -0600 Subject: [PATCH] Adds unit test of GetMassData(world, ShapeID) --- UnitTests/WorldShape.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/UnitTests/WorldShape.cpp b/UnitTests/WorldShape.cpp index 8790a42e93..581576010c 100644 --- a/UnitTests/WorldShape.cpp +++ b/UnitTests/WorldShape.cpp @@ -307,3 +307,19 @@ TEST(WorldShape, Rotate) EXPECT_EQ(distanceProxy.GetVertex(0u), Length2(0.0_m, -0.5_m)); EXPECT_EQ(distanceProxy.GetVertex(1u), Length2(0.0_m, +0.5_m)); } + +TEST(WorldShape, GetMassData) +{ + EXPECT_THROW(GetMassData(World{}, ShapeID(0)), std::out_of_range); + auto world = World{}; + auto shapeId = InvalidShapeID; + const auto v0 = Length2{-0.5_m, +0.0_m}; + const auto v1 = Length2{+0.5_m, +0.0_m}; + const auto shape = EdgeShapeConf{v0, v1}; + const auto expected = GetMassData(shape); + ASSERT_NO_THROW(shapeId = CreateShape(world, shape)); + ASSERT_EQ(shapeId, ShapeID(0u)); + auto massData = MassData{}; + EXPECT_NO_THROW(massData = GetMassData(world, ShapeID(0))); + EXPECT_EQ(expected, massData); +}