Initial commit.
This commit is contained in:
40
tests/LibraryTests/SpeciesLibraryTests.cpp
Normal file
40
tests/LibraryTests/SpeciesLibraryTests.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifdef TESTS_BUILD
|
||||
#define CATCH_CONFIG_MAIN
|
||||
#include "../../extern/catch.hpp"
|
||||
#include "../../src/Library/Species/SpeciesLibrary.hpp"
|
||||
|
||||
TEST_CASE("Able to build and destroy empty library", "library") {
|
||||
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||
delete lib;
|
||||
}
|
||||
|
||||
TEST_CASE("Able to build, destroy and insert library", "library") {
|
||||
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||
lib->LoadSpecies("foo",
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo",
|
||||
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", 100, 100));
|
||||
delete lib;
|
||||
}
|
||||
|
||||
TEST_CASE("Able to insert and retrieve from library", "library") {
|
||||
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||
lib->LoadSpecies("foo",
|
||||
new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo",
|
||||
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", 100, 100));
|
||||
auto val = lib->GetSpecies("foo");
|
||||
REQUIRE(val->GetName() == "foo");
|
||||
delete lib;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
124
tests/LibraryTests/SpeciesTests.cpp
Normal file
124
tests/LibraryTests/SpeciesTests.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
#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",
|
||||
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", 100, 100);
|
||||
delete species;
|
||||
}
|
||||
|
||||
TEST_CASE("Able to get default forme", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo",
|
||||
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", 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",
|
||||
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", 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",
|
||||
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", 100, 100);
|
||||
|
||||
REQUIRE(species->GetName() == "foo");
|
||||
|
||||
delete species;
|
||||
}
|
||||
|
||||
TEST_CASE("Able to get species id", "library") {
|
||||
auto species = new PkmnLib::Library::PokemonSpecies(
|
||||
1, "foo",
|
||||
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", 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",
|
||||
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", 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",
|
||||
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", 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",
|
||||
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", 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",
|
||||
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", 100, 100);
|
||||
|
||||
REQUIRE(species->GetBaseHappiness() == 100);
|
||||
|
||||
delete species;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
1
tests/TestLibrary/TestLibrary.cpp
Normal file
1
tests/TestLibrary/TestLibrary.cpp
Normal file
@@ -0,0 +1 @@
|
||||
#include "TestLibrary.hpp"
|
||||
49
tests/TestLibrary/TestLibrary.hpp
Normal file
49
tests/TestLibrary/TestLibrary.hpp
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef PKMNLIB_TESTLIBRARY_HPP
|
||||
#define PKMNLIB_TESTLIBRARY_HPP
|
||||
|
||||
#include "../../src/Library/PokemonLibrary.hpp"
|
||||
class TestLibrary {
|
||||
private:
|
||||
static PkmnLib::Library::PokemonLibrary* _library;
|
||||
|
||||
public:
|
||||
static PkmnLib::Library::PokemonLibrary* GetLibrary() {
|
||||
if (_library == nullptr) {
|
||||
_library = BuildLibrary();
|
||||
}
|
||||
return _library;
|
||||
}
|
||||
|
||||
static PkmnLib::Library::PokemonLibrary* BuildLibrary() {
|
||||
return new PkmnLib::Library::PokemonLibrary(CreatureLib::Library::LibrarySettings(100, 4),
|
||||
BuildSpeciesLibrary(), BuildAttackLibrary(), BuildItemLibrary(),
|
||||
BuildGrowthRateLibrary(), BuildTypeLibrary());
|
||||
}
|
||||
|
||||
static PkmnLib::Library::SpeciesLibrary* BuildSpeciesLibrary() {
|
||||
auto lib = new PkmnLib::Library::SpeciesLibrary();
|
||||
return lib;
|
||||
}
|
||||
|
||||
static CreatureLib::Library::AttackLibrary* BuildAttackLibrary() {
|
||||
auto lib = new CreatureLib::Library::AttackLibrary();
|
||||
return lib;
|
||||
}
|
||||
|
||||
static CreatureLib::Library::ItemLibrary* BuildItemLibrary() {
|
||||
auto lib = new CreatureLib::Library::ItemLibrary();
|
||||
return lib;
|
||||
}
|
||||
|
||||
static CreatureLib::Library::GrowthRateLibrary* BuildGrowthRateLibrary() {
|
||||
auto lib = new CreatureLib::Library::GrowthRateLibrary();
|
||||
return lib;
|
||||
}
|
||||
|
||||
static CreatureLib::Library::TypeLibrary* BuildTypeLibrary() {
|
||||
auto lib = new CreatureLib::Library::TypeLibrary();
|
||||
return lib;
|
||||
}
|
||||
};
|
||||
|
||||
#endif // PKMNLIB_TESTLIBRARY_HPP
|
||||
Reference in New Issue
Block a user