Skip to content

Commit 67cb978

Browse files
committed
added unit test
1 parent 8d2b109 commit 67cb978

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
@@ -137,3 +137,41 @@ TEST(Preconditions, Basic)
137137
ASSERT_EQ(counters[2], 0); // skipped
138138
ASSERT_EQ(counters[3], 1); // executed
139139
}
140+
141+
142+
TEST(Preconditions, Issue533)
143+
{
144+
BehaviorTreeFactory factory;
145+
std::array<int, 3> counters;
146+
RegisterTestTick(factory, "Test", counters);
147+
148+
const std::string xml_text = R"(
149+
150+
<root BTCPP_format="4" >
151+
<BehaviorTree ID="MainTree">
152+
<Sequence>
153+
<TestA _skipIf="A!=1" />
154+
<TestB _skipIf="A!=2" _onSuccess="A=1"/>
155+
<TestC _skipIf="A!=3" _onSuccess="A=2"/>
156+
</Sequence>
157+
</BehaviorTree>
158+
</root>)";
159+
160+
auto tree = factory.createTreeFromText(xml_text);
161+
tree.subtrees.front()->blackboard->set("A", 3);
162+
163+
tree.tickOnce();
164+
ASSERT_EQ(counters[0], 0);
165+
ASSERT_EQ(counters[1], 0);
166+
ASSERT_EQ(counters[2], 1);
167+
168+
tree.tickOnce();
169+
ASSERT_EQ(counters[0], 0);
170+
ASSERT_EQ(counters[1], 1);
171+
ASSERT_EQ(counters[2], 1);
172+
173+
tree.tickOnce();
174+
ASSERT_EQ(counters[0], 1);
175+
ASSERT_EQ(counters[1], 1);
176+
ASSERT_EQ(counters[2], 1);
177+
}

0 commit comments

Comments
 (0)