Skip to content

Commit

Permalink
Add unit test for switch node in combination with enum values
Browse files Browse the repository at this point in the history
  • Loading branch information
Roboterbastler committed Jan 16, 2024
1 parent 574a34f commit 74449f5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/gtest_enums.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,34 @@ TEST(Enums, StrintToEnum)
}
}

TEST(Enums, SwitchNodeWithEnum)
{
const std::string xml_txt = R"(
<root BTCPP_format="4" >
<BehaviorTree ID="Main">
<Sequence>
<Script code=" my_color := Blue "/>
<Switch4 variable="{my_color}"
case_1="{Red}"
case_2="{Blue}"
case_3="{Green}"
case_4="{Undefined}">
<AlwaysFailure name="case_red" />
<AlwaysSuccess name="case_blue" />
<AlwaysFailure name="case_green" />
<AlwaysFailure name="case_undefined" />
<AlwaysFailure name="default_case" />
</Switch4>
</Sequence>
</BehaviorTree>
</root>)";

BehaviorTreeFactory factory;
factory.registerScriptingEnums<Color>();

auto tree = factory.createTreeFromText(xml_txt);

NodeStatus status = tree.tickWhileRunning();

ASSERT_EQ(status, NodeStatus::SUCCESS);
}

0 comments on commit 74449f5

Please sign in to comment.