CreatureLib/tests/BattleTests/CreaturePartyTests.cpp

46 lines
1.6 KiB
C++

#ifdef TESTS_BUILD
#include <doctest.h>
#include "../../src/Battling/Models/CreateCreature.hpp"
#include "../../src/Battling/Models/CreatureParty.hpp"
#include "../TestLibrary/TestLibrary.hpp"
using namespace CreatureLib::Battling;
TEST_CASE("Pack party tests with single creature") {
auto library = TestLibrary::Get();
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
auto party = CreatureParty(6);
party.SwapInto(1, creature);
REQUIRE(party.GetAtIndex(1) == creature);
party.PackParty();
REQUIRE(party.GetAtIndex(0) == creature);
REQUIRE(party.GetAtIndex(1) == nullptr);
party.Switch(0, 5);
REQUIRE(party.GetAtIndex(0) == nullptr);
REQUIRE(party.GetAtIndex(5) == creature);
party.PackParty();
REQUIRE(party.GetAtIndex(0) == creature);
REQUIRE(party.GetAtIndex(1) == nullptr);
REQUIRE(party.GetAtIndex(2) == nullptr);
REQUIRE(party.GetAtIndex(3) == nullptr);
REQUIRE(party.GetAtIndex(4) == nullptr);
REQUIRE(party.GetAtIndex(5) == nullptr);
}
TEST_CASE("Pack party tests with two creatures") {
auto library = TestLibrary::Get();
auto creature1 = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
auto creature2 = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
auto party = CreatureParty(6);
party.SwapInto(1, creature1);
party.SwapInto(5, creature2);
REQUIRE(party.GetAtIndex(1) == creature1);
REQUIRE(party.GetAtIndex(5) == creature2);
party.PackParty();
REQUIRE(party.GetAtIndex(0) == creature1);
REQUIRE(party.GetAtIndex(1) == creature2);
}
#endif