Skip to content

Commit

Permalink
check null model, update test
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Chen <[email protected]>
  • Loading branch information
iche033 committed Mar 5, 2024
1 parent ca1715e commit d08d0ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions bullet-featherstone/src/EntityManagementFeatures.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ Identity EntityManagementFeatures::ConstructEmptyWorld(
bool EntityManagementFeatures::RemoveModel(const Identity &_modelID)
{
auto *model = this->ReferenceInterface<ModelInfo>(_modelID);
if (!model)

Check warning on line 209 in bullet-featherstone/src/EntityManagementFeatures.cc

View check run for this annotation

Codecov / codecov/patch

bullet-featherstone/src/EntityManagementFeatures.cc#L209

Added line #L209 was not covered by tests
return false;
return this->RemoveModelImpl(model->world, _modelID);

Check warning on line 211 in bullet-featherstone/src/EntityManagementFeatures.cc

View check run for this annotation

Codecov / codecov/patch

bullet-featherstone/src/EntityManagementFeatures.cc#L211

Added line #L211 was not covered by tests
}

Expand Down
4 changes: 4 additions & 0 deletions test/common_test/world_features.cc
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@ TEST_F(WorldNestedModelTest, WorldConstructNestedModel)
gz::physics::ForwardStep::State state;
gz::physics::ForwardStep::Output output;

// Check invalid input to RemoveNestedModel method
EXPECT_FALSE(worldModel->RemoveNestedModel(1));
EXPECT_FALSE(worldModel->RemoveNestedModel("invalid"));

// Check that we can remove models via RemoveNestedModel
EXPECT_TRUE(worldModel->RemoveNestedModel(0));
EXPECT_TRUE(nestedModel->Removed());
Expand Down

0 comments on commit d08d0ef

Please sign in to comment.