Reworks test suite, tweaks to Cmake config for Windows.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-12-07 13:45:44 +01:00
parent 8897f2282f
commit 0483e635ea
10 changed files with 90 additions and 68 deletions

View File

@@ -1,24 +1,35 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../src/Battling/Library/BattleLibrary.hpp"
#include "TestLibrary.hpp"
using namespace CreatureLib::Core;
using namespace CreatureLib::Library;
using namespace CreatureLib::Battling;
static BattleLibrary* __library = nullptr;
BattleLibrary* TestLibrary::_library = nullptr;
static SpeciesLibrary* BuildSpeciesLibrary() {
BattleLibrary *TestLibrary::Get() {
if (TestLibrary::_library == nullptr){
auto l = new DataLibrary(LibrarySettings(100, 4), BuildSpeciesLibrary(), BuildAttackLibrary(), BuildItemLibrary(),
BuildGrowthRateLibrary(), BuildTypeLibrary());
auto statCalc = new BattleStatCalculator();
auto battleLib = new BattleLibrary(l, statCalc, new DamageLibrary(), new CriticalLibrary(), new ScriptResolver());
TestLibrary::_library = battleLib;
}
return TestLibrary::_library;
}
SpeciesLibrary *TestLibrary::BuildSpeciesLibrary() {
auto l = new SpeciesLibrary();
l->LoadSpecies("testSpecies1",
new CreatureSpecies(
0, "testSpecies1",
new SpeciesVariant("default", 1, 1, 10, {0, 1}, StatisticSet<uint16_t>(10, 10, 10, 10, 10, 10),
{"testTalent"}, {"testSecretTalent"}, new LearnableAttacks(100)),
0.5f, "testGrowthRate", 5, 100));
0, "testSpecies1",
new SpeciesVariant("default", 1, 1, 10, {0, 1}, StatisticSet<uint16_t>(10, 10, 10, 10, 10, 10),
{"testTalent"}, {"testSecretTalent"}, new LearnableAttacks(100)),
0.5f, "testGrowthRate", 5, 100));
return l;
}
static AttackLibrary* BuildAttackLibrary() {
AttackLibrary *TestLibrary::BuildAttackLibrary() {
auto l = new AttackLibrary();
l->LoadAttack("standard", new AttackData("standard", "normal", AttackCategory::Physical, 20, 100, 30,
AttackTarget::AdjacentOpponent, 0, {}));
@@ -31,17 +42,17 @@ static AttackLibrary* BuildAttackLibrary() {
return l;
}
static ItemLibrary* BuildItemLibrary() {
ItemLibrary *TestLibrary::BuildItemLibrary() {
auto l = new ItemLibrary();
return l;
}
static GrowthRateLibrary* BuildGrowthRateLibrary() {
GrowthRateLibrary *TestLibrary::BuildGrowthRateLibrary() {
auto l = new GrowthRateLibrary();
return l;
}
static TypeLibrary* BuildTypeLibrary() {
TypeLibrary *TestLibrary::BuildTypeLibrary() {
auto l = new TypeLibrary();
l->RegisterType("testType1");
l->RegisterType("testType2");
@@ -49,18 +60,4 @@ static TypeLibrary* BuildTypeLibrary() {
return l;
}
static BattleLibrary* BuildLibrary() {
auto l = new DataLibrary(LibrarySettings(100, 4), BuildSpeciesLibrary(), BuildAttackLibrary(), BuildItemLibrary(),
BuildGrowthRateLibrary(), BuildTypeLibrary());
auto statCalc = new BattleStatCalculator();
auto battleLib = new BattleLibrary(l, statCalc, new DamageLibrary(), new CriticalLibrary(), new ScriptResolver());
return battleLib;
}
[[maybe_unused]] static BattleLibrary* GetLibrary() {
if (__library == nullptr) {
__library = BuildLibrary();
}
return __library;
}
#endif

View File

@@ -0,0 +1,24 @@
#ifndef CREATURELIB_TESTLIBRARY_HPP
#define CREATURELIB_TESTLIBRARY_HPP
#include "../../src/Battling/Library/BattleLibrary.hpp"
using namespace CreatureLib::Core;
using namespace CreatureLib::Library;
using namespace CreatureLib::Battling;
class TestLibrary{
static BattleLibrary* _library;
public:
static SpeciesLibrary* BuildSpeciesLibrary();
static AttackLibrary* BuildAttackLibrary();
static ItemLibrary* BuildItemLibrary();
static GrowthRateLibrary* BuildGrowthRateLibrary();
static TypeLibrary* BuildTypeLibrary();
static BattleLibrary* Get();
};
#endif //CREATURELIB_TESTLIBRARY_HPP