You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1016 B
50 lines
1016 B
#include <fmt/core.h>
|
|
#include <deque>
|
|
#include <string>
|
|
#include <fuc2/testing.hpp>
|
|
#define SOL_ALL_SAFETIES_ON 1
|
|
#include <sol/sol.hpp>
|
|
|
|
using namespace fuc2;
|
|
|
|
namespace bao_tests {
|
|
|
|
struct BAEntity {
|
|
std::string name;
|
|
int hp=0;
|
|
int damage=0;
|
|
bool dead=false;
|
|
};
|
|
|
|
void test_bao_basics() {
|
|
std::vector<BAEntity> entities;
|
|
|
|
for(int i = 0; i < 10; i++) {
|
|
auto name = fmt::format("Fighter-{}", i);
|
|
entities.emplace_back(name, i+10, i+1);
|
|
}
|
|
|
|
sol::state lua;
|
|
lua.open_libraries(sol::lib::base);
|
|
lua.new_usertype<BAEntity>("BAEntity",
|
|
"name", &BAEntity::name,
|
|
"hp", &BAEntity::hp,
|
|
"damage", &BAEntity::damage,
|
|
"dead", &BAEntity::dead);
|
|
|
|
lua.script_file("tests/bao_tests.lua");
|
|
sol::function handler = lua["handler"];
|
|
|
|
for(auto& fighter : entities) {
|
|
handler(fighter);
|
|
}
|
|
}
|
|
|
|
fuc2::Set TESTS{
|
|
.name="bao",
|
|
.options={ .fail_fast=false },
|
|
.tests={
|
|
TEST(test_bao_basics),
|
|
}
|
|
};
|
|
}
|
|
|