MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / TEST

Function TEST

tests/gtest_postconditions.cpp:10–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8using namespace BT;
9
10TEST(PostConditions, BasicTest)
11{
12 BehaviorTreeFactory factory;
13
14 const std::string xml_text = R"(
15
16 <root BTCPP_format="4" >
17 <BehaviorTree ID="MainTree">
18 <Sequence>
19 <Script code = "A:=1; B:=1; C:=1; D:=1" />
20
21 <AlwaysSuccess _onSuccess="B=42"/>
22
23 <ForceSuccess>
24 <AlwaysSuccess _failureIf="A!=0" _onFailure="C=42"/>
25 </ForceSuccess>
26
27 <ForceSuccess>
28 <AlwaysFailure _onFailure="D=42"/>
29 </ForceSuccess>
30 </Sequence>
31 </BehaviorTree>
32 </root>)";
33
34 auto tree = factory.createTreeFromText(xml_text);
35 const auto status = tree.tickWhileRunning();
36 ASSERT_EQ(status, NodeStatus::SUCCESS);
37
38 ASSERT_EQ(tree.rootBlackboard()->get<int>("B"), 42);
39 ASSERT_EQ(tree.rootBlackboard()->get<int>("C"), 42);
40 ASSERT_EQ(tree.rootBlackboard()->get<int>("D"), 42);
41}
42
43TEST(PostConditions, Issue539)
44{

Callers

nothing calls this directly

Calls 3

createTreeFromTextMethod · 0.80
tickWhileRunningMethod · 0.80
rootBlackboardMethod · 0.45

Tested by

no test coverage detected