| 8 | using namespace BT; |
| 9 | |
| 10 | TEST(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 | |
| 43 | TEST(PostConditions, Issue539) |
| 44 | { |
nothing calls this directly
no test coverage detected