From b0e3753d76db7b8f482f629d7318d83985e60fb0 Mon Sep 17 00:00:00 2001 From: Serhii Snitsaruk Date: Fri, 8 Mar 2024 20:04:27 +0100 Subject: [PATCH] Update HSM unit tests --- tests/test_hsm.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_hsm.h b/tests/test_hsm.h index 43309b4..72a553e 100644 --- a/tests/test_hsm.h +++ b/tests/test_hsm.h @@ -60,7 +60,8 @@ TEST_CASE("[Modules][LimboAI] HSM") { hsm->add_transition(state_beta, state_alpha, "event_two"); hsm->set_initial_state(state_alpha); - hsm->initialize(agent); + Ref parent_scope = memnew(Blackboard); + hsm->initialize(agent, parent_scope); hsm->set_active(true); SUBCASE("Test get_root()") { @@ -172,6 +173,12 @@ TEST_CASE("[Modules][LimboAI] HSM") { CHECK(hsm->is_active()); CHECK(hsm->get_active_state() == state_alpha); } + SUBCASE("Check if parent scope is accessible") { + parent_scope->set_var("parent_var", 100); + CHECK(state_alpha->get_blackboard()->get_parent() == parent_scope); + CHECK(state_beta->get_blackboard()->get_parent() == parent_scope); + CHECK(state_alpha->get_blackboard()->get_var("parent_var", Variant()) == Variant(100)); + } memdelete(agent); memdelete(hsm);