2023-08-29 14:12:09 +00:00
|
|
|
/**
|
2023-08-29 14:56:25 +00:00
|
|
|
* limbo_test.h
|
2023-08-29 14:12:09 +00:00
|
|
|
* =============================================================================
|
|
|
|
* Copyright 2021-2023 Serhii Snitsaruk
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
* https://opensource.org/licenses/MIT.
|
|
|
|
* =============================================================================
|
|
|
|
*/
|
|
|
|
|
2023-08-29 14:56:25 +00:00
|
|
|
#ifndef LIMBO_TEST_H
|
|
|
|
#define LIMBO_TEST_H
|
|
|
|
|
|
|
|
#include "tests/test_macros.h"
|
2023-08-29 14:12:09 +00:00
|
|
|
|
|
|
|
#include "modules/limboai/bt/tasks/bt_action.h"
|
|
|
|
|
|
|
|
class BTTestAction : public BTAction {
|
|
|
|
GDCLASS(BTTestAction, BTAction);
|
|
|
|
|
|
|
|
public:
|
2023-08-29 14:32:14 +00:00
|
|
|
int ret_status = BTTask::SUCCESS;
|
2023-08-29 14:12:09 +00:00
|
|
|
int num_entries = 0;
|
|
|
|
int num_ticks = 0;
|
|
|
|
int num_exits = 0;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void _enter() override { num_entries += 1; }
|
|
|
|
virtual void _exit() override { num_exits += 1; }
|
|
|
|
|
|
|
|
virtual int _tick(double p_delta) override {
|
|
|
|
num_ticks += 1;
|
|
|
|
return ret_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2023-08-30 10:20:18 +00:00
|
|
|
bool is_status_either(int p_status1, int p_status2) { return (get_status() == p_status1 || get_status() == p_status2); }
|
|
|
|
|
2023-08-29 14:12:09 +00:00
|
|
|
BTTestAction(int p_return_status) { ret_status = p_return_status; }
|
2023-08-30 08:34:12 +00:00
|
|
|
BTTestAction() {}
|
2023-08-29 14:12:09 +00:00
|
|
|
};
|
|
|
|
|
2023-08-29 14:56:25 +00:00
|
|
|
#define CHECK_ENTRIES_TICKS_EXITS(m_task, m_entries, m_ticks, m_exits) \
|
|
|
|
CHECK(m_task->num_entries == m_entries); \
|
|
|
|
CHECK(m_task->num_ticks == m_ticks); \
|
|
|
|
CHECK(m_task->num_exits == m_exits);
|
|
|
|
|
2023-08-30 09:19:14 +00:00
|
|
|
#define CHECK_ENTRIES_TICKS_EXITS_UP_TO(m_task, m_entries, m_ticks, m_exits) \
|
|
|
|
CHECK(m_task->num_entries <= m_entries); \
|
|
|
|
CHECK(m_task->num_ticks <= m_ticks); \
|
|
|
|
CHECK(m_task->num_exits <= m_exits);
|
|
|
|
|
2023-08-29 14:56:25 +00:00
|
|
|
#endif // LIMBO_TEST_H
|