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

This commit is contained in:
Deukhoofd 2019-10-31 13:33:32 +01:00
parent 163752a8ea
commit d7fee13002
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 24 additions and 8 deletions

View File

@ -27,8 +27,10 @@ TEST_CASE( "Turn ordering: Attack before pass", "[Battling]" ) {
TEST_CASE( "Turn ordering: High priority goes before no priority", "[Battling]" ) {
auto l = GetLibrary()->GetAttackLibrary();
auto choice1 = new AttackTurnChoice(nullptr, new LearnedAttack(l->GetAttack("standard"), AttackLearnMethod::Unknown));
auto choice2 = new AttackTurnChoice(nullptr, new LearnedAttack(l->GetAttack("highPriority"), AttackLearnMethod::Unknown));
auto a1 = new LearnedAttack(l->GetAttack("standard"), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->GetAttack("highPriority"), AttackLearnMethod::Unknown);
auto choice1 = new AttackTurnChoice(nullptr, a1);
auto choice2 = new AttackTurnChoice(nullptr, a2);
auto vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
auto rand = Core::Random();
TurnOrdering::OrderChoices(vec,rand);
@ -41,12 +43,16 @@ TEST_CASE( "Turn ordering: High priority goes before no priority", "[Battling]"
delete choice1;
delete choice2;
delete a1;
delete a2;
}
TEST_CASE( "Turn ordering: Higher priority goes before high priority", "[Battling]" ) {
auto l = GetLibrary()->GetAttackLibrary();
auto choice1 = new AttackTurnChoice(nullptr, new LearnedAttack(l->GetAttack("highPriority"), AttackLearnMethod::Unknown));
auto choice2 = new AttackTurnChoice(nullptr, new LearnedAttack(l->GetAttack("higherPriority"), AttackLearnMethod::Unknown));
auto a1 = new LearnedAttack(l->GetAttack("highPriority"), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->GetAttack("higherPriority"), AttackLearnMethod::Unknown);
auto choice1 = new AttackTurnChoice(nullptr, a1);
auto choice2 = new AttackTurnChoice(nullptr, a2);
auto vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
auto rand = Core::Random();
TurnOrdering::OrderChoices(vec,rand);
@ -59,12 +65,16 @@ TEST_CASE( "Turn ordering: Higher priority goes before high priority", "[Battlin
delete choice1;
delete choice2;
delete a1;
delete a2;
}
TEST_CASE( "Turn ordering: High priority goes before low priority", "[Battling]" ) {
auto l = GetLibrary()->GetAttackLibrary();
auto choice1 = new AttackTurnChoice(nullptr, new LearnedAttack(l->GetAttack("lowPriority"), AttackLearnMethod::Unknown));
auto choice2 = new AttackTurnChoice(nullptr, new LearnedAttack(l->GetAttack("higherPriority"), AttackLearnMethod::Unknown));
auto a1 = new LearnedAttack(l->GetAttack("lowPriority"), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->GetAttack("higherPriority"), AttackLearnMethod::Unknown);
auto choice1 = new AttackTurnChoice(nullptr, a1);
auto choice2 = new AttackTurnChoice(nullptr, a2);
auto vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
auto rand = Core::Random();
TurnOrdering::OrderChoices(vec,rand);
@ -77,12 +87,16 @@ TEST_CASE( "Turn ordering: High priority goes before low priority", "[Battling]"
delete choice1;
delete choice2;
delete a1;
delete a2;
}
TEST_CASE( "Turn ordering: No priority goes before low priority", "[Battling]" ) {
auto l = GetLibrary()->GetAttackLibrary();
auto choice1 = new AttackTurnChoice(nullptr, new LearnedAttack(l->GetAttack("lowPriority"), AttackLearnMethod::Unknown));
auto choice2 = new AttackTurnChoice(nullptr, new LearnedAttack(l->GetAttack("standard"), AttackLearnMethod::Unknown));
auto a1 = new LearnedAttack(l->GetAttack("lowPriority"), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->GetAttack("standard"), AttackLearnMethod::Unknown);
auto choice1 = new AttackTurnChoice(nullptr, a1);
auto choice2 = new AttackTurnChoice(nullptr, a2);
auto vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
auto rand = Core::Random();
TurnOrdering::OrderChoices(vec,rand);
@ -95,6 +109,8 @@ TEST_CASE( "Turn ordering: No priority goes before low priority", "[Battling]" )
delete choice1;
delete choice2;
delete a1;
delete a2;
}