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

Function TEST

tests/gtest_preconditions.cpp:12–43  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10using namespace BT;
11
12TEST(PreconditionsDecorator, Integers)
13{
14 BehaviorTreeFactory factory;
15 std::array<int, 3> counters{};
16 RegisterTestTick(factory, "Test", counters);
17
18 const std::string xml_text = R"(
19
20 <root BTCPP_format="4" >
21 <BehaviorTree ID="MainTree">
22 <Sequence>
23 <Script code = "A:=1; B:=1; C:=3" />
24 <Precondition if="A==B" else="FAILURE">
25 <TestA/>
26 </Precondition>
27 <Precondition if="A==C" else="SUCCESS">
28 <TestB/>
29 </Precondition>
30 <Precondition if="A!=C" else="FAILURE">
31 <TestC/>
32 </Precondition>
33 </Sequence>
34 </BehaviorTree>
35 </root>)";
36
37 auto tree = factory.createTreeFromText(xml_text);
38 const auto status = tree.tickWhileRunning();
39 ASSERT_EQ(status, NodeStatus::SUCCESS);
40 ASSERT_EQ(counters[0], 1);
41 ASSERT_EQ(counters[1], 0);
42 ASSERT_EQ(counters[2], 1);
43}
44
45TEST(PreconditionsDecorator, DoubleEquals)
46{

Callers

nothing calls this directly

Calls 10

RegisterTestTickFunction · 0.85
BehaviorTreeFactoryClass · 0.85
createTreeFromTextMethod · 0.80
tickWhileRunningMethod · 0.80
tickOnceMethod · 0.80
setMethod · 0.80
createTreeMethod · 0.80
rootBlackboardMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected