Skip to content

Commit 74449f5

Browse files
Add unit test for switch node in combination with enum values
1 parent 574a34f commit 74449f5

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/gtest_enums.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,34 @@ TEST(Enums, StrintToEnum)
8989
}
9090
}
9191

92+
TEST(Enums, SwitchNodeWithEnum)
93+
{
94+
const std::string xml_txt = R"(
95+
<root BTCPP_format="4" >
96+
<BehaviorTree ID="Main">
97+
<Sequence>
98+
<Script code=" my_color := Blue "/>
99+
<Switch4 variable="{my_color}"
100+
case_1="{Red}"
101+
case_2="{Blue}"
102+
case_3="{Green}"
103+
case_4="{Undefined}">
104+
<AlwaysFailure name="case_red" />
105+
<AlwaysSuccess name="case_blue" />
106+
<AlwaysFailure name="case_green" />
107+
<AlwaysFailure name="case_undefined" />
108+
<AlwaysFailure name="default_case" />
109+
</Switch4>
110+
</Sequence>
111+
</BehaviorTree>
112+
</root>)";
113+
114+
BehaviorTreeFactory factory;
115+
factory.registerScriptingEnums<Color>();
116+
117+
auto tree = factory.createTreeFromText(xml_txt);
118+
119+
NodeStatus status = tree.tickWhileRunning();
120+
121+
ASSERT_EQ(status, NodeStatus::SUCCESS);
122+
}

0 commit comments

Comments
 (0)