Refactor unit tests
This commit is contained in:
parent
9600e94ee6
commit
3667360d35
|
@ -36,6 +36,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BTTestAction(int p_return_status) { ret_status = p_return_status; }
|
BTTestAction(int p_return_status) { ret_status = p_return_status; }
|
||||||
|
BTTestAction() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CHECK_ENTRIES_TICKS_EXITS(m_task, m_entries, m_ticks, m_exits) \
|
#define CHECK_ENTRIES_TICKS_EXITS(m_task, m_entries, m_ticks, m_exits) \
|
||||||
|
|
|
@ -21,9 +21,9 @@ namespace TestDynamicSelector {
|
||||||
|
|
||||||
TEST_CASE("[Modules][LimboAI] BTDynamicSelector") {
|
TEST_CASE("[Modules][LimboAI] BTDynamicSelector") {
|
||||||
Ref<BTDynamicSelector> sel = memnew(BTDynamicSelector);
|
Ref<BTDynamicSelector> sel = memnew(BTDynamicSelector);
|
||||||
Ref<BTTestAction> task1 = memnew(BTTestAction(BTTask::SUCCESS));
|
Ref<BTTestAction> task1 = memnew(BTTestAction());
|
||||||
Ref<BTTestAction> task2 = memnew(BTTestAction(BTTask::SUCCESS));
|
Ref<BTTestAction> task2 = memnew(BTTestAction());
|
||||||
Ref<BTTestAction> task3 = memnew(BTTestAction(BTTask::SUCCESS));
|
Ref<BTTestAction> task3 = memnew(BTTestAction());
|
||||||
|
|
||||||
sel->add_child(task1);
|
sel->add_child(task1);
|
||||||
sel->add_child(task2);
|
sel->add_child(task2);
|
||||||
|
@ -36,7 +36,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSelector") {
|
||||||
task2->ret_status = BTTask::RUNNING;
|
task2->ret_status = BTTask::RUNNING;
|
||||||
task3->ret_status = BTTask::SUCCESS;
|
task3->ret_status = BTTask::SUCCESS;
|
||||||
|
|
||||||
CHECK(sel->execute(0.1666) == BTTask::RUNNING);
|
CHECK(sel->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
@ -47,7 +47,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSelector") {
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0); // * still fresh
|
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0); // * still fresh
|
||||||
|
|
||||||
SUBCASE("Subcase 1A: With no changes, first task is re-evaluated.") {
|
SUBCASE("Subcase 1A: With no changes, first task is re-evaluated.") {
|
||||||
CHECK(sel->execute(0.1666) == BTTask::RUNNING);
|
CHECK(sel->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
@ -60,7 +60,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSelector") {
|
||||||
|
|
||||||
SUBCASE("Subcase 1B: When second task succeeds, we finish with SUCCESS.") {
|
SUBCASE("Subcase 1B: When second task succeeds, we finish with SUCCESS.") {
|
||||||
task2->ret_status = BTTask::SUCCESS;
|
task2->ret_status = BTTask::SUCCESS;
|
||||||
CHECK(sel->execute(0.1666) == BTTask::SUCCESS);
|
CHECK(sel->execute(0.01666) == BTTask::SUCCESS);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::SUCCESS);
|
CHECK(task2->get_status() == BTTask::SUCCESS);
|
||||||
|
@ -73,7 +73,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSelector") {
|
||||||
|
|
||||||
SUBCASE("Subcase 1C: When first task re-evaluates to SUCCESS, second task should be cancelled and exited.") {
|
SUBCASE("Subcase 1C: When first task re-evaluates to SUCCESS, second task should be cancelled and exited.") {
|
||||||
task1->ret_status = BTTask::SUCCESS;
|
task1->ret_status = BTTask::SUCCESS;
|
||||||
CHECK(sel->execute(0.1666) == BTTask::SUCCESS);
|
CHECK(sel->execute(0.01666) == BTTask::SUCCESS);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::FRESH); // * cancelled - status changed to FRESH
|
CHECK(task2->get_status() == BTTask::FRESH); // * cancelled - status changed to FRESH
|
||||||
|
@ -88,7 +88,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSelector") {
|
||||||
task1->ret_status = BTTask::FAILURE;
|
task1->ret_status = BTTask::FAILURE;
|
||||||
task2->ret_status = BTTask::FAILURE;
|
task2->ret_status = BTTask::FAILURE;
|
||||||
task3->ret_status = BTTask::RUNNING;
|
task3->ret_status = BTTask::RUNNING;
|
||||||
CHECK(sel->execute(0.1666) == BTTask::RUNNING);
|
CHECK(sel->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
@ -102,7 +102,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSelector") {
|
||||||
task1->ret_status = BTTask::FAILURE;
|
task1->ret_status = BTTask::FAILURE;
|
||||||
task2->ret_status = BTTask::FAILURE;
|
task2->ret_status = BTTask::FAILURE;
|
||||||
task3->ret_status = BTTask::FAILURE;
|
task3->ret_status = BTTask::FAILURE;
|
||||||
CHECK(sel->execute(0.1666) == BTTask::FAILURE);
|
CHECK(sel->execute(0.01666) == BTTask::FAILURE);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
|
|
@ -21,9 +21,9 @@ namespace TestDynamicSequence {
|
||||||
|
|
||||||
TEST_CASE("[Modules][LimboAI] BTDynamicSequence") {
|
TEST_CASE("[Modules][LimboAI] BTDynamicSequence") {
|
||||||
Ref<BTDynamicSequence> seq = memnew(BTDynamicSequence);
|
Ref<BTDynamicSequence> seq = memnew(BTDynamicSequence);
|
||||||
Ref<BTTestAction> task1 = memnew(BTTestAction(BTTask::SUCCESS));
|
Ref<BTTestAction> task1 = memnew(BTTestAction());
|
||||||
Ref<BTTestAction> task2 = memnew(BTTestAction(BTTask::SUCCESS));
|
Ref<BTTestAction> task2 = memnew(BTTestAction());
|
||||||
Ref<BTTestAction> task3 = memnew(BTTestAction(BTTask::SUCCESS));
|
Ref<BTTestAction> task3 = memnew(BTTestAction());
|
||||||
|
|
||||||
seq->add_child(task1);
|
seq->add_child(task1);
|
||||||
seq->add_child(task2);
|
seq->add_child(task2);
|
||||||
|
@ -36,7 +36,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSequence") {
|
||||||
task2->ret_status = BTTask::RUNNING;
|
task2->ret_status = BTTask::RUNNING;
|
||||||
task3->ret_status = BTTask::SUCCESS;
|
task3->ret_status = BTTask::SUCCESS;
|
||||||
|
|
||||||
CHECK(seq->execute(0.1666) == BTTask::RUNNING);
|
CHECK(seq->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
@ -47,7 +47,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSequence") {
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0); // * still fresh
|
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0); // * still fresh
|
||||||
|
|
||||||
SUBCASE("Subcase 1A: With no changes, first task is re-evaluated.") {
|
SUBCASE("Subcase 1A: With no changes, first task is re-evaluated.") {
|
||||||
CHECK(seq->execute(0.1666) == BTTask::RUNNING);
|
CHECK(seq->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
@ -60,7 +60,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSequence") {
|
||||||
|
|
||||||
SUBCASE("Subcase 1B: When first task re-evaluates to FAILURE, second task should be cancelled and exited.") {
|
SUBCASE("Subcase 1B: When first task re-evaluates to FAILURE, second task should be cancelled and exited.") {
|
||||||
task1->ret_status = BTTask::FAILURE;
|
task1->ret_status = BTTask::FAILURE;
|
||||||
CHECK(seq->execute(0.1666) == BTTask::FAILURE);
|
CHECK(seq->execute(0.01666) == BTTask::FAILURE);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::FRESH); // * cancelled - status changed to FRESH
|
CHECK(task2->get_status() == BTTask::FRESH); // * cancelled - status changed to FRESH
|
||||||
|
@ -75,7 +75,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSequence") {
|
||||||
task1->ret_status = BTTask::SUCCESS;
|
task1->ret_status = BTTask::SUCCESS;
|
||||||
task2->ret_status = BTTask::SUCCESS;
|
task2->ret_status = BTTask::SUCCESS;
|
||||||
task3->ret_status = BTTask::RUNNING;
|
task3->ret_status = BTTask::RUNNING;
|
||||||
CHECK(seq->execute(0.1666) == BTTask::RUNNING);
|
CHECK(seq->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::SUCCESS);
|
CHECK(task2->get_status() == BTTask::SUCCESS);
|
||||||
|
@ -89,7 +89,7 @@ TEST_CASE("[Modules][LimboAI] BTDynamicSequence") {
|
||||||
task1->ret_status = BTTask::SUCCESS;
|
task1->ret_status = BTTask::SUCCESS;
|
||||||
task2->ret_status = BTTask::SUCCESS;
|
task2->ret_status = BTTask::SUCCESS;
|
||||||
task3->ret_status = BTTask::SUCCESS;
|
task3->ret_status = BTTask::SUCCESS;
|
||||||
CHECK(seq->execute(0.1666) == BTTask::SUCCESS);
|
CHECK(seq->execute(0.01666) == BTTask::SUCCESS);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::SUCCESS);
|
CHECK(task2->get_status() == BTTask::SUCCESS);
|
||||||
|
|
|
@ -21,9 +21,9 @@ namespace TestParallel {
|
||||||
|
|
||||||
TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_required_failures: 1") {
|
TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_required_failures: 1") {
|
||||||
Ref<BTParallel> par = memnew(BTParallel);
|
Ref<BTParallel> par = memnew(BTParallel);
|
||||||
Ref<BTTestAction> task1 = memnew(BTTestAction(BTTask::SUCCESS));
|
Ref<BTTestAction> task1 = memnew(BTTestAction());
|
||||||
Ref<BTTestAction> task2 = memnew(BTTestAction(BTTask::SUCCESS));
|
Ref<BTTestAction> task2 = memnew(BTTestAction());
|
||||||
Ref<BTTestAction> task3 = memnew(BTTestAction(BTTask::SUCCESS));
|
Ref<BTTestAction> task3 = memnew(BTTestAction());
|
||||||
|
|
||||||
par->add_child(task1);
|
par->add_child(task1);
|
||||||
par->add_child(task2);
|
par->add_child(task2);
|
||||||
|
@ -33,14 +33,14 @@ TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_
|
||||||
|
|
||||||
SUBCASE("BTParallel composition {RUNNING, SUCCESS, FAILURE} and successes/failures required 1/1") {
|
SUBCASE("BTParallel composition {RUNNING, SUCCESS, FAILURE} and successes/failures required 1/1") {
|
||||||
// * Case #1: When reached both success and failure required, we expect one that triggered sooner (SUCCESS in this case).
|
// * Case #1: When reached both success and failure required, we expect one that triggered sooner (SUCCESS in this case).
|
||||||
par->set_num_successes_required(1);
|
|
||||||
par->set_num_failures_required(1);
|
|
||||||
par->set_repeat(false);
|
|
||||||
task1->ret_status = BTTask::RUNNING;
|
task1->ret_status = BTTask::RUNNING;
|
||||||
task2->ret_status = BTTask::SUCCESS;
|
task2->ret_status = BTTask::SUCCESS;
|
||||||
task3->ret_status = BTTask::FAILURE;
|
task3->ret_status = BTTask::FAILURE;
|
||||||
|
par->set_num_successes_required(1);
|
||||||
|
par->set_num_failures_required(1);
|
||||||
|
par->set_repeat(false);
|
||||||
|
|
||||||
CHECK(par->execute(0.1666) == BTTask::SUCCESS); // When reached both conditions.
|
CHECK(par->execute(0.01666) == BTTask::SUCCESS); // When reached both conditions.
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::RUNNING);
|
CHECK(task1->get_status() == BTTask::RUNNING);
|
||||||
CHECK(task2->get_status() == BTTask::SUCCESS);
|
CHECK(task2->get_status() == BTTask::SUCCESS);
|
||||||
|
@ -53,14 +53,14 @@ TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_
|
||||||
|
|
||||||
SUBCASE("BTParallel composition {RUNNING, SUCCESS, RUNNING} and successes/failures required 1/1") {
|
SUBCASE("BTParallel composition {RUNNING, SUCCESS, RUNNING} and successes/failures required 1/1") {
|
||||||
// * Case #1b: When reached required number of successes, we expect SUCCESS.
|
// * Case #1b: When reached required number of successes, we expect SUCCESS.
|
||||||
par->set_num_successes_required(1);
|
|
||||||
par->set_num_failures_required(1);
|
|
||||||
par->set_repeat(false);
|
|
||||||
task1->ret_status = BTTask::RUNNING;
|
task1->ret_status = BTTask::RUNNING;
|
||||||
task2->ret_status = BTTask::SUCCESS;
|
task2->ret_status = BTTask::SUCCESS;
|
||||||
task3->ret_status = BTTask::RUNNING;
|
task3->ret_status = BTTask::RUNNING;
|
||||||
|
par->set_num_successes_required(1);
|
||||||
|
par->set_num_failures_required(1);
|
||||||
|
par->set_repeat(false);
|
||||||
|
|
||||||
CHECK(par->execute(0.1666) == BTTask::SUCCESS);
|
CHECK(par->execute(0.01666) == BTTask::SUCCESS);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::RUNNING);
|
CHECK(task1->get_status() == BTTask::RUNNING);
|
||||||
CHECK(task2->get_status() == BTTask::SUCCESS);
|
CHECK(task2->get_status() == BTTask::SUCCESS);
|
||||||
|
@ -73,14 +73,14 @@ TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_
|
||||||
|
|
||||||
SUBCASE("BTParallel composition {RUNNING, FAILURE, RUNNING} and successes/failures required 1/1") {
|
SUBCASE("BTParallel composition {RUNNING, FAILURE, RUNNING} and successes/failures required 1/1") {
|
||||||
// * Case #1c: When reached required number of failures, we expect FAILURE.
|
// * Case #1c: When reached required number of failures, we expect FAILURE.
|
||||||
par->set_num_successes_required(1);
|
|
||||||
par->set_num_failures_required(1);
|
|
||||||
par->set_repeat(false);
|
|
||||||
task1->ret_status = BTTask::RUNNING;
|
task1->ret_status = BTTask::RUNNING;
|
||||||
task2->ret_status = BTTask::FAILURE;
|
task2->ret_status = BTTask::FAILURE;
|
||||||
task3->ret_status = BTTask::RUNNING;
|
task3->ret_status = BTTask::RUNNING;
|
||||||
|
par->set_num_successes_required(1);
|
||||||
|
par->set_num_failures_required(1);
|
||||||
|
par->set_repeat(false);
|
||||||
|
|
||||||
CHECK(par->execute(0.1666) == BTTask::FAILURE);
|
CHECK(par->execute(0.01666) == BTTask::FAILURE);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::RUNNING);
|
CHECK(task1->get_status() == BTTask::RUNNING);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
@ -101,7 +101,7 @@ TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_
|
||||||
par->set_num_failures_required(3);
|
par->set_num_failures_required(3);
|
||||||
par->set_repeat(false);
|
par->set_repeat(false);
|
||||||
|
|
||||||
CHECK(par->execute(0.1666) == BTTask::RUNNING);
|
CHECK(par->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
@ -121,7 +121,7 @@ TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_
|
||||||
par->set_num_successes_required(3);
|
par->set_num_successes_required(3);
|
||||||
par->set_num_failures_required(3);
|
par->set_num_failures_required(3);
|
||||||
par->set_repeat(false);
|
par->set_repeat(false);
|
||||||
CHECK(par->execute(0.1666) == BTTask::FAILURE);
|
CHECK(par->execute(0.01666) == BTTask::FAILURE);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
@ -141,7 +141,7 @@ TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_
|
||||||
par->set_num_successes_required(3);
|
par->set_num_successes_required(3);
|
||||||
par->set_num_failures_required(3);
|
par->set_num_failures_required(3);
|
||||||
par->set_repeat(true);
|
par->set_repeat(true);
|
||||||
CHECK(par->execute(0.1666) == BTTask::RUNNING);
|
CHECK(par->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
@ -152,7 +152,7 @@ TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task3, 1, 1, 1);
|
CHECK_ENTRIES_TICKS_EXITS(task3, 1, 1, 1);
|
||||||
|
|
||||||
// * Execution #2: Check if tasks are repeated, when set so (there is no RUNNING task).
|
// * Execution #2: Check if tasks are repeated, when set so (there is no RUNNING task).
|
||||||
CHECK(par->execute(0.1666) == BTTask::RUNNING);
|
CHECK(par->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
@ -172,7 +172,7 @@ TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_
|
||||||
par->set_num_successes_required(2);
|
par->set_num_successes_required(2);
|
||||||
par->set_num_failures_required(2);
|
par->set_num_failures_required(2);
|
||||||
par->set_repeat(false);
|
par->set_repeat(false);
|
||||||
CHECK(par->execute(0.1666) == BTTask::RUNNING);
|
CHECK(par->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
@ -183,7 +183,7 @@ TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task3, 1, 1, 1);
|
CHECK_ENTRIES_TICKS_EXITS(task3, 1, 1, 1);
|
||||||
|
|
||||||
// * Execution #2: Check if tasks are not repeated, when set so.
|
// * Execution #2: Check if tasks are not repeated, when set so.
|
||||||
CHECK(par->execute(0.1666) == BTTask::RUNNING);
|
CHECK(par->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
@ -195,7 +195,7 @@ TEST_CASE("[Modules][LimboAI] BTParallel with num_required_successes: 1 and num_
|
||||||
|
|
||||||
// * Execution #3: Check if tasks are repeated, when set so.
|
// * Execution #3: Check if tasks are repeated, when set so.
|
||||||
par->set_repeat(true);
|
par->set_repeat(true);
|
||||||
CHECK(par->execute(0.1666) == BTTask::RUNNING);
|
CHECK(par->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
|
|
@ -32,7 +32,7 @@ TEST_CASE("[Modules][LimboAI] BTSelector when all return FAILURE") {
|
||||||
REQUIRE(sel->get_child_count() == 3);
|
REQUIRE(sel->get_child_count() == 3);
|
||||||
|
|
||||||
// * First execution.
|
// * First execution.
|
||||||
CHECK(sel->execute(0.1666) == BTTask::FAILURE);
|
CHECK(sel->execute(0.01666) == BTTask::FAILURE);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
@ -43,7 +43,7 @@ TEST_CASE("[Modules][LimboAI] BTSelector when all return FAILURE") {
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task3, 1, 1, 1);
|
CHECK_ENTRIES_TICKS_EXITS(task3, 1, 1, 1);
|
||||||
|
|
||||||
// * Second execution.
|
// * Second execution.
|
||||||
CHECK(sel->execute(0.1666) == BTTask::FAILURE);
|
CHECK(sel->execute(0.01666) == BTTask::FAILURE);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
@ -67,7 +67,7 @@ TEST_CASE("[Modules][LimboAI] BTSelector when second returns SUCCESS") {
|
||||||
REQUIRE(sel->get_child_count() == 3);
|
REQUIRE(sel->get_child_count() == 3);
|
||||||
|
|
||||||
// * First execution.
|
// * First execution.
|
||||||
CHECK(sel->execute(0.1666) == BTTask::SUCCESS);
|
CHECK(sel->execute(0.01666) == BTTask::SUCCESS);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::SUCCESS);
|
CHECK(task2->get_status() == BTTask::SUCCESS);
|
||||||
|
@ -78,7 +78,7 @@ TEST_CASE("[Modules][LimboAI] BTSelector when second returns SUCCESS") {
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0);
|
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0);
|
||||||
|
|
||||||
// * Second execution.
|
// * Second execution.
|
||||||
CHECK(sel->execute(0.1666) == BTTask::SUCCESS);
|
CHECK(sel->execute(0.01666) == BTTask::SUCCESS);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::SUCCESS);
|
CHECK(task2->get_status() == BTTask::SUCCESS);
|
||||||
|
@ -102,7 +102,7 @@ TEST_CASE("[Modules][LimboAI] BTSelector when second returns RUNNING") {
|
||||||
REQUIRE(sel->get_child_count() == 3);
|
REQUIRE(sel->get_child_count() == 3);
|
||||||
|
|
||||||
// * First execution.
|
// * First execution.
|
||||||
CHECK(sel->execute(0.1666) == BTTask::RUNNING);
|
CHECK(sel->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
@ -113,7 +113,7 @@ TEST_CASE("[Modules][LimboAI] BTSelector when second returns RUNNING") {
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0);
|
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0);
|
||||||
|
|
||||||
// * Second execution.
|
// * Second execution.
|
||||||
CHECK(sel->execute(0.1666) == BTTask::RUNNING);
|
CHECK(sel->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
@ -125,7 +125,7 @@ TEST_CASE("[Modules][LimboAI] BTSelector when second returns RUNNING") {
|
||||||
|
|
||||||
// * Third execution with second task returning FAILURE.
|
// * Third execution with second task returning FAILURE.
|
||||||
task2->ret_status = BTTask::FAILURE;
|
task2->ret_status = BTTask::FAILURE;
|
||||||
CHECK(sel->execute(0.1666) == BTTask::FAILURE);
|
CHECK(sel->execute(0.01666) == BTTask::FAILURE);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::FAILURE);
|
CHECK(task1->get_status() == BTTask::FAILURE);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
|
|
@ -32,7 +32,7 @@ TEST_CASE("[Modules][LimboAI] BTSequence when all return SUCCESS") {
|
||||||
REQUIRE(seq->get_child_count() == 3);
|
REQUIRE(seq->get_child_count() == 3);
|
||||||
|
|
||||||
// * First execution.
|
// * First execution.
|
||||||
CHECK(seq->execute(0.1666) == BTTask::SUCCESS);
|
CHECK(seq->execute(0.01666) == BTTask::SUCCESS);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::SUCCESS);
|
CHECK(task2->get_status() == BTTask::SUCCESS);
|
||||||
|
@ -43,7 +43,7 @@ TEST_CASE("[Modules][LimboAI] BTSequence when all return SUCCESS") {
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task3, 1, 1, 1);
|
CHECK_ENTRIES_TICKS_EXITS(task3, 1, 1, 1);
|
||||||
|
|
||||||
// * Second execution.
|
// * Second execution.
|
||||||
CHECK(seq->execute(0.1666) == BTTask::SUCCESS);
|
CHECK(seq->execute(0.01666) == BTTask::SUCCESS);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::SUCCESS);
|
CHECK(task2->get_status() == BTTask::SUCCESS);
|
||||||
|
@ -67,7 +67,7 @@ TEST_CASE("[Modules][LimboAI] BTSequence when second returns FAILURE") {
|
||||||
REQUIRE(seq->get_child_count() == 3);
|
REQUIRE(seq->get_child_count() == 3);
|
||||||
|
|
||||||
// * First execution.
|
// * First execution.
|
||||||
CHECK(seq->execute(0.1666) == BTTask::FAILURE);
|
CHECK(seq->execute(0.01666) == BTTask::FAILURE);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
@ -78,7 +78,7 @@ TEST_CASE("[Modules][LimboAI] BTSequence when second returns FAILURE") {
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0);
|
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0);
|
||||||
|
|
||||||
// * Second execution.
|
// * Second execution.
|
||||||
CHECK(seq->execute(0.1666) == BTTask::FAILURE);
|
CHECK(seq->execute(0.01666) == BTTask::FAILURE);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::FAILURE);
|
CHECK(task2->get_status() == BTTask::FAILURE);
|
||||||
|
@ -102,7 +102,7 @@ TEST_CASE("[Modules][LimboAI] BTSequence when second returns RUNNING") {
|
||||||
REQUIRE(seq->get_child_count() == 3);
|
REQUIRE(seq->get_child_count() == 3);
|
||||||
|
|
||||||
// * First execution.
|
// * First execution.
|
||||||
CHECK(seq->execute(0.1666) == BTTask::RUNNING);
|
CHECK(seq->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::RUNNING);
|
CHECK(task2->get_status() == BTTask::RUNNING);
|
||||||
|
@ -113,7 +113,7 @@ TEST_CASE("[Modules][LimboAI] BTSequence when second returns RUNNING") {
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0);
|
CHECK_ENTRIES_TICKS_EXITS(task3, 0, 0, 0);
|
||||||
|
|
||||||
// * Second execution.
|
// * Second execution.
|
||||||
CHECK(seq->execute(0.1666) == BTTask::RUNNING);
|
CHECK(seq->execute(0.01666) == BTTask::RUNNING);
|
||||||
|
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task1, 1, 1, 1);
|
CHECK_ENTRIES_TICKS_EXITS(task1, 1, 1, 1);
|
||||||
CHECK_ENTRIES_TICKS_EXITS(task2, 1, 2, 0);
|
CHECK_ENTRIES_TICKS_EXITS(task2, 1, 2, 0);
|
||||||
|
@ -121,7 +121,7 @@ TEST_CASE("[Modules][LimboAI] BTSequence when second returns RUNNING") {
|
||||||
|
|
||||||
// * Third execution with second task returning SUCCESS.
|
// * Third execution with second task returning SUCCESS.
|
||||||
task2->ret_status = BTTask::SUCCESS;
|
task2->ret_status = BTTask::SUCCESS;
|
||||||
CHECK(seq->execute(0.1666) == BTTask::SUCCESS);
|
CHECK(seq->execute(0.01666) == BTTask::SUCCESS);
|
||||||
|
|
||||||
CHECK(task1->get_status() == BTTask::SUCCESS);
|
CHECK(task1->get_status() == BTTask::SUCCESS);
|
||||||
CHECK(task2->get_status() == BTTask::SUCCESS);
|
CHECK(task2->get_status() == BTTask::SUCCESS);
|
||||||
|
@ -136,7 +136,7 @@ TEST_CASE("[Modules][LimboAI] BTSequence with no child tasks") {
|
||||||
Ref<BTSequence> seq = memnew(BTSequence);
|
Ref<BTSequence> seq = memnew(BTSequence);
|
||||||
|
|
||||||
REQUIRE(seq->get_child_count() == 0);
|
REQUIRE(seq->get_child_count() == 0);
|
||||||
CHECK(seq->execute(0.1666) == BTTask::SUCCESS);
|
CHECK(seq->execute(0.01666) == BTTask::SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
} //namespace TestSequence
|
} //namespace TestSequence
|
||||||
|
|
Loading…
Reference in New Issue