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.
58 lines
1.2 KiB
58 lines
1.2 KiB
|
1 day ago
|
#include <fmt/core.h>
|
||
|
|
#include <deque>
|
||
|
|
#include <string>
|
||
|
|
#include <fuc2/testing.hpp>
|
||
|
|
#define SOL_ALL_SAFETIES_ON 1
|
||
|
|
#include <sol/sol.hpp>
|
||
|
|
#include "stats.hpp"
|
||
|
|
|
||
|
|
using namespace fuc2;
|
||
|
|
|
||
|
|
namespace soa_tests {
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
struct SOAStyle {
|
||
|
|
std::vector<std::string> name;
|
||
|
|
std::vector<int> hp;
|
||
|
|
std::vector<int> damage;
|
||
|
|
std::vector<bool> dead;
|
||
|
|
size_t count=0;
|
||
|
|
};
|
||
|
|
|
||
|
|
void test_soa_basics() {
|
||
|
|
SOAStyle world;
|
||
|
|
|
||
|
|
for(int i = 0; i < 10; i++) {
|
||
|
|
auto name = fmt::format("Fighter-{}", i);
|
||
|
|
world.name.emplace_back(name);
|
||
|
|
world.hp.emplace_back(i+10);
|
||
|
|
world.damage.emplace_back(i+1);
|
||
|
|
world.dead.emplace_back(false);
|
||
|
|
world.count++;
|
||
|
|
}
|
||
|
|
|
||
|
|
sol::state lua;
|
||
|
|
lua.open_libraries(sol::lib::base);
|
||
|
|
lua.new_usertype<SOAStyle>("SOAStyle",
|
||
|
|
"name", &SOAStyle::name,
|
||
|
|
"hp", &SOAStyle::hp,
|
||
|
|
"damage", &SOAStyle::damage,
|
||
|
|
"dead", &SOAStyle::dead,
|
||
|
|
"count", &SOAStyle::count);
|
||
|
|
|
||
|
|
lua.script_file("tests/soa_tests.lua");
|
||
|
|
sol::function handler = lua["handler"];
|
||
|
|
|
||
|
|
handler(world);
|
||
|
|
}
|
||
|
|
|
||
|
|
fuc2::Set TESTS{
|
||
|
|
.name="soa",
|
||
|
|
.options={ .fail_fast=false },
|
||
|
|
.tests={
|
||
|
|
TEST(test_soa_basics),
|
||
|
|
}
|
||
|
|
};
|
||
|
|
}
|