From b478c8eb2c68bdc370f8af316d4858125e890e05 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Sun, 21 Jul 2024 14:02:27 +0200 Subject: [PATCH] Add tests for has_transition() and remove_transition() --- tests/test_hsm.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/test_hsm.h b/tests/test_hsm.h index 533f279..73fe102 100644 --- a/tests/test_hsm.h +++ b/tests/test_hsm.h @@ -86,6 +86,21 @@ TEST_CASE("[Modules][LimboAI] HSM") { hsm->initialize(agent, parent_scope); 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()") { CHECK(state_alpha->get_root() == hsm); CHECK(state_beta->get_root() == hsm);