149 lines
6.0 KiB
C++
149 lines
6.0 KiB
C++
#ifdef TESTS_BUILD
|
|
#include "../../extern/catch.hpp"
|
|
#include "../../src/Library/Species/PokemonSpecies.hpp"
|
|
|
|
TEST_CASE("Able to create and destroy species", "library") {
|
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
|
1, "foo"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
delete species;
|
|
}
|
|
|
|
TEST_CASE("Able to get default forme", "library") {
|
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
|
1, "foo"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
|
|
auto forme = species->GetDefaultForme();
|
|
REQUIRE(forme != nullptr);
|
|
|
|
delete species;
|
|
}
|
|
|
|
TEST_CASE("Able to get default forme name", "library") {
|
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
|
1, "foo"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
|
|
auto forme = species->GetDefaultForme();
|
|
REQUIRE(forme != nullptr);
|
|
REQUIRE(forme->GetName() == "default");
|
|
|
|
delete species;
|
|
}
|
|
|
|
TEST_CASE("Able to get species name", "library") {
|
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
|
1, "foo"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
|
|
REQUIRE(species->GetName() == "foo");
|
|
|
|
delete species;
|
|
}
|
|
|
|
TEST_CASE("Able to get species id", "library") {
|
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
|
1, "foo"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
|
|
REQUIRE(species->GetId() == 1);
|
|
|
|
delete species;
|
|
}
|
|
|
|
TEST_CASE("Able to get species gender ratio", "library") {
|
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
|
1, "foo"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
|
|
REQUIRE(species->GetGenderRate() == 0.5f);
|
|
|
|
delete species;
|
|
}
|
|
|
|
TEST_CASE("Able to get species growth rate", "library") {
|
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
|
1, "foo"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
|
|
REQUIRE(species->GetGrowthRate() == "testGrowthRate");
|
|
|
|
delete species;
|
|
}
|
|
|
|
TEST_CASE("Able to get species capture rate", "library") {
|
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
|
1, "foo"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
|
|
REQUIRE(species->GetCaptureRate() == 100);
|
|
|
|
delete species;
|
|
}
|
|
|
|
TEST_CASE("Able to get species base happiness", "library") {
|
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
|
1, "foo"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
|
|
REQUIRE(species->GetBaseHappiness() == 100);
|
|
|
|
delete species;
|
|
}
|
|
|
|
TEST_CASE("Able to set and get evolution", "library") {
|
|
auto species = new PkmnLib::Library::PokemonSpecies(
|
|
1, "foo"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
auto species2 = new PkmnLib::Library::PokemonSpecies(
|
|
2, "bar"_cnc,
|
|
new PkmnLib::Library::PokemonForme(
|
|
"default", 1.0f, 1.0f, 100, {0}, CreatureLib::Core::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
|
|
{"testAbility"}, {"testHiddenAbility"}, new CreatureLib::Library::LearnableAttacks(100)),
|
|
0.5f, "testGrowthRate"_cnc, 100, 100);
|
|
|
|
species->AddEvolution(PkmnLib::Library::EvolutionData::CreateLevelEvolution(16, species2));
|
|
auto evolutions = species->GetEvolutions();
|
|
REQUIRE(evolutions.size() == 1);
|
|
auto evo = evolutions[0];
|
|
CHECK(evo.GetMethod() == PkmnLib::Library::EvolutionMethod::Level);
|
|
CHECK(evo.GetNewSpecies() == species2);
|
|
CHECK(std::any_cast<uint8_t>(evo.GetData(0)) == 16);
|
|
|
|
delete species;
|
|
delete species2;
|
|
}
|
|
|
|
|
|
#endif |