Fixes memory leak in unit tests
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2021-08-29 16:28:21 +02:00
parent 2123a01151
commit 75d6100689
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 17 additions and 16 deletions

View File

@ -8,29 +8,30 @@ using namespace PkmnLib::Battling;
TEST_CASE("Correct rounding for damage.") {
auto lib = TestLibrary::GetLibrary();
auto mon1 = CreatePokemon(lib, "testCharizard"_cnc, 100)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.WithEffortValues(0, 0, 0, 0, 0, 0)
.WithNature("neutralNature"_cnc)
.WithGender(CreatureLib::Library::Gender::Male)
.IsAllowedExperienceGain(false)
.Build();
auto mon2 = CreatePokemon(lib, "testVenusaur"_cnc, 100)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.WithEffortValues(0, 0, 0, 0, 0, 0)
.WithNature("neutralNature"_cnc)
.WithGender(CreatureLib::Library::Gender::Male)
.IsAllowedExperienceGain(false)
.Build();
auto mon1 = ArbUt::ScopedPtr(CreatePokemon(lib, "testCharizard"_cnc, 100)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.WithEffortValues(0, 0, 0, 0, 0, 0)
.WithNature("neutralNature"_cnc)
.WithGender(CreatureLib::Library::Gender::Male)
.IsAllowedExperienceGain(false)
.Build());
auto mon2 = ArbUt::ScopedPtr(CreatePokemon(lib, "testVenusaur"_cnc, 100)
.WithIndividualValues(31, 31, 31, 31, 31, 31)
.WithEffortValues(0, 0, 0, 0, 0, 0)
.WithNature("neutralNature"_cnc)
.WithGender(CreatureLib::Library::Gender::Male)
.IsAllowedExperienceGain(false)
.Build());
auto move = PkmnLib::Library::MoveData("test", 0, PkmnLib::Library::MoveCategory::Physical, 55, 100, 10,
CreatureLib::Library::AttackTarget::All, 0, nullptr, {});
auto attack = PkmnLib::Battling::LearnedMove(&move, CreatureLib::Battling::AttackLearnMethod::Unknown);
auto executingAttack = CreatureLib::Battling::ExecutingAttack({mon2}, 1, mon1, &attack, &move, nullptr);
auto executingAttack =
CreatureLib::Battling::ExecutingAttack({mon2.GetValue()}, 1, mon1.GetValue(), &attack, &move, nullptr);
auto hit = executingAttack.GetHitData(mon2, 0);
auto hit = executingAttack.GetHitData(mon2.GetValue(), 0);
hit.SetBasePower(55);
hit.SetEffectiveness(2.0f);
hit.SetCritical(0);