Priority tests
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-10-31 13:03:41 +01:00
parent 42c1623985
commit 7da87956cf
2 changed files with 82 additions and 0 deletions

View File

@@ -25,4 +25,78 @@ TEST_CASE( "Turn ordering: Attack before pass", "[Battling]" ) {
delete choice2;
}
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 vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
auto rand = Core::Random();
TurnOrdering::OrderChoices(vec,rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
vec = std::vector<const BaseTurnChoice*>{choice2, choice1};
TurnOrdering::OrderChoices(vec,rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
delete choice1;
delete choice2;
}
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 vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
auto rand = Core::Random();
TurnOrdering::OrderChoices(vec,rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
vec = std::vector<const BaseTurnChoice*>{choice2, choice1};
TurnOrdering::OrderChoices(vec,rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
delete choice1;
delete choice2;
}
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 vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
auto rand = Core::Random();
TurnOrdering::OrderChoices(vec,rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
vec = std::vector<const BaseTurnChoice*>{choice2, choice1};
TurnOrdering::OrderChoices(vec,rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
delete choice1;
delete choice2;
}
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 vec = std::vector<const BaseTurnChoice*>{choice1, choice2};
auto rand = Core::Random();
TurnOrdering::OrderChoices(vec,rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
vec = std::vector<const BaseTurnChoice*>{choice2, choice1};
TurnOrdering::OrderChoices(vec,rand);
CHECK(vec[0] == choice2);
CHECK(vec[1] == choice1);
delete choice1;
delete choice2;
}
#endif