//< Action Nodes Tests LOAD_TEST(btunittest, action_ut_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/action_ut_0", format); myTestAgent->resetProperties(); ChildNodeTest* testChildAgent = behaviac::Agent::Create<ChildNodeTest>(1, "par_child", 0, 0); StaticAgent* pStaticAgent = behaviac::Agent::Create<StaticAgent>("StaticAgent"); myTestAgent->testVar_3 = 1; testChildAgent->testVar_2 = 2; myTestAgent->SetVariable<ChildNodeTest*>("par_child", testChildAgent); myTestAgent->btexec(); CHECK_EQUAL(1500, myTestAgent->testVar_0); CHECK_EQUAL(1800, myTestAgent->testVar_1); CHECK_EQUAL("null", myTestAgent->testVar_str_0); CHECK_EQUAL(2, StaticAgent::sInt); CHECK_EQUAL(true, testChildAgent->m_bTargetValid); behaviac::Agent::Destroy(testChildAgent); behaviac::Agent::Destroy(pStaticAgent); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, selector_loop_ut_8) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/selector_loop_ut_8", format); myTestAgent->resetProperties(); myTestAgent->testVar_0 = 10; myTestAgent->m_bCanSee = false; behaviac::EBTStatus s = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_RUNNING, s); CHECK_EQUAL(2, myTestAgent->testVar_0); CHECK_EQUAL(1, myTestAgent->testVar_1); myTestAgent->testVar_0 = 10; s = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_RUNNING, s); CHECK_EQUAL(2, myTestAgent->testVar_0); CHECK_EQUAL(2, myTestAgent->testVar_1); s = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_SUCCESS, s); CHECK_EQUAL(2, myTestAgent->testVar_0); CHECK_EQUAL(101, myTestAgent->testVar_1); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, action_ut_waitforsignal_0_saveload_agent) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/action_ut_waitforsignal_0", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); BEHAVIAC_UNUSED_VAR(status); CHECK_EQUAL(-1, myTestAgent->testVar_1); CHECK_FLOAT_EQUAL(-1.0f, myTestAgent->testVar_2); behaviac::State_t state; myTestAgent->btsave(state); state.SaveToFile("btsave3.xml", myTestAgent); //modify the members myTestAgent->testVar_1 = 1; myTestAgent->testVar_2 = 1; behaviac::State_t stateTemp; stateTemp.LoadFromFile("btsave3.xml", myTestAgent); CHECK_EQUAL(-1, myTestAgent->testVar_1); CHECK_FLOAT_EQUAL(-1.0f, myTestAgent->testVar_2); myTestAgent->btload(stateTemp); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, action_ut_1) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/action_ut_1", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); BEHAVIAC_UNUSED_VAR(status); CHECK_FLOAT_EQUAL(1.8f, myTestAgent->testVar_2); CHECK_FLOAT_EQUAL(4.5f, myTestAgent->testVar_3); CHECK_EQUAL("HC", myTestAgent->testVar_str_0); CHECK_EQUAL("NODE", myTestAgent->testVar_str_1); const TestNS::Float2& float2 = myTestAgent->GetVariable<TestNS::Float2>("testFloat2"); CHECK_FLOAT_EQUAL(1.0f, float2.x); CHECK_FLOAT_EQUAL(1.0f, float2.y); const TestNS::Float2& c_ReturnFloat2 = myTestAgent->GetVariable<TestNS::Float2>("c_ReturnFloat2"); CHECK_FLOAT_EQUAL(2.0f, c_ReturnFloat2.x); CHECK_FLOAT_EQUAL(2.0f, c_ReturnFloat2.y); const TestNS::Float2& c_ReturnFloat2Const = myTestAgent->GetVariable<TestNS::Float2>("c_ReturnFloat2Const"); CHECK_FLOAT_EQUAL(2.0f, c_ReturnFloat2Const.x); CHECK_FLOAT_EQUAL(2.0f, c_ReturnFloat2Const.y); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, decoration_successuntil_ut_1) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_successuntil_ut_1", format); myTestAgent->resetProperties(); int loopCount = 0; while (loopCount < 5) { behaviac::EBTStatus status = myTestAgent->btexec(); if (loopCount < 4) { CHECK_EQUAL(behaviac::BT_SUCCESS, status); } else { CHECK_EQUAL(behaviac::BT_FAILURE, status); } ++loopCount; } finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, decoration_loop_ut_1) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_loop_ut_1", format); int loopCount = 0; while (loopCount < 500) { myTestAgent->resetProperties(); myTestAgent->btexec(); if (loopCount < 499) { CHECK_EQUAL(0, myTestAgent->testVar_0); } else { CHECK_EQUAL(1, myTestAgent->testVar_0); } ++loopCount; } finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, decoration_countlimit_ut_2) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_countlimit_ut_2", format); myTestAgent->resetProperties(); int loopCount = 0; while (loopCount < 11) { if (loopCount == 5) { myTestAgent->testVar_1 = 0; myTestAgent->testVar_2 = 0.0f; } myTestAgent->btexec(); myTestAgent->testVar_1 = -1; if (loopCount < 10) { CHECK_EQUAL(0, myTestAgent->testVar_0); } else { CHECK_EQUAL(1, myTestAgent->testVar_0); } ++loopCount; } finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, selector_loop_ut_7) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/selector_loop_ut_7", format); myTestAgent->resetProperties(); myTestAgent->m_bCanSee = false; const int kCount = 5; for (int i = 0; i <kCount; ++i) { behaviac::EBTStatus s = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_RUNNING, s); CHECK_EQUAL(2, myTestAgent->testVar_0); CHECK_EQUAL(i + 1, myTestAgent->testVar_1); } myTestAgent->m_bCanSee = true; behaviac::EBTStatus s = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_RUNNING, s); CHECK_EQUAL(1, myTestAgent->testVar_0); CHECK_EQUAL(6, myTestAgent->testVar_1); myTestAgent->m_bTargetValid = false; s = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_SUCCESS, s); CHECK_EQUAL(1, myTestAgent->testVar_0); CHECK_EQUAL(3, myTestAgent->testVar_1); finlTestEnvNode(myTestAgent); }
//< Decoration Frames Tests LOAD_TEST(btunittest, decoration_frames_ut_0) { behaviac::Workspace::GetInstance()->SetFrameSinceStartup(0); AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_frames_ut_0", format); int loopCount = 0; while (loopCount < 100) { myTestAgent->resetProperties(); myTestAgent->btexec(); if (loopCount < 99) { CHECK_EQUAL(0, myTestAgent->testVar_0); } else { CHECK_EQUAL(1, myTestAgent->testVar_0); } ++loopCount; behaviac::Workspace::GetInstance()->SetFrameSinceStartup(behaviac::Workspace::GetInstance()->GetFrameSinceStartup() + 1); } finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, decoration_not_ut_1) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_not_ut_1", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); CHECK_EQUAL(0, myTestAgent->testVar_0); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, parallel_ut_2) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/parallel_ut_2", format); myTestAgent->resetProperties(); myTestAgent->btexec(); CHECK_EQUAL(2, myTestAgent->testVar_0); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, condition_ut_2) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/condition_ut_2", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); BEHAVIAC_UNUSED_VAR(status); CHECK_EQUAL(0, myTestAgent->testVar_0); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, predicate_sequence_ut_1) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/predicate_sequence_ut_1", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_FAILURE, status); CHECK_EQUAL(0, myTestAgent->testVar_0); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, selector_loop_ut_3) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/selector_loop_ut_3", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); BEHAVIAC_UNUSED_VAR(status); CHECK_EQUAL(-1, myTestAgent->testVar_0); finlTestEnvNode(myTestAgent); }
//< Noop Node Test LOAD_TEST(btunittest, action_noop_ut_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/action_noop_ut_0", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); CHECK_EQUAL(2, myTestAgent->testVar_0); CHECK_EQUAL(behaviac::BT_SUCCESS, status); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, reference_ut_2) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/reference_ut_2", format); myTestAgent->resetProperties(); myTestAgent->btexec(); CHECK_EQUAL(0, myTestAgent->testVar_0); CHECK_FLOAT_EQUAL(0.0f, myTestAgent->testVar_2); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, action_ut_3) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/action_ut_3", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); BEHAVIAC_UNUSED_VAR(status); CHECK_FLOAT_EQUAL(2.4f, myTestAgent->testVar_2); CHECK_FLOAT_EQUAL(4.0f, myTestAgent->testVar_3); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, decoration_repeat_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/repeat/repeat_ut_0", format); myTestAgent->resetProperties(); myTestAgent->btexec(); CHECK_EQUAL(5, myTestAgent->testVar_0); finlTestEnvNode(myTestAgent); }
//< Decoration Always Failure Tests LOAD_TEST(btunittest, decoration_alwaysfailure_ut_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_alwaysfailure_ut_0", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); CHECK_EQUAL(1, myTestAgent->testVar_0); CHECK_EQUAL(1, myTestAgent->testVar_1); CHECK_EQUAL(1.0f, myTestAgent->testVar_2); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, predicate_selector_ut_2) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/predicate_selector_ut_2", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_SUCCESS, status); CHECK_EQUAL(0, myTestAgent->testVar_0); CHECK_EQUAL(0, myTestAgent->testVar_1); CHECK_FLOAT_EQUAL(0.0f, myTestAgent->testVar_2); finlTestEnvNode(myTestAgent); }
//< Decoration Log Tests LOAD_TEST(btunittest, decoration_log_ut_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_log_ut_0", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); CHECK_EQUAL(0, myTestAgent->testVar_0); CHECK_EQUAL(1, myTestAgent->testVar_1); CHECK_FLOAT_EQUAL(0.0f, myTestAgent->testVar_2); CHECK_EQUAL(behaviac::BT_RUNNING, status); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, selector_loop_ut_5) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/selector_loop_ut_5", format); myTestAgent->resetProperties(); behaviac::EBTStatus s = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_SUCCESS, s); CHECK_EQUAL(1, myTestAgent->testVar_0); finlTestEnvNode(myTestAgent); }
//< Decoration Always Success Tests LOAD_TEST(btunittest, decoration_alwayssuccess_ut_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_alwayssuccess_ut_0", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); BEHAVIAC_UNUSED_VAR(status); CHECK_EQUAL(0, myTestAgent->testVar_0); CHECK_EQUAL(0, myTestAgent->testVar_1); CHECK_FLOAT_EQUAL(0.0f, myTestAgent->testVar_2); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, frames_ut_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/frames_ut_0", format); myTestAgent->resetProperties(); once_(myTestAgent); //rerun again once_(myTestAgent); finlTestEnvNode(myTestAgent); }
//< Decoration Failure Until Tests LOAD_TEST(btunittest, decoration_failureuntil_ut_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_failureuntil_ut_0", format); myTestAgent->resetProperties(); int loopCount = 0; while (loopCount < 1000) { behaviac::EBTStatus status = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_FAILURE, status); ++loopCount; } finlTestEnvNode(myTestAgent); }
//< Decoration Loop Tests LOAD_TEST(btunittest, decoration_loop_ut_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_loop_ut_0", format); int loopCount = 1000; while (loopCount > 0) { myTestAgent->resetProperties(); myTestAgent->btexec(); CHECK_EQUAL(0, myTestAgent->testVar_0); --loopCount; } finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, par_test_custom_property_reset) { AgentNodeTest* myTestAgent = initTestEnvNode("par_test/custom_property_reset", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_SUCCESS, status); CHECK_EQUAL(10, myTestAgent->testVar_1); status = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_SUCCESS, status); CHECK_EQUAL(20, myTestAgent->testVar_1); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, action_ut_waitforsignal_2) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/action_ut_waitforsignal_2", format); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); BEHAVIAC_UNUSED_VAR(status); CHECK_FLOAT_EQUAL(-1.0f, myTestAgent->testVar_2); CHECK_EQUAL(behaviac::BT_RUNNING, status); myTestAgent->resetProperties(); myTestAgent->testVar_2 = 0.0f; status = myTestAgent->btexec(); CHECK_FLOAT_EQUAL(2.3f, myTestAgent->testVar_2); CHECK_EQUAL(behaviac::BT_SUCCESS, status); finlTestEnvNode(myTestAgent); }
LOAD_TEST(btunittest, wait_ut_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/wait_ut_0", format); behaviac::Workspace::GetInstance()->SetTimeSinceStartup(0); myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_RUNNING, status); CHECK_EQUAL(1, myTestAgent->testVar_0); behaviac::Workspace::GetInstance()->SetTimeSinceStartup(1.001f); status = myTestAgent->btexec(); CHECK_EQUAL(behaviac::BT_SUCCESS, status); CHECK_EQUAL(2, myTestAgent->testVar_0); finlTestEnvNode(myTestAgent); }
//< Decoration Always Running Tests LOAD_TEST(btunittest, decoration_alwaysrunning_ut_0) { AgentNodeTest* myTestAgent = initTestEnvNode("node_test/decoration_alwaysrunning_ut_0", format); int loopCount = 0; while (loopCount < 1000) { myTestAgent->resetProperties(); behaviac::EBTStatus status = myTestAgent->btexec(); CHECK_EQUAL(0, myTestAgent->testVar_0); CHECK_EQUAL(0, myTestAgent->testVar_1); CHECK_EQUAL(0.0f, myTestAgent->testVar_2); ++loopCount; } finlTestEnvNode(myTestAgent); }