Skip to content
Prev Previous commit
Next Next commit
Clean up test
Signed-off-by: David G <david.randommail1@gmail.com>
  • Loading branch information
DavidG-Develop committed Sep 18, 2025
commit d1da24e0d4a1904f1ab74828f31f9f760b410b40
Original file line number Diff line number Diff line change
Expand Up @@ -92,34 +92,30 @@ std::shared_ptr<BT::BehaviorTreeFactory>
ToggleCollisionMonitorTestFixture::factory_ = nullptr;
std::shared_ptr<BT::Tree> ToggleCollisionMonitorTestFixture::tree_ = nullptr;

TEST_F(ToggleCollisionMonitorTestFixture, test_tick_enable_collision_monitor)
{
std::string xml_txt =
R"(
<root BTCPP_format="4">
<BehaviorTree ID="MainTree">
<ToggleCollisionMonitor service_name="toggle_collision_monitor" enable="true"/>
</BehaviorTree>
</root>)";
class ToggleParamTest
: public ToggleCollisionMonitorTestFixture,
public ::testing::WithParamInterface<bool> {};

tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText(xml_txt, config_->blackboard));
EXPECT_EQ(tree_->rootNode()->executeTick(), BT::NodeStatus::SUCCESS);
}

TEST_F(ToggleCollisionMonitorTestFixture, test_tick_disable_collision_monitor)
TEST_P(ToggleParamTest, test_tick)
{
const bool enable = GetParam();

std::string xml_txt =
R"(
std::string(R"(
<root BTCPP_format="4">
<BehaviorTree ID="MainTree">
<ToggleCollisionMonitor service_name="toggle_collision_monitor" enable="false"/>
<ToggleCollisionMonitor service_name="toggle_collision_monitor" enable=")")
+ std::string(enable ? "true" : "false") +
R"(" />
</BehaviorTree>
</root>)";

tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText(xml_txt, config_->blackboard));
EXPECT_EQ(tree_->rootNode()->executeTick(), BT::NodeStatus::SUCCESS);
}

INSTANTIATE_TEST_SUITE_P(EnableDisable, ToggleParamTest, ::testing::Values(true, false));

int main(int argc, char ** argv)
{
::testing::InitGoogleTest(&argc, argv);
Expand Down