Skip to content

Commit f3a6556

Browse files
committed
add unit test
1 parent 3073f29 commit f3a6556

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/gtest_preconditions.cpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,3 +298,41 @@ TEST(Preconditions, Issue615_NoSkipWhenRunning_B)
298298
tree.rootBlackboard()->set("check", false);
299299
ASSERT_EQ( tree.tickOnce(), NodeStatus::RUNNING );
300300
}
301+
302+
303+
304+
TEST(Preconditions, Remapping)
305+
{
306+
static constexpr auto xml_text = R"(
307+
<root BTCPP_format="4">
308+
309+
<BehaviorTree ID="Main">
310+
<Sequence>
311+
<Script code="value:=1" />
312+
<SubTree ID="Sub1" param="{value}"/>
313+
<TestA _skipIf="value!=1" />
314+
</Sequence>
315+
</BehaviorTree>
316+
317+
<BehaviorTree ID="Sub1">
318+
<Sequence>
319+
<TestB _skipIf="param!=1" />
320+
</Sequence>
321+
</BehaviorTree>
322+
</root>
323+
)";
324+
325+
BehaviorTreeFactory factory;
326+
327+
std::array<int, 2> counters;
328+
RegisterTestTick(factory, "Test", counters);
329+
330+
factory.registerBehaviorTreeFromText(xml_text);
331+
auto tree = factory.createTree("Main");
332+
333+
auto status = tree.tickWhileRunning();
334+
335+
ASSERT_EQ(status, BT::NodeStatus::SUCCESS);
336+
ASSERT_EQ( counters[0], 1 );
337+
ASSERT_EQ( counters[1], 1 );
338+
}

0 commit comments

Comments
 (0)