Switch over to doctest.

This commit is contained in:
Deukhoofd 2021-03-28 15:16:07 +02:00
parent 761714f2f5
commit d44ba77795
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
12 changed files with 10981 additions and 17712 deletions

4310
extern/args.hpp vendored Normal file

File diff suppressed because it is too large Load Diff

17615
extern/catch.hpp vendored

File diff suppressed because it is too large Load Diff

6580
extern/doctest.hpp vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,11 +1,11 @@
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../Library.hpp"
#define CHECK_NATURE_NEUTRAL(name) \
{ \
auto nature = natureLib->GetNatureByName(ArbUt::StringView(#name)); \
CHECK(nature->GetIncreaseModifier() == Approx(1.0)); \
CHECK(nature->GetDecreaseModifier() == Approx(1.0)); \
CHECK(nature->GetIncreaseModifier() == doctest::Approx(1.0)); \
CHECK(nature->GetDecreaseModifier() == doctest::Approx(1.0)); \
}
#define CHECK_NATURE(name, increasedStat, decreasedStat) \
@ -13,11 +13,11 @@
auto nature = natureLib->GetNatureByName(ArbUt::StringView(#name)); \
CHECK(nature->GetIncreasedStat() == PkmnLib::Library::Statistic::increasedStat); \
CHECK(nature->GetDecreasedStat() == PkmnLib::Library::Statistic::decreasedStat); \
CHECK(nature->GetIncreaseModifier() == Approx(1.1)); \
CHECK(nature->GetDecreaseModifier() == Approx(0.9)); \
CHECK(nature->GetIncreaseModifier() == doctest::Approx(1.1)); \
CHECK(nature->GetDecreaseModifier() == doctest::Approx(0.9)); \
}
TEST_CASE("Nature Checks", "[natures]") {
TEST_CASE("Nature Checks") {
auto natureLib = Library::GetStaticLib()->GetNatureLibrary();
CHECK_NATURE_NEUTRAL(Hardy);
CHECK_NATURE(Lonely, PhysicalAttack, PhysicalDefense);

View File

@ -1,21 +1,21 @@
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../Library.hpp"
#define ENSURE_SPECIES_EXISTS(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();
ENSURE_SPECIES_EXISTS(charizard);
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();
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();
size_t i = 0;
auto& lib = library->GetSpeciesLibrary();
@ -27,7 +27,7 @@ TEST_CASE("Species - Ensure each species has a default forme", "[species]") {
REQUIRE(i == 802);
}
TEST_CASE("Species - Ensure each forme has abilities", "[species]") {
TEST_CASE("Species - Ensure each forme has abilities") {
auto library = Library::GetLibrary();
size_t i = 0;
auto& lib = library->GetSpeciesLibrary();

View File

@ -1,11 +1,11 @@
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../Library.hpp"
#define CHECK_EFFECTIVENESS(attack, defense, expected) \
CHECK(typeLib->GetSingleEffectiveness(typeLib->GetTypeId(ArbUt::StringView(#attack)), \
typeLib->GetTypeId(ArbUt::StringView(#defense))) == expected);
TEST_CASE("Type Effectiveness - Normal Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Normal Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Normal, Normal, 1);
CHECK_EFFECTIVENESS(Normal, Fighting, 1);
@ -27,7 +27,7 @@ TEST_CASE("Type Effectiveness - Normal Attacking", "[type]") {
CHECK_EFFECTIVENESS(Normal, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Fighting Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Fighting Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Fighting, Normal, 2);
CHECK_EFFECTIVENESS(Fighting, Fighting, 1);
@ -49,7 +49,7 @@ TEST_CASE("Type Effectiveness - Fighting Attacking", "[type]") {
CHECK_EFFECTIVENESS(Fighting, Fairy, 0.5);
}
TEST_CASE("Type Effectiveness - Flying Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Flying Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Flying, Normal, 1);
CHECK_EFFECTIVENESS(Flying, Fighting, 2);
@ -71,7 +71,7 @@ TEST_CASE("Type Effectiveness - Flying Attacking", "[type]") {
CHECK_EFFECTIVENESS(Flying, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Poison Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Poison Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Poison, Normal, 1);
CHECK_EFFECTIVENESS(Poison, Fighting, 1);
@ -93,7 +93,7 @@ TEST_CASE("Type Effectiveness - Poison Attacking", "[type]") {
CHECK_EFFECTIVENESS(Poison, Fairy, 2);
}
TEST_CASE("Type Effectiveness - Ground Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Ground Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Ground, Normal, 1);
CHECK_EFFECTIVENESS(Ground, Fighting, 1);
@ -115,7 +115,7 @@ TEST_CASE("Type Effectiveness - Ground Attacking", "[type]") {
CHECK_EFFECTIVENESS(Ground, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Rock Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Rock Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Rock, Normal, 1);
CHECK_EFFECTIVENESS(Rock, Fighting, 0.5);
@ -137,7 +137,7 @@ TEST_CASE("Type Effectiveness - Rock Attacking", "[type]") {
CHECK_EFFECTIVENESS(Rock, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Bug Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Bug Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Bug, Normal, 1);
CHECK_EFFECTIVENESS(Bug, Fighting, 0.5);
@ -159,7 +159,7 @@ TEST_CASE("Type Effectiveness - Bug Attacking", "[type]") {
CHECK_EFFECTIVENESS(Bug, Fairy, 0.5);
}
TEST_CASE("Type Effectiveness - Ghost Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Ghost Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Ghost, Normal, 0);
CHECK_EFFECTIVENESS(Ghost, Fighting, 1);
@ -181,7 +181,7 @@ TEST_CASE("Type Effectiveness - Ghost Attacking", "[type]") {
CHECK_EFFECTIVENESS(Ghost, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Steel Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Steel Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Steel, Normal, 1);
CHECK_EFFECTIVENESS(Steel, Fighting, 1);
@ -203,7 +203,7 @@ TEST_CASE("Type Effectiveness - Steel Attacking", "[type]") {
CHECK_EFFECTIVENESS(Steel, Fairy, 2);
}
TEST_CASE("Type Effectiveness - Fire Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Fire Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Fire, Normal, 1);
CHECK_EFFECTIVENESS(Fire, Fighting, 1);
@ -225,7 +225,7 @@ TEST_CASE("Type Effectiveness - Fire Attacking", "[type]") {
CHECK_EFFECTIVENESS(Fire, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Water Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Water Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Water, Normal, 1);
CHECK_EFFECTIVENESS(Water, Fighting, 1);
@ -247,7 +247,7 @@ TEST_CASE("Type Effectiveness - Water Attacking", "[type]") {
CHECK_EFFECTIVENESS(Water, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Grass Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Grass Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Grass, Normal, 1);
CHECK_EFFECTIVENESS(Grass, Fighting, 1);
@ -269,7 +269,7 @@ TEST_CASE("Type Effectiveness - Grass Attacking", "[type]") {
CHECK_EFFECTIVENESS(Grass, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Electric Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Electric Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Electric, Normal, 1);
CHECK_EFFECTIVENESS(Electric, Fighting, 1);
@ -291,7 +291,7 @@ TEST_CASE("Type Effectiveness - Electric Attacking", "[type]") {
CHECK_EFFECTIVENESS(Electric, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Psychic Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Psychic Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Psychic, Normal, 1);
CHECK_EFFECTIVENESS(Psychic, Fighting, 2);
@ -313,7 +313,7 @@ TEST_CASE("Type Effectiveness - Psychic Attacking", "[type]") {
CHECK_EFFECTIVENESS(Psychic, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Ice Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Ice Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Ice, Normal, 1);
CHECK_EFFECTIVENESS(Ice, Fighting, 1);
@ -335,7 +335,7 @@ TEST_CASE("Type Effectiveness - Ice Attacking", "[type]") {
CHECK_EFFECTIVENESS(Ice, Fairy, 1);
}
TEST_CASE("Type Effectiveness - Dragon Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Dragon Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Dragon, Normal, 1);
CHECK_EFFECTIVENESS(Dragon, Fighting, 1);
@ -357,7 +357,7 @@ TEST_CASE("Type Effectiveness - Dragon Attacking", "[type]") {
CHECK_EFFECTIVENESS(Dragon, Fairy, 0);
}
TEST_CASE("Type Effectiveness - Dark Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Dark Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Dark, Normal, 1);
CHECK_EFFECTIVENESS(Dark, Fighting, 0.5);
@ -379,7 +379,7 @@ TEST_CASE("Type Effectiveness - Dark Attacking", "[type]") {
CHECK_EFFECTIVENESS(Dark, Fairy, 0.5);
}
TEST_CASE("Type Effectiveness - Fairy Attacking", "[type]") {
TEST_CASE("Type Effectiveness - Fairy Attacking") {
auto& typeLib = Library::GetStaticLib()->GetTypeLibrary();
CHECK_EFFECTIVENESS(Fairy, Normal, 1);
CHECK_EFFECTIVENESS(Fairy, Fighting, 2);

View File

@ -3,7 +3,7 @@
#include <PkmnLib/Battling/Battle/Battle.hpp>
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptScript.hpp>
#include "../../../extern/catch.hpp"
#include "../../../extern/doctest.hpp"
#include "../../Library.hpp"
#define SETUP_MOVE_TEST(move) \
@ -43,7 +43,7 @@
delete battle;
#define ON_MOVE_EFFECT_TRIGGER(move, onAfterCheck) \
TEST_CASE(#move " - On Effect Trigger", "[moves]") { \
TEST_CASE(#move " - On Effect Trigger") { \
SETUP_MOVE_TEST(move) \
\
battle->AddVolatileScript("TriggerEffectChance"_cnc); \
@ -54,7 +54,7 @@
}
#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) \
\
battle->AddVolatileScript("BlockEffectChance"_cnc); \
@ -65,7 +65,7 @@
}
#define MOVE_EFFECT_CHANCE(move, chance) \
TEST_CASE(#move " - Effect Chance = " #chance, "[moves]") { \
TEST_CASE(#move " - Effect Chance = " #chance) { \
auto library = Library::GetLibrary(); \
auto move = library->GetMoveLibrary()->Get(ArbUt::StringView(#move)); \
REQUIRE(move->HasSecondaryEffect()); \
@ -77,7 +77,7 @@
MOVE_EFFECT_CHANCE(moveName, chance)
#define INCREASED_CRITICAL_RATE(moveName, expectedStage) \
TEST_CASE(#moveName " - Increased critical ratio", "[moves]") { \
TEST_CASE(#moveName " - Increased critical ratio") { \
SETUP_MOVE_TEST(moveName) \
\
auto pkmnScript = dynamic_cast<PkmnLib::Battling::PkmnScript*>(script); \
@ -89,7 +89,7 @@
}
#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) \
\
CHECK(userMon->GetStatBoost(PkmnLib::Library::Statistic::stat) == 0); \
@ -100,7 +100,7 @@
}
#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) \
\
CHECK(targetMon->GetStatBoost(PkmnLib::Library::Statistic::stat) == 0); \

View File

@ -1,10 +1,10 @@
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
#include <PkmnLib/Battling/Battle/Battle.hpp>
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
#include "../../../../extern/catch.hpp"
#include "../../../../extern/doctest.hpp"
#include "../../Macros/MoveMacros.hpp"
TEST_CASE("Absorb - Heals on use", "[moves]") {
TEST_CASE("Absorb - Heals on use") {
SETUP_MOVE_TEST(Absorb)
userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);
@ -15,7 +15,7 @@ TEST_CASE("Absorb - Heals on use", "[moves]") {
CLEANUP_MOVE_TEST
}
TEST_CASE("Absorb - Heals more with big root", "[moves]") {
TEST_CASE("Absorb - Heals more with big root") {
SETUP_MOVE_TEST(Absorb)
userMon->Damage(50, CreatureLib::Battling::DamageSource::AttackDamage);

View File

@ -1,7 +1,7 @@
#include "../../Macros/MoveMacros.hpp"
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)
uint8_t basePower = 40;
@ -11,7 +11,7 @@ TEST_CASE("Acrobatics - doubles base power when no held item", "[moves]") {
CLEANUP_MOVE_TEST
}
TEST_CASE("Acrobatics - doesn't overflow", "[moves]") {
TEST_CASE("Acrobatics - doesn't overflow") {
SETUP_MOVE_TEST(Acrobatics)
uint8_t basePower = 200;
@ -21,7 +21,7 @@ TEST_CASE("Acrobatics - doesn't overflow", "[moves]") {
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)
userMon->SetHeldItem("poke_ball"_cnc.GetHash());

View File

@ -1,10 +1,10 @@
#include <CreatureLib/Battling/Models/ExecutingAttack.hpp>
#include <PkmnLib/Battling/Battle/Battle.hpp>
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
#include "../../../../extern/catch.hpp"
#include "../../../../extern/doctest.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)
script->OnSecondaryEffect(executingMove, targetMon, 0);
@ -29,7 +29,7 @@ TEST_CASE("Acupressure - increases random stat by 2", "[moves]") {
CLEANUP_MOVE_TEST
}
TEST_CASE("Acupressure - fails if user is target", "[moves]") {
TEST_CASE("Acupressure - fails if user is target") {
SETUP_MOVE_TEST(Acupressure)
script->OnSecondaryEffect(executingMove, userMon, 0);

View File

@ -2,10 +2,10 @@
#include <CreatureLib/Battling/TurnChoices/AttackTurnChoice.hpp>
#include <PkmnLib/Battling/Battle/Battle.hpp>
#include <PkmnLib/Battling/Pokemon/CreatePokemon.hpp>
#include "../../../extern/catch.hpp"
#include "../../../extern/doctest.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 userMon = PkmnLib::Battling::CreatePokemon(library, "charizard"_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]);
auto& script = ((CreatureLib::Battling::AttackTurnChoice*)library->GetMiscLibrary()->ReplacementAttack(
userMon, CreatureLib::Battling::CreatureIndex(1, 0)))
->GetAttackScript();
userMon, CreatureLib::Battling::CreatureIndex(1, 0)))
->GetAttackScript();
REQUIRE(script != nullptr);
auto choice = (CreatureLib::Battling::AttackTurnChoice*)library->GetMiscLibrary()->ReplacementAttack(

View File

@ -1,7 +1,8 @@
#define CATCH_CONFIG_RUNNER
#include <PkmnLib/ScriptResolving/AngelScript/AngelScriptResolver.hpp>
#include <filesystem>
#include "../extern/catch.hpp"
#include "../extern/args.hpp"
#define DOCTEST_CONFIG_IMPLEMENT
#include "../extern/doctest.hpp"
#include "BuildData/BuildItems.hpp"
#include "BuildData/BuildMoves.hpp"
#include "BuildData/BuildNatures.hpp"
@ -12,36 +13,11 @@
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[]) {
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 naturesFile = "Natures.csv";
std::string pokemonFile = "Pokemon.json";
@ -50,23 +26,30 @@ int main(int argc, char* argv[]) {
std::string growthRatesFile = "GrowthRates.json";
std::string scriptsPath = "Scripts";
using namespace Catch::clara;
auto cli = session.cli() | Opt(workingDirectory, "Working Directory")["--workdir"]("Which work directory to use.") |
Opt(pokemonFile, "Species")["--species"]("Which species file to load.") |
Opt(typesFile, "Types")["--types"]("Which Types file to load.") |
Opt(naturesFile, "Natures")["--natures"]("Which Natures file to load.") |
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.");
args::HelpFlag helpFlag(parser, "help", "Display this help menu", {'h', "help"});
args::ValueFlag<std::string> workingDirFlag(parser, "Working Directory", "Which work directory to use.",
{"workdir"});
args::ValueFlag<std::string> _(parser, "Reporters", "List of reporters to use (default is console)",
{'r', "reporters"});
session.cli(cli);
int returnCode = session.applyCommandLine(argc, argv);
if (returnCode != 0) // Indicates a command line error
return returnCode;
if (session.config().showHelp())
try {
parser.ParseCLI(argc, argv);
} catch (args::Help) {
std::cout << parser;
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()) {
chdir(workingDirectory.c_str());
@ -137,5 +120,16 @@ class SaveEffectChance : PkmnScript {
Library::SetStaticLib(staticLibrary);
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
}