| 216 | } |
| 217 | |
| 218 | TEST(Decorator, RunOnce) |
| 219 | { |
| 220 | BT::BehaviorTreeFactory factory; |
| 221 | std::array<int, 2> counters{}; |
| 222 | RegisterTestTick(factory, "Test", counters); |
| 223 | |
| 224 | const std::string xml_text = R"( |
| 225 | <root BTCPP_format="4" > |
| 226 | <BehaviorTree> |
| 227 | <Sequence> |
| 228 | <RunOnce> <TestA/> </RunOnce> |
| 229 | <TestB/> |
| 230 | </Sequence> |
| 231 | </BehaviorTree> |
| 232 | </root>)"; |
| 233 | |
| 234 | auto tree = factory.createTreeFromText(xml_text); |
| 235 | |
| 236 | for(int i = 0; i < 5; i++) |
| 237 | { |
| 238 | NodeStatus status = tree.tickWhileRunning(); |
| 239 | ASSERT_EQ(status, NodeStatus::SUCCESS); |
| 240 | } |
| 241 | // counters[0] contains the number of times TestA was ticked |
| 242 | ASSERT_EQ(counters[0], 1); |
| 243 | // counters[1] contains the number of times TestB was ticked |
| 244 | ASSERT_EQ(counters[1], 5); |
| 245 | } |
| 246 | |
| 247 | // Test for DelayNode with XML: delay_msec port should be honored |
| 248 | TEST(Decorator, DelayWithXML) |
nothing calls this directly
no test coverage detected