Fix memory leak in unit tests
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
163752a8ea
commit
d7fee13002
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue