File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,11 @@ BT::NodeStatus PersistentSequenceNode::tick()
2929 const int children_count = children_nodes_.size ();
3030
3131 int current_child_idx;
32- getInput (" current_child_idx" , current_child_idx);
32+ if (!getInput (" current_child_idx" , current_child_idx)) {
33+ throw BT::RuntimeError (
34+ " Missing required input [current_child_idx] in PersistentSequenceNode. "
35+ " Set via <Script code=\" current_child_idx := 0\" />" );
36+ }
3337
3438 setStatus (BT::NodeStatus::RUNNING);
3539
Original file line number Diff line number Diff line change @@ -62,6 +62,23 @@ std::shared_ptr<BT::BehaviorTreeFactory>
6262PersistentSequenceTestFixture::factory_ = nullptr ;
6363std::shared_ptr<BT::Tree> PersistentSequenceTestFixture::tree_ = nullptr ;
6464
65+ TEST_F (PersistentSequenceTestFixture, test_empty_fails)
66+ {
67+ // create tree
68+ std::string xml_txt =
69+ R"(
70+ <root BTCPP_format="4">
71+ <BehaviorTree ID="MainTree">
72+ <PersistentSequence>
73+ <AlwaysSuccess/>
74+ </PersistentSequence>
75+ </BehaviorTree>
76+ </root>)" ;
77+ tree_ = std::make_shared<BT::Tree>(factory_->createTreeFromText (xml_txt, config_->blackboard ));
78+
79+ EXPECT_THROW (tree_->rootNode ()->executeTick (), BT::RuntimeError);
80+ }
81+
6582TEST_F (PersistentSequenceTestFixture, test_tick)
6683{
6784 // create tree
You can’t perform that action at this time.
0 commit comments