Add tests for has_transition() and remove_transition()

This commit is contained in:
Serhii Snitsaruk 2024-07-21 14:02:27 +02:00
parent cf99a27692
commit b478c8eb2c
No known key found for this signature in database
GPG Key ID: A965EF8799FFEC2D
1 changed files with 15 additions and 0 deletions

View File

@ -86,6 +86,21 @@ TEST_CASE("[Modules][LimboAI] HSM") {
hsm->initialize(agent, parent_scope); hsm->initialize(agent, parent_scope);
hsm->set_active(true); hsm->set_active(true);
SUBCASE("Test has_transition() and remove_transition()") {
CHECK(hsm->has_transition(state_alpha, "event_one"));
CHECK(hsm->has_transition(state_beta, "event_two"));
CHECK(hsm->has_transition(hsm->anystate(), "goto_nested"));
CHECK_FALSE(hsm->has_transition(state_alpha, "event_two"));
CHECK_FALSE(hsm->has_transition(state_beta, "event_one"));
CHECK_FALSE(hsm->has_transition(hsm->anystate(), "event_one"));
hsm->remove_transition(state_alpha, "event_one");
CHECK_FALSE(hsm->has_transition(state_alpha, "event_one"));
hsm->remove_transition(state_beta, "event_two");
CHECK_FALSE(hsm->has_transition(state_beta, "event_two"));
hsm->remove_transition(hsm->anystate(), "goto_nested");
CHECK_FALSE(hsm->has_transition(hsm->anystate(), "goto_nested"));
}
SUBCASE("Test get_root()") { SUBCASE("Test get_root()") {
CHECK(state_alpha->get_root() == hsm); CHECK(state_alpha->get_root() == hsm);
CHECK(state_beta->get_root() == hsm); CHECK(state_beta->get_root() == hsm);