Switch over to doctest.
This commit is contained in:
parent
761714f2f5
commit
d44ba77795
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,11 @@
|
||||||
#include "../../extern/catch.hpp"
|
#include "../../extern/doctest.hpp"
|
||||||
#include "../Library.hpp"
|
#include "../Library.hpp"
|
||||||
|
|
||||||
#define CHECK_NATURE_NEUTRAL(name) \
|
#define CHECK_NATURE_NEUTRAL(name) \
|
||||||
{ \
|
{ \
|
||||||
auto nature = natureLib->GetNatureByName(ArbUt::StringView(#name)); \
|
auto nature = natureLib->GetNatureByName(ArbUt::StringView(#name)); \
|
||||||
CHECK(nature->GetIncreaseModifier() == Approx(1.0)); \
|
CHECK(nature->GetIncreaseModifier() == doctest::Approx(1.0)); \
|
||||||
CHECK(nature->GetDecreaseModifier() == Approx(1.0)); \
|
CHECK(nature->GetDecreaseModifier() == doctest::Approx(1.0)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_NATURE(name, increasedStat, decreasedStat) \
|
#define CHECK_NATURE(name, increasedStat, decreasedStat) \
|
||||||
|
@ -13,11 +13,11 @@
|
||||||
auto nature = natureLib->GetNatureByName(ArbUt::StringView(#name)); \
|
auto nature = natureLib->GetNatureByName(ArbUt::StringView(#name)); \
|
||||||
CHECK(nature->GetIncreasedStat() == PkmnLib::Library::Statistic::increasedStat); \
|
CHECK(nature->GetIncreasedStat() == PkmnLib::Library::Statistic::increasedStat); \
|
||||||
CHECK(nature->GetDecreasedStat() == PkmnLib::Library::Statistic::decreasedStat); \
|
CHECK(nature->GetDecreasedStat() == PkmnLib::Library::Statistic::decreasedStat); \
|
||||||
CHECK(nature->GetIncreaseModifier() == Approx(1.1)); \
|
CHECK(nature->GetIncreaseModifier() == doctest::Approx(1.1)); \
|
||||||
CHECK(nature->GetDecreaseModifier() == Approx(0.9)); \
|
CHECK(nature->GetDecreaseModifier() == doctest::Approx(0.9)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Nature Checks", "[natures]") {
|
TEST_CASE("Nature Checks") {
|
||||||
auto natureLib = Library::GetStaticLib()->GetNatureLibrary();
|
auto natureLib = Library::GetStaticLib()->GetNatureLibrary();
|
||||||
CHECK_NATURE_NEUTRAL(Hardy);
|
CHECK_NATURE_NEUTRAL(Hardy);
|
||||||
CHECK_NATURE(Lonely, PhysicalAttack, PhysicalDefense);
|
CHECK_NATURE(Lonely, PhysicalAttack, PhysicalDefense);
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
#include "../../extern/catch.hpp"
|
#include "../../extern/doctest.hpp"
|
||||||
#include "../Library.hpp"
|
#include "../Library.hpp"
|
||||||
|
|
||||||
#define ENSURE_SPECIES_EXISTS(species) \
|
#define ENSURE_SPECIES_EXISTS(species) \
|
||||||
CHECK(library->GetSpeciesLibrary()->Get(ArbUt::StringView(#species))->GetName() == #species);
|
CHECK(library->GetSpeciesLibrary()->Get(ArbUt::StringView(#species))->GetName() == #species);
|
||||||
|
|
||||||
TEST_CASE("Species - Ensure relevant species exist", "[species]") {
|
TEST_CASE("Species - Ensure relevant species exist") {
|
||||||
auto library = Library::GetLibrary();
|
auto library = Library::GetLibrary();
|
||||||
ENSURE_SPECIES_EXISTS(charizard);
|
ENSURE_SPECIES_EXISTS(charizard);
|
||||||
ENSURE_SPECIES_EXISTS(pikachu);
|
ENSURE_SPECIES_EXISTS(pikachu);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Species - Ensure species count is valid", "[species]") {
|
TEST_CASE("Species - Ensure species count is valid") {
|
||||||
auto library = Library::GetLibrary();
|
auto library = Library::GetLibrary();
|
||||||
CHECK(library->GetSpeciesLibrary()->GetCount() == 802);
|
CHECK(library->GetSpeciesLibrary()->GetCount() == 802);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Species - Ensure each species has a default forme", "[species]") {
|
TEST_CASE("Species - Ensure each species has a default forme") {
|
||||||
auto library = Library::GetLibrary();
|
auto library = Library::GetLibrary();
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
auto& lib = library->GetSpeciesLibrary();
|
auto& lib = library->GetSpeciesLibrary();
|
||||||
|
@ -27,7 +27,7 @@ TEST_CASE("Species - Ensure each species has a default forme", "[species]") {
|
||||||
REQUIRE(i == 802);
|
REQUIRE(i == 802);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Species - Ensure each forme has abilities", "[species]") {
|
TEST_CASE("Species - Ensure each forme has abilities") {
|
||||||
auto library = Library::GetLibrary();
|
auto library = Library::GetLibrary();
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
auto& lib = library->GetSpeciesLibrary();
|
auto& lib = library->GetSpeciesLibrary();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include "../../extern/catch.hpp"
|
#include "../../extern/doctest.hpp"
|
||||||
#include "../Library.hpp"
|
#include "../Library.hpp"
|
||||||
|
|
||||||
#define CHECK_EFFECTIVENESS(attack, defense, expected) \
|
#define CHECK_EFFECTIVENESS(attack, defense, expected) \
|
||||||
CHECK(typeLib->GetSingleEffectiveness(typeLib->GetTypeId(ArbUt::StringView(#attack)), \
|
CHECK(typeLib->GetSingleEffectiveness(typeLib->GetTypeId(ArbUt::StringView(#attack)), \
|
||||||
typeLib->GetTypeId(ArbUt::StringView(#defense))) == expected);
|
typeLib->GetTypeId(ArbUt::StringView(#defense))) == expected);
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Normal Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Normal Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Normal, Normal, 1);
|
CHECK_EFFECTIVENESS(Normal, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Normal, Fighting, 1);
|
CHECK_EFFECTIVENESS(Normal, Fighting, 1);
|
||||||
|
@ -27,7 +27,7 @@ TEST_CASE("Type Effectiveness - Normal Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Normal, Fairy, 1);
|
CHECK_EFFECTIVENESS(Normal, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Fighting Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Fighting Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Fighting, Normal, 2);
|
CHECK_EFFECTIVENESS(Fighting, Normal, 2);
|
||||||
CHECK_EFFECTIVENESS(Fighting, Fighting, 1);
|
CHECK_EFFECTIVENESS(Fighting, Fighting, 1);
|
||||||
|
@ -49,7 +49,7 @@ TEST_CASE("Type Effectiveness - Fighting Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Fighting, Fairy, 0.5);
|
CHECK_EFFECTIVENESS(Fighting, Fairy, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Flying Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Flying Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Flying, Normal, 1);
|
CHECK_EFFECTIVENESS(Flying, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Flying, Fighting, 2);
|
CHECK_EFFECTIVENESS(Flying, Fighting, 2);
|
||||||
|
@ -71,7 +71,7 @@ TEST_CASE("Type Effectiveness - Flying Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Flying, Fairy, 1);
|
CHECK_EFFECTIVENESS(Flying, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Poison Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Poison Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Poison, Normal, 1);
|
CHECK_EFFECTIVENESS(Poison, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Poison, Fighting, 1);
|
CHECK_EFFECTIVENESS(Poison, Fighting, 1);
|
||||||
|
@ -93,7 +93,7 @@ TEST_CASE("Type Effectiveness - Poison Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Poison, Fairy, 2);
|
CHECK_EFFECTIVENESS(Poison, Fairy, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Ground Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Ground Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Ground, Normal, 1);
|
CHECK_EFFECTIVENESS(Ground, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Ground, Fighting, 1);
|
CHECK_EFFECTIVENESS(Ground, Fighting, 1);
|
||||||
|
@ -115,7 +115,7 @@ TEST_CASE("Type Effectiveness - Ground Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Ground, Fairy, 1);
|
CHECK_EFFECTIVENESS(Ground, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Rock Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Rock Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Rock, Normal, 1);
|
CHECK_EFFECTIVENESS(Rock, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Rock, Fighting, 0.5);
|
CHECK_EFFECTIVENESS(Rock, Fighting, 0.5);
|
||||||
|
@ -137,7 +137,7 @@ TEST_CASE("Type Effectiveness - Rock Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Rock, Fairy, 1);
|
CHECK_EFFECTIVENESS(Rock, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Bug Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Bug Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Bug, Normal, 1);
|
CHECK_EFFECTIVENESS(Bug, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Bug, Fighting, 0.5);
|
CHECK_EFFECTIVENESS(Bug, Fighting, 0.5);
|
||||||
|
@ -159,7 +159,7 @@ TEST_CASE("Type Effectiveness - Bug Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Bug, Fairy, 0.5);
|
CHECK_EFFECTIVENESS(Bug, Fairy, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Ghost Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Ghost Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Ghost, Normal, 0);
|
CHECK_EFFECTIVENESS(Ghost, Normal, 0);
|
||||||
CHECK_EFFECTIVENESS(Ghost, Fighting, 1);
|
CHECK_EFFECTIVENESS(Ghost, Fighting, 1);
|
||||||
|
@ -181,7 +181,7 @@ TEST_CASE("Type Effectiveness - Ghost Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Ghost, Fairy, 1);
|
CHECK_EFFECTIVENESS(Ghost, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Steel Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Steel Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Steel, Normal, 1);
|
CHECK_EFFECTIVENESS(Steel, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Steel, Fighting, 1);
|
CHECK_EFFECTIVENESS(Steel, Fighting, 1);
|
||||||
|
@ -203,7 +203,7 @@ TEST_CASE("Type Effectiveness - Steel Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Steel, Fairy, 2);
|
CHECK_EFFECTIVENESS(Steel, Fairy, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Fire Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Fire Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Fire, Normal, 1);
|
CHECK_EFFECTIVENESS(Fire, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Fire, Fighting, 1);
|
CHECK_EFFECTIVENESS(Fire, Fighting, 1);
|
||||||
|
@ -225,7 +225,7 @@ TEST_CASE("Type Effectiveness - Fire Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Fire, Fairy, 1);
|
CHECK_EFFECTIVENESS(Fire, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Water Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Water Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Water, Normal, 1);
|
CHECK_EFFECTIVENESS(Water, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Water, Fighting, 1);
|
CHECK_EFFECTIVENESS(Water, Fighting, 1);
|
||||||
|
@ -247,7 +247,7 @@ TEST_CASE("Type Effectiveness - Water Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Water, Fairy, 1);
|
CHECK_EFFECTIVENESS(Water, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Grass Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Grass Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Grass, Normal, 1);
|
CHECK_EFFECTIVENESS(Grass, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Grass, Fighting, 1);
|
CHECK_EFFECTIVENESS(Grass, Fighting, 1);
|
||||||
|
@ -269,7 +269,7 @@ TEST_CASE("Type Effectiveness - Grass Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Grass, Fairy, 1);
|
CHECK_EFFECTIVENESS(Grass, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Electric Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Electric Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Electric, Normal, 1);
|
CHECK_EFFECTIVENESS(Electric, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Electric, Fighting, 1);
|
CHECK_EFFECTIVENESS(Electric, Fighting, 1);
|
||||||
|
@ -291,7 +291,7 @@ TEST_CASE("Type Effectiveness - Electric Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Electric, Fairy, 1);
|
CHECK_EFFECTIVENESS(Electric, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Psychic Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Psychic Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Psychic, Normal, 1);
|
CHECK_EFFECTIVENESS(Psychic, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Psychic, Fighting, 2);
|
CHECK_EFFECTIVENESS(Psychic, Fighting, 2);
|
||||||
|
@ -313,7 +313,7 @@ TEST_CASE("Type Effectiveness - Psychic Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Psychic, Fairy, 1);
|
CHECK_EFFECTIVENESS(Psychic, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Ice Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Ice Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Ice, Normal, 1);
|
CHECK_EFFECTIVENESS(Ice, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Ice, Fighting, 1);
|
CHECK_EFFECTIVENESS(Ice, Fighting, 1);
|
||||||
|
@ -335,7 +335,7 @@ TEST_CASE("Type Effectiveness - Ice Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Ice, Fairy, 1);
|
CHECK_EFFECTIVENESS(Ice, Fairy, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Dragon Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Dragon Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Dragon, Normal, 1);
|
CHECK_EFFECTIVENESS(Dragon, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Dragon, Fighting, 1);
|
CHECK_EFFECTIVENESS(Dragon, Fighting, 1);
|
||||||
|
@ -357,7 +357,7 @@ TEST_CASE("Type Effectiveness - Dragon Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Dragon, Fairy, 0);
|
CHECK_EFFECTIVENESS(Dragon, Fairy, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Dark Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Dark Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Dark, Normal, 1);
|
CHECK_EFFECTIVENESS(Dark, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Dark, Fighting, 0.5);
|
CHECK_EFFECTIVENESS(Dark, Fighting, 0.5);
|
||||||
|
@ -379,7 +379,7 @@ TEST_CASE("Type Effectiveness - Dark Attacking", "[type]") {
|
||||||
CHECK_EFFECTIVENESS(Dark, Fairy, 0.5);
|
CHECK_EFFECTIVENESS(Dark, Fairy, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Type Effectiveness - Fairy Attacking", "[type]") {
|
TEST_CASE("Type Effectiveness - Fairy Attacking") {
|
||||||
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
|
||||||
CHECK_EFFECTIVENESS(Fairy, Normal, 1);
|
CHECK_EFFECTIVENESS(Fairy, Normal, 1);
|
||||||
CHECK_EFFECTIVENESS(Fairy, Fighting, 2);
|
CHECK_EFFECTIVENESS(Fairy, Fighting, 2);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <PkmnLib/Battling/Battle/Battle.hpp>
|
#include <PkmnLib/Battling/Battle/Battle.hpp>
|
||||||
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
||||||
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptScript.hpp>
|
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptScript.hpp>
|
||||||
#include "../../../extern/catch.hpp"
|
#include "../../../extern/doctest.hpp"
|
||||||
#include "../../Library.hpp"
|
#include "../../Library.hpp"
|
||||||
|
|
||||||
#define SETUP_MOVE_TEST(move) \
|
#define SETUP_MOVE_TEST(move) \
|
||||||
|
@ -43,7 +43,7 @@
|
||||||
delete battle;
|
delete battle;
|
||||||
|
|
||||||
#define ON_MOVE_EFFECT_TRIGGER(move, onAfterCheck) \
|
#define ON_MOVE_EFFECT_TRIGGER(move, onAfterCheck) \
|
||||||
TEST_CASE(#move " - On Effect Trigger", "[moves]") { \
|
TEST_CASE(#move " - On Effect Trigger") { \
|
||||||
SETUP_MOVE_TEST(move) \
|
SETUP_MOVE_TEST(move) \
|
||||||
\
|
\
|
||||||
battle->AddVolatileScript("TriggerEffectChance"_cnc); \
|
battle->AddVolatileScript("TriggerEffectChance"_cnc); \
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ON_MOVE_EFFECT_NO_TRIGGER(move, onAfterCheck) \
|
#define ON_MOVE_EFFECT_NO_TRIGGER(move, onAfterCheck) \
|
||||||
TEST_CASE(#move " - On Effect No Trigger", "[moves]") { \
|
TEST_CASE(#move " - On Effect No Trigger") { \
|
||||||
SETUP_MOVE_TEST(move) \
|
SETUP_MOVE_TEST(move) \
|
||||||
\
|
\
|
||||||
battle->AddVolatileScript("BlockEffectChance"_cnc); \
|
battle->AddVolatileScript("BlockEffectChance"_cnc); \
|
||||||
|
@ -65,7 +65,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MOVE_EFFECT_CHANCE(move, chance) \
|
#define MOVE_EFFECT_CHANCE(move, chance) \
|
||||||
TEST_CASE(#move " - Effect Chance = " #chance, "[moves]") { \
|
TEST_CASE(#move " - Effect Chance = " #chance) { \
|
||||||
auto library = Library::GetLibrary(); \
|
auto library = Library::GetLibrary(); \
|
||||||
auto move = library->GetMoveLibrary()->Get(ArbUt::StringView(#move)); \
|
auto move = library->GetMoveLibrary()->Get(ArbUt::StringView(#move)); \
|
||||||
REQUIRE(move->HasSecondaryEffect()); \
|
REQUIRE(move->HasSecondaryEffect()); \
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
MOVE_EFFECT_CHANCE(moveName, chance)
|
MOVE_EFFECT_CHANCE(moveName, chance)
|
||||||
|
|
||||||
#define INCREASED_CRITICAL_RATE(moveName, expectedStage) \
|
#define INCREASED_CRITICAL_RATE(moveName, expectedStage) \
|
||||||
TEST_CASE(#moveName " - Increased critical ratio", "[moves]") { \
|
TEST_CASE(#moveName " - Increased critical ratio") { \
|
||||||
SETUP_MOVE_TEST(moveName) \
|
SETUP_MOVE_TEST(moveName) \
|
||||||
\
|
\
|
||||||
auto pkmnScript = dynamic_cast<PkmnLib::Battling::PkmnScript*>(script); \
|
auto pkmnScript = dynamic_cast<PkmnLib::Battling::PkmnScript*>(script); \
|
||||||
|
@ -89,7 +89,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHANGE_USER_STAT_MOVE(moveName, stat, stage, function) \
|
#define CHANGE_USER_STAT_MOVE(moveName, stat, stage, function) \
|
||||||
TEST_CASE(#moveName " - Change " #stat " by " #stage, "[moves]") { \
|
TEST_CASE(#moveName " - Change " #stat " by " #stage) { \
|
||||||
SETUP_MOVE_TEST(moveName) \
|
SETUP_MOVE_TEST(moveName) \
|
||||||
\
|
\
|
||||||
CHECK(userMon->GetStatBoost(PkmnLib::Library::Statistic::stat) == 0); \
|
CHECK(userMon->GetStatBoost(PkmnLib::Library::Statistic::stat) == 0); \
|
||||||
|
@ -100,7 +100,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHANGE_TARGET_STAT_MOVE(moveName, stat, stage, function) \
|
#define CHANGE_TARGET_STAT_MOVE(moveName, stat, stage, function) \
|
||||||
TEST_CASE(#moveName " - Change " #stat " by " #stage, "[moves]") { \
|
TEST_CASE(#moveName " - Change " #stat " by " #stage) { \
|
||||||
SETUP_MOVE_TEST(moveName) \
|
SETUP_MOVE_TEST(moveName) \
|
||||||
\
|
\
|
||||||
CHECK(targetMon->GetStatBoost(PkmnLib::Library::Statistic::stat) == 0); \
|
CHECK(targetMon->GetStatBoost(PkmnLib::Library::Statistic::stat) == 0); \
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
||||||
#include <PkmnLib/Battling/Battle/Battle.hpp>
|
#include <PkmnLib/Battling/Battle/Battle.hpp>
|
||||||
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
||||||
#include "../../../../extern/catch.hpp"
|
#include "../../../../extern/doctest.hpp"
|
||||||
#include "../../Macros/MoveMacros.hpp"
|
#include "../../Macros/MoveMacros.hpp"
|
||||||
|
|
||||||
TEST_CASE("Absorb - Heals on use", "[moves]") {
|
TEST_CASE("Absorb - Heals on use") {
|
||||||
SETUP_MOVE_TEST(Absorb)
|
SETUP_MOVE_TEST(Absorb)
|
||||||
|
|
||||||
userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);
|
userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);
|
||||||
|
@ -15,7 +15,7 @@ TEST_CASE("Absorb - Heals on use", "[moves]") {
|
||||||
CLEANUP_MOVE_TEST
|
CLEANUP_MOVE_TEST
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Absorb - Heals more with big root", "[moves]") {
|
TEST_CASE("Absorb - Heals more with big root") {
|
||||||
SETUP_MOVE_TEST(Absorb)
|
SETUP_MOVE_TEST(Absorb)
|
||||||
|
|
||||||
userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);
|
userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "../../Macros/MoveMacros.hpp"
|
#include "../../Macros/MoveMacros.hpp"
|
||||||
using Stats = PkmnLib::Library::Statistic;
|
using Stats = PkmnLib::Library::Statistic;
|
||||||
|
|
||||||
TEST_CASE("Acrobatics - doubles base power when no held item", "[moves]") {
|
TEST_CASE("Acrobatics - doubles base power when no held item") {
|
||||||
SETUP_MOVE_TEST(Acrobatics)
|
SETUP_MOVE_TEST(Acrobatics)
|
||||||
|
|
||||||
uint8_t basePower = 40;
|
uint8_t basePower = 40;
|
||||||
|
@ -11,7 +11,7 @@ TEST_CASE("Acrobatics - doubles base power when no held item", "[moves]") {
|
||||||
CLEANUP_MOVE_TEST
|
CLEANUP_MOVE_TEST
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Acrobatics - doesn't overflow", "[moves]") {
|
TEST_CASE("Acrobatics - doesn't overflow") {
|
||||||
SETUP_MOVE_TEST(Acrobatics)
|
SETUP_MOVE_TEST(Acrobatics)
|
||||||
|
|
||||||
uint8_t basePower = 200;
|
uint8_t basePower = 200;
|
||||||
|
@ -21,7 +21,7 @@ TEST_CASE("Acrobatics - doesn't overflow", "[moves]") {
|
||||||
CLEANUP_MOVE_TEST
|
CLEANUP_MOVE_TEST
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Acrobatics - doesn't double base power when no held item", "[moves]") {
|
TEST_CASE("Acrobatics - doesn't double base power when no held item") {
|
||||||
SETUP_MOVE_TEST(Acrobatics)
|
SETUP_MOVE_TEST(Acrobatics)
|
||||||
|
|
||||||
userMon->SetHeldItem("poke_ball"_cnc.GetHash());
|
userMon->SetHeldItem("poke_ball"_cnc.GetHash());
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
|
||||||
#include <PkmnLib/Battling/Battle/Battle.hpp>
|
#include <PkmnLib/Battling/Battle/Battle.hpp>
|
||||||
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
||||||
#include "../../../../extern/catch.hpp"
|
#include "../../../../extern/doctest.hpp"
|
||||||
#include "../../Macros/MoveMacros.hpp"
|
#include "../../Macros/MoveMacros.hpp"
|
||||||
|
|
||||||
TEST_CASE("Acupressure - increases random stat by 2", "[moves]") {
|
TEST_CASE("Acupressure - increases random stat by 2") {
|
||||||
SETUP_MOVE_TEST(Acupressure)
|
SETUP_MOVE_TEST(Acupressure)
|
||||||
|
|
||||||
script->OnSecondaryEffect(executingMove, targetMon, 0);
|
script->OnSecondaryEffect(executingMove, targetMon, 0);
|
||||||
|
@ -29,7 +29,7 @@ TEST_CASE("Acupressure - increases random stat by 2", "[moves]") {
|
||||||
CLEANUP_MOVE_TEST
|
CLEANUP_MOVE_TEST
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("Acupressure - fails if user is target", "[moves]") {
|
TEST_CASE("Acupressure - fails if user is target") {
|
||||||
SETUP_MOVE_TEST(Acupressure)
|
SETUP_MOVE_TEST(Acupressure)
|
||||||
|
|
||||||
script->OnSecondaryEffect(executingMove, userMon, 0);
|
script->OnSecondaryEffect(executingMove, userMon, 0);
|
||||||
|
|
|
@ -2,10 +2,10 @@
|
||||||
#include <CreatureLib/Battling/TurnChoices/AttackTurnChoice.hpp>
|
#include <CreatureLib/Battling/TurnChoices/AttackTurnChoice.hpp>
|
||||||
#include <PkmnLib/Battling/Battle/Battle.hpp>
|
#include <PkmnLib/Battling/Battle/Battle.hpp>
|
||||||
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
|
||||||
#include "../../../extern/catch.hpp"
|
#include "../../../extern/doctest.hpp"
|
||||||
#include "../Macros/MoveMacros.hpp"
|
#include "../Macros/MoveMacros.hpp"
|
||||||
|
|
||||||
TEST_CASE("Struggle - Damages by 1/4th of users max health", "[moves]") {
|
TEST_CASE("Struggle - Damages by 1/4th of users max health") {
|
||||||
auto library = Library::GetLibrary();
|
auto library = Library::GetLibrary();
|
||||||
auto userMon = PkmnLib::Battling::CreatePokemon(library, "charizard"_cnc, 50).Build();
|
auto userMon = PkmnLib::Battling::CreatePokemon(library, "charizard"_cnc, 50).Build();
|
||||||
auto targetMon = PkmnLib::Battling::CreatePokemon(library, "venusaur"_cnc, 50).Build();
|
auto targetMon = PkmnLib::Battling::CreatePokemon(library, "venusaur"_cnc, 50).Build();
|
||||||
|
@ -22,8 +22,8 @@ TEST_CASE("Struggle - Damages by 1/4th of users max health", "[moves]") {
|
||||||
targetMon->SetBattleData(battle, battle->GetSides()[1]);
|
targetMon->SetBattleData(battle, battle->GetSides()[1]);
|
||||||
|
|
||||||
auto& script = ((CreatureLib::Battling::AttackTurnChoice*)library->GetMiscLibrary()->ReplacementAttack(
|
auto& script = ((CreatureLib::Battling::AttackTurnChoice*)library->GetMiscLibrary()->ReplacementAttack(
|
||||||
userMon, CreatureLib::Battling::CreatureIndex(1, 0)))
|
userMon, CreatureLib::Battling::CreatureIndex(1, 0)))
|
||||||
->GetAttackScript();
|
->GetAttackScript();
|
||||||
REQUIRE(script != nullptr);
|
REQUIRE(script != nullptr);
|
||||||
|
|
||||||
auto choice = (CreatureLib::Battling::AttackTurnChoice*)library->GetMiscLibrary()->ReplacementAttack(
|
auto choice = (CreatureLib::Battling::AttackTurnChoice*)library->GetMiscLibrary()->ReplacementAttack(
|
||||||
|
|
88
src/main.cpp
88
src/main.cpp
|
@ -1,7 +1,8 @@
|
||||||
#define CATCH_CONFIG_RUNNER
|
|
||||||
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptResolver.hpp>
|
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptResolver.hpp>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include "../extern/catch.hpp"
|
#include "../extern/args.hpp"
|
||||||
|
#define DOCTEST_CONFIG_IMPLEMENT
|
||||||
|
#include "../extern/doctest.hpp"
|
||||||
#include "BuildData/BuildItems.hpp"
|
#include "BuildData/BuildItems.hpp"
|
||||||
#include "BuildData/BuildMoves.hpp"
|
#include "BuildData/BuildMoves.hpp"
|
||||||
#include "BuildData/BuildNatures.hpp"
|
#include "BuildData/BuildNatures.hpp"
|
||||||
|
@ -12,36 +13,11 @@
|
||||||
|
|
||||||
static const char* ScriptsPath = nullptr;
|
static const char* ScriptsPath = nullptr;
|
||||||
|
|
||||||
// static constexpr const char* GetCategoryPath(CreatureLib::Battling::ScriptResolver::ScriptCategory category){
|
|
||||||
// switch (category){
|
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Attack: return "Moves";
|
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Talent: return "Abilities";
|
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Status: return "Status";
|
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Creature: return "Pokemon";
|
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Battle: return "Battle";
|
|
||||||
// case CreatureLib::Battling::ScriptResolver::ScriptCategory::Side: return "Side";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// static const char* LoadFunc(CreatureLib::Battling::ScriptResolver::ScriptCategory category, const char* scriptName){
|
|
||||||
// auto categoryStr = GetCategoryPath(category);
|
|
||||||
// char fullPath[strlen(ScriptsPath) + 1 + strlen(categoryStr) + 1 + strlen(scriptName) + 3];
|
|
||||||
// strcpy(fullPath, ScriptsPath);
|
|
||||||
// strcat(fullPath, "/");
|
|
||||||
// strcat(fullPath, categoryStr);
|
|
||||||
// strcat(fullPath, "/");
|
|
||||||
// strcat(fullPath, scriptName);
|
|
||||||
// strcat(fullPath, ".as");
|
|
||||||
// std::ifstream in(fullPath);
|
|
||||||
// std::string contents((std::istreambuf_iterator<char>(in)), std::istreambuf_iterator<char>());
|
|
||||||
// char res[contents.size()];
|
|
||||||
// return strcpy(res, contents.c_str());
|
|
||||||
// }
|
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
Catch::Session session;
|
args::ArgumentParser parser("Gen 7 test set.", "");
|
||||||
|
args::HelpFlag help(parser, "help", "Display this help menu", {'h', "help"});
|
||||||
|
|
||||||
std::string workingDirectory = "";
|
std::string workingDirectory;
|
||||||
std::string typesFile = "Types.csv";
|
std::string typesFile = "Types.csv";
|
||||||
std::string naturesFile = "Natures.csv";
|
std::string naturesFile = "Natures.csv";
|
||||||
std::string pokemonFile = "Pokemon.json";
|
std::string pokemonFile = "Pokemon.json";
|
||||||
|
@ -50,23 +26,30 @@ int main(int argc, char* argv[]) {
|
||||||
std::string growthRatesFile = "GrowthRates.json";
|
std::string growthRatesFile = "GrowthRates.json";
|
||||||
std::string scriptsPath = "Scripts";
|
std::string scriptsPath = "Scripts";
|
||||||
|
|
||||||
using namespace Catch::clara;
|
args::HelpFlag helpFlag(parser, "help", "Display this help menu", {'h', "help"});
|
||||||
auto cli = session.cli() | Opt(workingDirectory, "Working Directory")["--workdir"]("Which work directory to use.") |
|
args::ValueFlag<std::string> workingDirFlag(parser, "Working Directory", "Which work directory to use.",
|
||||||
Opt(pokemonFile, "Species")["--species"]("Which species file to load.") |
|
{"workdir"});
|
||||||
Opt(typesFile, "Types")["--types"]("Which Types file to load.") |
|
args::ValueFlag<std::string> _(parser, "Reporters", "List of reporters to use (default is console)",
|
||||||
Opt(naturesFile, "Natures")["--natures"]("Which Natures file to load.") |
|
{'r', "reporters"});
|
||||||
Opt(moveFile, "Moves")["--moves"]("Which Moves file to load.") |
|
|
||||||
Opt(itemsFile, "Items")["--items"]("Which Items file to load.") |
|
|
||||||
Opt(growthRatesFile, "Growthrates")["--growthrates"]("Which Growthrates file to load.") |
|
|
||||||
Opt(scriptsPath, "Scripts")["--scripts"]("Which Scripts path to load scripts from.");
|
|
||||||
|
|
||||||
session.cli(cli);
|
try {
|
||||||
|
parser.ParseCLI(argc, argv);
|
||||||
int returnCode = session.applyCommandLine(argc, argv);
|
} catch (args::Help) {
|
||||||
if (returnCode != 0) // Indicates a command line error
|
std::cout << parser;
|
||||||
return returnCode;
|
|
||||||
if (session.config().showHelp())
|
|
||||||
return 0;
|
return 0;
|
||||||
|
} catch (args::ParseError e) {
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
std::cerr << parser;
|
||||||
|
return 1;
|
||||||
|
} catch (args::ValidationError e) {
|
||||||
|
std::cerr << e.what() << std::endl;
|
||||||
|
std::cerr << parser;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (workingDirFlag) {
|
||||||
|
workingDirectory = args::get(workingDirFlag);
|
||||||
|
}
|
||||||
|
|
||||||
if (!workingDirectory.empty()) {
|
if (!workingDirectory.empty()) {
|
||||||
chdir(workingDirectory.c_str());
|
chdir(workingDirectory.c_str());
|
||||||
|
@ -137,5 +120,16 @@ class SaveEffectChance : PkmnScript {
|
||||||
Library::SetStaticLib(staticLibrary);
|
Library::SetStaticLib(staticLibrary);
|
||||||
Library::SetLibrary(battleLib);
|
Library::SetLibrary(battleLib);
|
||||||
|
|
||||||
return session.run();
|
doctest::Context context;
|
||||||
}
|
context.applyCommandLine(argc, argv);
|
||||||
|
|
||||||
|
int res = context.run(); // run
|
||||||
|
|
||||||
|
if (context.shouldExit()) // important - query flags (and --exit) rely on the user doing this
|
||||||
|
return res; // propagate the result of the tests
|
||||||
|
|
||||||
|
int client_stuff_return_code = 0;
|
||||||
|
// your program - if the testing framework is integrated in your production code
|
||||||
|
|
||||||
|
return res + client_stuff_return_code; // the result from doctest is propagated here as well
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue