Defensive programming.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-08-17 18:23:25 +02:00
parent f3721ad2a5
commit cc92cf1491
10 changed files with 67 additions and 26 deletions

View File

@@ -16,7 +16,7 @@ TEST_CASE("Able to build, destroy and insert library", "library") {
new PkmnLib::Library::PokemonForme(
"default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
{"testHiddenAbility"_cnc}, new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
delete lib;
}
@@ -29,7 +29,7 @@ TEST_CASE("Able to insert and retrieve from library", "library") {
new PkmnLib::Library::PokemonForme(
"default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
{"testHiddenAbility"_cnc}, new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
auto val = lib->Get("foo"_cnc);
REQUIRE(val->GetName() == "foo");

View File

@@ -8,7 +8,7 @@ TEST_CASE("Able to create and destroy species", "library") {
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
delete species;
}
@@ -19,7 +19,7 @@ TEST_CASE("Able to get default forme", "library") {
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
auto forme = species->GetDefaultForme();
@@ -34,7 +34,7 @@ TEST_CASE("Able to get default forme name", "library") {
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
auto forme = species->GetDefaultForme();
@@ -50,7 +50,7 @@ TEST_CASE("Able to get species name", "library") {
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
REQUIRE(species->GetName() == "foo");
@@ -64,7 +64,7 @@ TEST_CASE("Able to get species id", "library") {
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
REQUIRE(species->GetId() == 1);
@@ -78,7 +78,7 @@ TEST_CASE("Able to get species gender ratio", "library") {
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
REQUIRE(species->GetGenderRate() == 0.5f);
@@ -92,7 +92,7 @@ TEST_CASE("Able to get species growth rate", "library") {
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
REQUIRE(species->GetGrowthRate() == "testGrowthRate");
@@ -106,7 +106,7 @@ TEST_CASE("Able to get species capture rate", "library") {
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
REQUIRE(species->GetCaptureRate() == 100);
@@ -120,7 +120,7 @@ TEST_CASE("Able to get species base happiness", "library") {
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
REQUIRE(species->GetBaseHappiness() == 100);
@@ -134,14 +134,14 @@ TEST_CASE("Able to set and get evolution", "library") {
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
auto species2 = new PkmnLib::Library::PokemonSpecies(
2, "bar"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100),
{"testAbility"_cnc}, {"testHiddenAbility"_cnc},
new CreatureLib::Library::LearnableAttacks(100)),
new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc});
species->AddEvolution(PkmnLib::Library::EvolutionData::CreateLevelEvolution(16, species2));

View File

@@ -10,7 +10,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
new PkmnLib::Library::PokemonForme(
"default"_cnc, 1.0f, 1.0f, 236, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
{"testHiddenAbility"_cnc}, new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
lib->Insert("testSpecies2"_cnc,
new PkmnLib::Library::PokemonSpecies(
@@ -18,7 +18,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
new PkmnLib::Library::PokemonForme(
"default"_cnc, 1.0f, 1.0f, 306, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
{"testHiddenAbility"_cnc}, new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
lib->Insert("statTestSpecies1"_cnc,
new PkmnLib::Library::PokemonSpecies(
@@ -26,7 +26,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
new PkmnLib::Library::PokemonForme(
"default"_cnc, 1.0f, 1.0f, 236, {0},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
{"testHiddenAbility"_cnc}, new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
lib->Insert("testSpecies3"_cnc,
new PkmnLib::Library::PokemonSpecies(
@@ -34,7 +34,7 @@ PkmnLib::Library::SpeciesLibrary* TestLibrary::BuildSpeciesLibrary() {
new PkmnLib::Library::PokemonForme(
"default"_cnc, 1.0f, 1.0f, 236, {0, 4},
CreatureLib::Library::StatisticSet<uint16_t>(100, 100, 100, 100, 100, 100), {"testAbility"_cnc},
{"testHiddenAbility"_cnc}, new CreatureLib::Library::LearnableAttacks(100)),
{"testHiddenAbility"_cnc}, new PkmnLib::Library::LearnableMoves(100)),
0.5f, "testGrowthRate"_cnc, 100, 100, {"testEggGroup"_cnc}));
return lib;