Switch to doctest over Catch for unit tests.
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2020-09-29 18:04:06 +02:00
parent f9eade32db
commit 9a91d356e0
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
18 changed files with 6003 additions and 17635 deletions

View File

@ -20,7 +20,7 @@ steps:
- conan remote add epsilon-public https://packages.p-epsilon.com/ - conan remote add epsilon-public https://packages.p-epsilon.com/
- cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-debug -DSTATICC=ON -DTESTS=ON - cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-debug -DSTATICC=ON -DTESTS=ON
- cmake --build build-debug --target all -- -j 4 - cmake --build build-debug --target all -- -j 4
- build-debug/pkmnLibTests -s --durations yes --use-colour yes - build-debug/pkmnLibTests -s --duration=true --force-colors=true
- name: test-release-linux - name: test-release-linux
image: deukhoofd/linux64builder image: deukhoofd/linux64builder
volumes: volumes:
@ -33,7 +33,7 @@ steps:
- conan remote add epsilon-public https://packages.p-epsilon.com/ - conan remote add epsilon-public https://packages.p-epsilon.com/
- cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-release -DSTATICC=ON -DTESTS=ON - cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-release -DSTATICC=ON -DTESTS=ON
- cmake --build build-release --target all -- -j 4 - cmake --build build-release --target all -- -j 4
- build-release/pkmnLibTests -s --durations yes --use-colour yes - build-release/pkmnLibTests -s --duration=true --force-colors=true
- name: valgrind-release-linux - name: valgrind-release-linux
image: deukhoofd/linux64builder image: deukhoofd/linux64builder
volumes: volumes:
@ -71,7 +71,7 @@ steps:
- cmake --build build-release-windows --target all -- -j 4 - cmake --build build-release-windows --target all -- -j 4
- cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /drone/src/build-release-windows/ - cp /usr/x86_64-w64-mingw32/lib/libwinpthread-1.dll /drone/src/build-release-windows/
- export WINEARCH=win64 - export WINEARCH=win64
- wine build-release-windows/pkmnLibTests.exe -s --durations yes --use-colour yes - wine build-release-windows/pkmnLibTests.exe -s --duration=true --force-colors=true
- name: conan-deploy - name: conan-deploy
image: deukhoofd/linux64builder image: deukhoofd/linux64builder
volumes: volumes:

View File

@ -120,7 +120,7 @@ target_link_libraries(pkmnLib PUBLIC ${_LINKS})
if (TESTS) if (TESTS)
# Create Test executable # Create Test executable
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
add_executable(pkmnLibTests ${TEST_FILES} extern/catch.hpp) add_executable(pkmnLibTests ${TEST_FILES} extern/doctest.hpp)
message(STATUS "${_TESTLINKS}") message(STATUS "${_TESTLINKS}")
target_link_libraries(pkmnLibTests PUBLIC ${_TESTLINKS}) target_link_libraries(pkmnLibTests PUBLIC ${_TESTLINKS})

17597
extern/catch.hpp vendored

File diff suppressed because it is too large Load Diff

5965
extern/doctest.hpp vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,22 +1,22 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../extern/catch.hpp" #include "../../extern/doctest.hpp"
#include "../../src/Library/Natures/NatureLibrary.hpp" #include "../../src/Library/Natures/NatureLibrary.hpp"
#include "../../src/Library/Statistic.hpp" #include "../../src/Library/Statistic.hpp"
using namespace PkmnLib::Library; using namespace PkmnLib::Library;
TEST_CASE("Able to create and delete nature library", "library") { TEST_CASE("Able to create and delete nature library") {
auto lib = new NatureLibrary(); auto lib = new NatureLibrary();
delete lib; delete lib;
} }
TEST_CASE("Able to insert into nature library", "library") { TEST_CASE("Able to insert into nature library") {
auto lib = new NatureLibrary(); auto lib = new NatureLibrary();
lib->LoadNature("testNature"_cnc, new Nature(Statistic::PhysicalAttack, Statistic::Speed)); lib->LoadNature("testNature"_cnc, new Nature(Statistic::PhysicalAttack, Statistic::Speed));
delete lib; delete lib;
} }
TEST_CASE("Able to retrieve nature by name", "library") { TEST_CASE("Able to retrieve nature by name") {
auto lib = new NatureLibrary(); auto lib = new NatureLibrary();
lib->LoadNature("testNature"_cnc, new Nature(Statistic::PhysicalAttack, Statistic::Speed)); lib->LoadNature("testNature"_cnc, new Nature(Statistic::PhysicalAttack, Statistic::Speed));

View File

@ -1,14 +1,14 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#define CATCH_CONFIG_MAIN #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "../../extern/catch.hpp" #include "../../extern/doctest.hpp"
#include "../../src/Library/Species/SpeciesLibrary.hpp" #include "../../src/Library/Species/SpeciesLibrary.hpp"
TEST_CASE("Able to build and destroy empty library", "library") { TEST_CASE("Able to build and destroy empty library") {
auto lib = new PkmnLib::Library::SpeciesLibrary(); auto lib = new PkmnLib::Library::SpeciesLibrary();
delete lib; delete lib;
} }
TEST_CASE("Able to build, destroy and insert library", "library") { TEST_CASE("Able to build, destroy and insert library") {
auto lib = new PkmnLib::Library::SpeciesLibrary(); auto lib = new PkmnLib::Library::SpeciesLibrary();
lib->Insert("foo"_cnc.GetHash(), lib->Insert("foo"_cnc.GetHash(),
new PkmnLib::Library::PokemonSpecies( new PkmnLib::Library::PokemonSpecies(
@ -21,7 +21,7 @@ TEST_CASE("Able to build, destroy and insert library", "library") {
delete lib; delete lib;
} }
TEST_CASE("Able to insert and retrieve from library", "library") { TEST_CASE("Able to insert and retrieve from library") {
auto lib = new PkmnLib::Library::SpeciesLibrary(); auto lib = new PkmnLib::Library::SpeciesLibrary();
lib->Insert("foo"_cnc.GetHash(), lib->Insert("foo"_cnc.GetHash(),
new PkmnLib::Library::PokemonSpecies( new PkmnLib::Library::PokemonSpecies(

View File

@ -1,8 +1,8 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../extern/catch.hpp" #include "../../extern/doctest.hpp"
#include "../../src/Library/Species/PokemonSpecies.hpp" #include "../../src/Library/Species/PokemonSpecies.hpp"
TEST_CASE("Able to create and destroy species", "library") { TEST_CASE("Able to create and destroy species") {
auto species = new PkmnLib::Library::PokemonSpecies( auto species = new PkmnLib::Library::PokemonSpecies(
1, "foo"_cnc, 1, "foo"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
@ -13,7 +13,7 @@ TEST_CASE("Able to create and destroy species", "library") {
delete species; delete species;
} }
TEST_CASE("Able to get default forme", "library") { TEST_CASE("Able to get default forme") {
auto species = new PkmnLib::Library::PokemonSpecies( auto species = new PkmnLib::Library::PokemonSpecies(
1, "foo"_cnc, 1, "foo"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
@ -28,7 +28,7 @@ TEST_CASE("Able to get default forme", "library") {
delete species; delete species;
} }
TEST_CASE("Able to get default forme name", "library") { TEST_CASE("Able to get default forme name") {
auto species = new PkmnLib::Library::PokemonSpecies( auto species = new PkmnLib::Library::PokemonSpecies(
1, "foo"_cnc, 1, "foo"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
@ -44,7 +44,7 @@ TEST_CASE("Able to get default forme name", "library") {
delete species; delete species;
} }
TEST_CASE("Able to get species name", "library") { TEST_CASE("Able to get species name") {
auto species = new PkmnLib::Library::PokemonSpecies( auto species = new PkmnLib::Library::PokemonSpecies(
1, "foo"_cnc, 1, "foo"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
@ -58,7 +58,7 @@ TEST_CASE("Able to get species name", "library") {
delete species; delete species;
} }
TEST_CASE("Able to get species id", "library") { TEST_CASE("Able to get species id") {
auto species = new PkmnLib::Library::PokemonSpecies( auto species = new PkmnLib::Library::PokemonSpecies(
1, "foo"_cnc, 1, "foo"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
@ -72,7 +72,7 @@ TEST_CASE("Able to get species id", "library") {
delete species; delete species;
} }
TEST_CASE("Able to get species gender ratio", "library") { TEST_CASE("Able to get species gender ratio") {
auto species = new PkmnLib::Library::PokemonSpecies( auto species = new PkmnLib::Library::PokemonSpecies(
1, "foo"_cnc, 1, "foo"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
@ -86,7 +86,7 @@ TEST_CASE("Able to get species gender ratio", "library") {
delete species; delete species;
} }
TEST_CASE("Able to get species growth rate", "library") { TEST_CASE("Able to get species growth rate") {
auto species = new PkmnLib::Library::PokemonSpecies( auto species = new PkmnLib::Library::PokemonSpecies(
1, "foo"_cnc, 1, "foo"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
@ -100,7 +100,7 @@ TEST_CASE("Able to get species growth rate", "library") {
delete species; delete species;
} }
TEST_CASE("Able to get species capture rate", "library") { TEST_CASE("Able to get species capture rate") {
auto species = new PkmnLib::Library::PokemonSpecies( auto species = new PkmnLib::Library::PokemonSpecies(
1, "foo"_cnc, 1, "foo"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
@ -114,7 +114,7 @@ TEST_CASE("Able to get species capture rate", "library") {
delete species; delete species;
} }
TEST_CASE("Able to get species base happiness", "library") { TEST_CASE("Able to get species base happiness") {
auto species = new PkmnLib::Library::PokemonSpecies( auto species = new PkmnLib::Library::PokemonSpecies(
1, "foo"_cnc, 1, "foo"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},
@ -128,7 +128,7 @@ TEST_CASE("Able to get species base happiness", "library") {
delete species; delete species;
} }
TEST_CASE("Able to set and get evolution", "library") { TEST_CASE("Able to set and get evolution") {
auto species = new PkmnLib::Library::PokemonSpecies( auto species = new PkmnLib::Library::PokemonSpecies(
1, "foo"_cnc, 1, "foo"_cnc,
new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0}, new PkmnLib::Library::PokemonForme("default"_cnc, 1.0f, 1.0f, 100, {0},

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../extern/catch.hpp" #include "../../extern/doctest.hpp"
#include "../../src/Battling/Pokemon/CreatePokemon.hpp" #include "../../src/Battling/Pokemon/CreatePokemon.hpp"
#include "../TestLibrary/TestLibrary.hpp" #include "../TestLibrary/TestLibrary.hpp"

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../extern/catch.hpp" #include "../../extern/doctest.hpp"
#include "../../src/Battling/Pokemon/CreatePokemon.hpp" #include "../../src/Battling/Pokemon/CreatePokemon.hpp"
#include "../TestLibrary/TestLibrary.hpp" #include "../TestLibrary/TestLibrary.hpp"

View File

@ -1,11 +1,11 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../extern/catch.hpp" #include "../../extern/doctest.hpp"
#include "../../src/Battling/Library/ExperienceLibrary.hpp" #include "../../src/Battling/Library/ExperienceLibrary.hpp"
#include "../../src/Battling/Pokemon/CreatePokemon.hpp" #include "../../src/Battling/Pokemon/CreatePokemon.hpp"
#include "../TestLibrary/TestLibrary.hpp" #include "../TestLibrary/TestLibrary.hpp"
using namespace PkmnLib::Battling; using namespace PkmnLib::Battling;
TEST_CASE("Basic Experience gain test", "battling") { TEST_CASE("Basic Experience gain test") {
auto lib = TestLibrary::GetLibrary(); auto lib = TestLibrary::GetLibrary();
auto mon1 = CreatePokemon(lib, "testSpecies"_cnc, 55).Build(); auto mon1 = CreatePokemon(lib, "testSpecies"_cnc, 55).Build();
auto initialExp = mon1->GetExperience(); auto initialExp = mon1->GetExperience();

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../extern/catch.hpp" #include "../../extern/doctest.hpp"
#include "../../src/Battling/Pokemon/CreatePokemon.hpp" #include "../../src/Battling/Pokemon/CreatePokemon.hpp"
#include "../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp" #include "../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../TestLibrary/TestLibrary.hpp" #include "../TestLibrary/TestLibrary.hpp"
@ -277,7 +277,7 @@ TEST_CASE("Invoke ChangeEffectiveness script function") {
REQUIRE(script != nullptr); REQUIRE(script != nullptr);
float b = 0; float b = 0;
script->ChangeEffectiveness(nullptr, nullptr, 0, &b); script->ChangeEffectiveness(nullptr, nullptr, 0, &b);
REQUIRE(b == Approx(0.75)); REQUIRE(b == doctest::Approx(0.75));
delete script; delete script;
} }

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../extern/catch.hpp" #include "../../extern/doctest.hpp"
#include "../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp" #include "../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../TestLibrary/TestLibrary.hpp" #include "../TestLibrary/TestLibrary.hpp"

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/doctest.hpp"
#include "../../../../src/Battling/Pokemon/CreatePokemon.hpp" #include "../../../../src/Battling/Pokemon/CreatePokemon.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/doctest.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/doctest.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/doctest.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"
@ -92,7 +92,7 @@ TEST_CASE("Validate Move Category in Script") {
data.Context->SetArgDWord(1, (asDWORD)move->GetCategory()); data.Context->SetArgDWord(1, (asDWORD)move->GetCategory());
auto result = data.Context->Execute(); auto result = data.Context->Execute();
INFO("exception: " << data.Context->GetExceptionString()) INFO("exception: " << data.Context->GetExceptionString());
REQUIRE(result == asEXECUTION_FINISHED); REQUIRE(result == asEXECUTION_FINISHED);
REQUIRE((bool)data.Context->GetReturnByte()); REQUIRE((bool)data.Context->GetReturnByte());
} }

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/doctest.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD #ifdef TESTS_BUILD
#include "../../../../extern/catch.hpp" #include "../../../../extern/doctest.hpp"
#include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp" #include "../../../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp"
#include "../../../TestLibrary/TestLibrary.hpp" #include "../../../TestLibrary/TestLibrary.hpp"