PkmnLib/tests/LibraryTests/NatureLibraryTests.cpp

82 lines
2.9 KiB
C++

#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../src/Library/Natures/NatureLibrary.hpp"
#include "../../src/Library/Statistic.hpp"
using namespace PkmnLib::Library;
TEST_CASE("Able to create and delete nature library", "library") {
auto lib = new NatureLibrary();
delete lib;
}
TEST_CASE("Able to insert into nature library", "library") {
auto lib = new NatureLibrary();
lib->LoadNature("testNature", Nature(Statistic::PhysicalAttack, Statistic::Speed));
delete lib;
}
TEST_CASE("Able to retrieve nature by name", "library") {
auto lib = new NatureLibrary();
lib->LoadNature("testNature", Nature(Statistic::PhysicalAttack, Statistic::Speed));
auto nature = lib->GetNatureByName("testNature");
REQUIRE(nature.GetIncreasedStat() == Statistic::PhysicalAttack);
REQUIRE(nature.GetDecreasedStat() == Statistic::Speed);
REQUIRE(nature.GetIncreaseModifier() == 1.1f);
REQUIRE(nature.GetDecreaseModifier() == 0.9f);
delete lib;
}
TEST_CASE("Able to retrieve nature by id", "library") {
auto lib = new NatureLibrary();
auto id = lib->LoadNature("testNature", Nature(Statistic::PhysicalAttack, Statistic::Speed));
auto nature = lib->GetNature(id);
REQUIRE(nature.GetIncreasedStat() == Statistic::PhysicalAttack);
REQUIRE(nature.GetDecreasedStat() == Statistic::Speed);
REQUIRE(nature.GetIncreaseModifier() == 1.1f);
REQUIRE(nature.GetDecreaseModifier() == 0.9f);
delete lib;
}
TEST_CASE("Able to retrieve nature id by name", "library") {
auto lib = new NatureLibrary();
lib->LoadNature("testNature", Nature(Statistic::PhysicalAttack, Statistic::Speed));
auto id = lib->GetNatureIdByName("testNature");
REQUIRE(id == 0);
auto nature = lib->GetNature(id);
REQUIRE(nature.GetIncreasedStat() == Statistic::PhysicalAttack);
REQUIRE(nature.GetDecreasedStat() == Statistic::Speed);
REQUIRE(nature.GetIncreaseModifier() == 1.1f);
REQUIRE(nature.GetDecreaseModifier() == 0.9f);
delete lib;
}
TEST_CASE("Able to insert and retrieve multiple natures", "library") {
auto lib = new NatureLibrary();
auto id = lib->LoadNature("testNature", Nature(Statistic::PhysicalAttack, Statistic::Speed));
REQUIRE(id == 0);
auto id2 = lib->LoadNature("testNature2", Nature(Statistic::Speed, Statistic::PhysicalAttack));
REQUIRE(id2 == 1);
auto nature = lib->GetNature(id);
REQUIRE(nature.GetIncreasedStat() == Statistic::PhysicalAttack);
REQUIRE(nature.GetDecreasedStat() == Statistic::Speed);
REQUIRE(nature.GetIncreaseModifier() == 1.1f);
REQUIRE(nature.GetDecreaseModifier() == 0.9f);
nature = lib->GetNature(id2);
REQUIRE(nature.GetIncreasedStat() == Statistic::Speed);
REQUIRE(nature.GetDecreasedStat() == Statistic::PhysicalAttack);
REQUIRE(nature.GetIncreaseModifier() == 1.1f);
REQUIRE(nature.GetDecreaseModifier() == 0.9f);
delete lib;
}
#endif