Switch unit test library from Catch2 to DocTest.
continuous-integration/drone/push Build is failing Details

Signed-off-by: Deukhoofd <Deukhoofd@gmail.com>
This commit is contained in:
Deukhoofd 2020-09-25 12:43:08 +02:00
parent 5b10dac514
commit 5970dc5d90
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
18 changed files with 6052 additions and 16802 deletions

View File

@ -76,7 +76,7 @@ target_link_libraries(CreatureLib PUBLIC ${_LIBRARYLINKS} Threads::Threads)
if (TESTS)
# Create Test executable
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
add_executable(CreatureLibTests ${TEST_FILES} extern/catch.hpp tests/BattleTests/EventHookTests.cpp)
add_executable(CreatureLibTests ${TEST_FILES} extern/doctest.hpp tests/BattleTests/EventHookTests.cpp)
target_link_libraries(CreatureLibTests PUBLIC CreatureLib Arbutils)
# Add a definition for the test library

16712
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,6 +1,6 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../../src/Battling/Flow/ChoiceQueue.hpp"
#include "../../src/Battling/Models/BattleSide.hpp"
#include "../../src/Battling/Models/CreateCreature.hpp"
@ -9,7 +9,7 @@
using namespace CreatureLib::Battling;
TEST_CASE("Move creature choice up next.", "[Battling]") {
TEST_CASE("Move creature choice up next.") {
auto lib = TestLibrary::Get();
auto c1 = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();
auto c2 = CreateCreature(lib, "testSpecies1"_cnc, 1).Create();

View File

@ -1,6 +1,6 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../../src/Battling/Models/BattleSide.hpp"
#include "../../src/Battling/Models/CreateCreature.hpp"
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
@ -8,7 +8,7 @@
using namespace CreatureLib::Battling;
TEST_CASE("Set Choice one-sized side", "[Battling]") {
TEST_CASE("Set Choice one-sized side") {
auto side = BattleSide(0, nullptr, 1);
auto c = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
side.SetCreature(c, 0);
@ -17,7 +17,7 @@ TEST_CASE("Set Choice one-sized side", "[Battling]") {
delete c;
}
TEST_CASE("Set Choice one-sized side, validate all choices set", "[Battling]") {
TEST_CASE("Set Choice one-sized side, validate all choices set") {
auto side = BattleSide(0, nullptr, 1);
auto c = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
side.SetCreature(c, 0);
@ -28,7 +28,7 @@ TEST_CASE("Set Choice one-sized side, validate all choices set", "[Battling]") {
delete c;
}
TEST_CASE("Set Choice two-sized side", "[Battling]") {
TEST_CASE("Set Choice two-sized side") {
auto side = BattleSide(0, nullptr, 2);
auto c1 = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
auto c2 = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
@ -42,7 +42,7 @@ TEST_CASE("Set Choice two-sized side", "[Battling]") {
delete c2;
}
TEST_CASE("Set Choice two-sized side, validate all choices set", "[Battling]") {
TEST_CASE("Set Choice two-sized side, validate all choices set") {
auto side = BattleSide(0, nullptr, 2);
auto c1 = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();
auto c2 = CreateCreature(TestLibrary::Get(), "testSpecies1"_cnc, 5).Create();

View File

@ -1,12 +1,12 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../../src/Battling/Models/CreateCreature.hpp"
#include "../../src/Battling/Models/CreatureParty.hpp"
#include "../TestLibrary/TestLibrary.hpp"
using namespace CreatureLib::Battling;
TEST_CASE("Pack party tests with single creature", "[Library]") {
TEST_CASE("Pack party tests with single creature") {
auto library = TestLibrary::Get();
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
auto party = CreatureParty(6);
@ -28,7 +28,7 @@ TEST_CASE("Pack party tests with single creature", "[Library]") {
REQUIRE(party.GetAtIndex(5) == nullptr);
}
TEST_CASE("Pack party tests with two creatures", "[Library]") {
TEST_CASE("Pack party tests with two creatures") {
auto library = TestLibrary::Get();
auto creature1 = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
auto creature2 = CreateCreature(library, "testSpecies1"_cnc, 1).Create();

View File

@ -1,44 +1,44 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../../src/Battling/Models/CreateCreature.hpp"
#include "../TestLibrary/TestLibrary.hpp"
using namespace CreatureLib::Battling;
TEST_CASE("Create basic creature", "[Library]") {
TEST_CASE("Create basic creature") {
auto library = TestLibrary::Get();
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
delete creature;
}
TEST_CASE("Get creature species", "[Library]") {
TEST_CASE("Get creature species") {
auto library = TestLibrary::Get();
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
REQUIRE(creature->GetSpecies()->GetName() == "testSpecies1"_cnc);
delete creature;
}
TEST_CASE("Get creature level", "[Library]") {
TEST_CASE("Get creature level") {
auto library = TestLibrary::Get();
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
REQUIRE(creature->GetLevel() == 1);
delete creature;
}
TEST_CASE("Get creature variant when unset", "[Library]") {
TEST_CASE("Get creature variant when unset") {
auto library = TestLibrary::Get();
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
REQUIRE(creature->GetVariant()->GetName() == "default");
delete creature;
}
TEST_CASE("Get creature nickname when unset", "[Library]") {
TEST_CASE("Get creature nickname when unset") {
auto library = TestLibrary::Get();
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).WithNickname("foo").Create();
REQUIRE(creature->GetNickname() == "foo");
delete creature;
}
TEST_CASE("Increase creature stat boost", "[Library]") {
TEST_CASE("Increase creature stat boost") {
auto library = TestLibrary::Get();
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
creature->ChangeStatBoost(CreatureLib::Library::Statistic::PhysicalAttack, 6);
@ -46,7 +46,7 @@ TEST_CASE("Increase creature stat boost", "[Library]") {
delete creature;
}
TEST_CASE("Override Creature talent", "[Library]") {
TEST_CASE("Override Creature talent") {
auto library = TestLibrary::Get();
auto creature = CreateCreature(library, "testSpecies1"_cnc, 1).Create();
creature->OverrideActiveTalent("foobar");

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../../src/Battling/EventHooks/EventDataClasses.hpp"
#include "../../src/Battling/EventHooks/EventHook.hpp"
#include "../../src/Battling/Models/CreateCreature.hpp"
@ -7,7 +7,7 @@
using namespace CreatureLib::Battling;
TEST_CASE("Build and use event hook", "[Battling]") {
TEST_CASE("Build and use event hook") {
auto eventHook = EventHook();
std::vector<const EventData*> events;
eventHook.RegisterListener([&](const EventData* evt) mutable -> void { events.push_back(evt); });
@ -18,7 +18,7 @@ TEST_CASE("Build and use event hook", "[Battling]") {
REQUIRE(events[0]->GetKind() == EventDataKind::Damage);
}
TEST_CASE("Build and use event hook a lot", "[Battling]") {
TEST_CASE("Build and use event hook a lot") {
auto eventHook = EventHook();
std::vector<const EventData*> events;
eventHook.RegisterListener([&](const EventData* evt) mutable -> void { events.push_back(evt); });
@ -28,7 +28,7 @@ TEST_CASE("Build and use event hook a lot", "[Battling]") {
REQUIRE(events.size() == 10000);
}
TEST_CASE("Build and use event hook with different types", "[Battling]") {
TEST_CASE("Build and use event hook with different types") {
auto eventHook = EventHook();
std::vector<const EventData*> events;
eventHook.RegisterListener([&](const EventData* evt) mutable -> void { events.push_back(evt); });

View File

@ -1,7 +1,7 @@
#ifdef TESTS_BUILD
#include <utility>
#include "../../../extern/catch.hpp"
#include "../../../extern/doctest.hpp"
#include "../../../src/Battling/ScriptHandling/ScriptAggregator.hpp"
using namespace CreatureLib;
@ -18,7 +18,7 @@ public:
void TestMethod(int& runCount) { runCount++; }
};
TEST_CASE("Script Aggregator properly iterates containing script.", "[Battling, Scripting]") {
TEST_CASE("Script Aggregator properly iterates containing script.") {
auto script = std::make_unique<TestScript>("test");
auto ran = 0;
auto vec =
@ -32,7 +32,7 @@ TEST_CASE("Script Aggregator properly iterates containing script.", "[Battling,
CHECK(ran == 1);
}
TEST_CASE("Script Aggregator properly iterates multiple scripts.", "[Battling, Scripting]") {
TEST_CASE("Script Aggregator properly iterates multiple scripts.") {
auto script = std::make_unique<TestScript>("test");
auto script2 = std::make_unique<TestScript>("test2");
auto script3 = std::make_unique<TestScript>("test3");
@ -50,7 +50,7 @@ TEST_CASE("Script Aggregator properly iterates multiple scripts.", "[Battling, S
CHECK(ran == 3);
}
TEST_CASE("Script Aggregator properly iterates Script Set.", "[Battling, Scripting]") {
TEST_CASE("Script Aggregator properly iterates Script Set.") {
Script* script = new TestScript("test");
Script* script2 = new TestScript("test2");
Script* script3 = new TestScript("test3");
@ -69,7 +69,7 @@ TEST_CASE("Script Aggregator properly iterates Script Set.", "[Battling, Scripti
CHECK(ran == 3);
}
TEST_CASE("Script Aggregator properly iterates data of Script Set and Script.", "[Battling, Scripting]") {
TEST_CASE("Script Aggregator properly iterates data of Script Set and Script.") {
auto script = std::make_unique<TestScript>("test");
Script* script2 = new TestScript("test2");
Script* script3 = new TestScript("test3");
@ -88,7 +88,7 @@ TEST_CASE("Script Aggregator properly iterates data of Script Set and Script.",
CHECK(ran == 3);
}
TEST_CASE("Script Aggregator properly iterates data of Script and Script Set.", "[Battling, Scripting]") {
TEST_CASE("Script Aggregator properly iterates data of Script and Script Set.") {
auto script = std::make_unique<TestScript>("test");
Script* script2 = new TestScript("test2");
Script* script3 = new TestScript("test3");
@ -107,7 +107,7 @@ TEST_CASE("Script Aggregator properly iterates data of Script and Script Set.",
CHECK(ran == 3);
}
TEST_CASE("Script Aggregator properly iterates data of Script, Script Set and Script.", "[Battling, Scripting]") {
TEST_CASE("Script Aggregator properly iterates data of Script, Script Set and Script.") {
auto script = std::make_unique<TestScript>("test");
Script* script2 = new TestScript("test2");
Script* script3 = new TestScript("test3");
@ -128,7 +128,7 @@ TEST_CASE("Script Aggregator properly iterates data of Script, Script Set and Sc
CHECK(ran == 4);
}
TEST_CASE("Script Aggregator properly iterates when empty.", "[Battling, Scripting]") {
TEST_CASE("Script Aggregator properly iterates when empty.") {
auto ran = 0;
auto vec = ArbUt::List<ScriptWrapper>{};
auto aggr = ScriptAggregator(vec);
@ -138,7 +138,7 @@ TEST_CASE("Script Aggregator properly iterates when empty.", "[Battling, Scripti
CHECK(ran == 0);
}
TEST_CASE("Script Aggregator properly iterates empty Script Set.", "[Battling, Scripting]") {
TEST_CASE("Script Aggregator properly iterates empty Script Set.") {
auto ran = 0;
auto set = ScriptSet();
auto vec = ArbUt::List<ScriptWrapper>{ScriptWrapper::FromSet(&set)};

View File

@ -1,7 +1,7 @@
#ifdef TESTS_BUILD
#include <utility>
#include "../../../extern/catch.hpp"
#include "../../../extern/doctest.hpp"
#include "../../../src/Battling/ScriptHandling/ScriptSet.hpp"
using namespace CreatureLib;
@ -16,19 +16,19 @@ public:
const ArbUt::StringView& GetName() const noexcept override { return _name; }
};
TEST_CASE("Empty script set count == 0", "[Battling, Scripting]") {
TEST_CASE("Empty script set count == 0") {
auto set = ScriptSet();
REQUIRE(set.Count() == 0);
}
TEST_CASE("Add script to script set", "[Battling, Scripting]") {
TEST_CASE("Add script to script set") {
auto set = ScriptSet();
auto s = new TestScript("foobar");
set.Add(s);
REQUIRE(set.Count() == 1);
}
TEST_CASE("Add script to script set, then retrieve it", "[Battling, Scripting]") {
TEST_CASE("Add script to script set, then retrieve it") {
auto set = ScriptSet();
auto s = new TestScript("foobar");
set.Add(s);
@ -37,7 +37,7 @@ TEST_CASE("Add script to script set, then retrieve it", "[Battling, Scripting]")
REQUIRE(get->GetName() == "foobar");
}
TEST_CASE("Add two scripts to script set", "[Battling, Scripting]") {
TEST_CASE("Add two scripts to script set") {
auto set = ScriptSet();
auto s = new TestScript("foobar");
auto s2 = new TestScript("foobar2");
@ -46,7 +46,7 @@ TEST_CASE("Add two scripts to script set", "[Battling, Scripting]") {
REQUIRE(set.Count() == 2);
}
TEST_CASE("Add two scripts to script set, then retrieve them", "[Battling, Scripting]") {
TEST_CASE("Add two scripts to script set, then retrieve them") {
auto set = ScriptSet();
auto s = new TestScript("foobar");
auto s2 = new TestScript("foobar2");
@ -59,7 +59,7 @@ TEST_CASE("Add two scripts to script set, then retrieve them", "[Battling, Scrip
REQUIRE(get2->GetName() == "foobar2");
}
TEST_CASE("Add script to script set, then remove it", "[Battling, Scripting]") {
TEST_CASE("Add script to script set, then remove it") {
auto set = ScriptSet();
auto s = new TestScript("foobar");
set.Add(s);
@ -70,7 +70,7 @@ TEST_CASE("Add script to script set, then remove it", "[Battling, Scripting]") {
REQUIRE(it.Count() == 0);
}
TEST_CASE("Add two scripts to script set, then remove them", "[Battling, Scripting]") {
TEST_CASE("Add two scripts to script set, then remove them") {
auto set = ScriptSet();
auto s = new TestScript("foobar");
auto s2 = new TestScript("foobar2");

View File

@ -1,9 +1,7 @@
#ifdef TESTS_BUILD
#include "../../../src/Battling/ScriptHandling/ScriptSource.hpp"
#include <utility>
#include "../../../extern/catch.hpp"
#include "../../../src/Battling/ScriptHandling/ScriptAggregator.hpp"
#include "../../../extern/doctest.hpp"
using namespace CreatureLib;
using namespace CreatureLib::Battling;
@ -41,13 +39,13 @@ protected:
}
};
TEST_CASE("Script source with unset script ptr.", "[Battling, Scripting]") {
TEST_CASE("Script source with unset script ptr.") {
auto source = ScriptSourceWithScriptPtr();
auto scripts = source.GetScriptIterator();
REQUIRE_FALSE(scripts.HasNext());
}
TEST_CASE("Script source with script ptr being set.", "[Battling, Scripting]") {
TEST_CASE("Script source with script ptr being set.") {
auto source = ScriptSourceWithScriptPtr();
source.ScriptPtr = std::make_unique<TestScript>("foobar");
auto scripts = source.GetScriptIterator();
@ -55,7 +53,7 @@ TEST_CASE("Script source with script ptr being set.", "[Battling, Scripting]") {
CHECK(first != nullptr);
}
TEST_CASE("Script source with script ptr being set after first iteration.", "[Battling, Scripting]") {
TEST_CASE("Script source with script ptr being set after first iteration.") {
auto source = ScriptSourceWithScriptPtr();
auto scripts = source.GetScriptIterator();
REQUIRE_FALSE(scripts.HasNext());
@ -65,14 +63,14 @@ TEST_CASE("Script source with script ptr being set after first iteration.", "[Ba
CHECK(first != nullptr);
}
TEST_CASE("Script source with empty script set.", "[Battling, Scripting]") {
TEST_CASE("Script source with empty script set.") {
auto source = ScriptSourceWithScriptSet();
auto scripts = source.GetScriptIterator();
scripts.Reset();
REQUIRE_FALSE(scripts.HasNext());
}
TEST_CASE("Script source with single item script set.", "[Battling, Scripting]") {
TEST_CASE("Script source with single item script set.") {
auto source = ScriptSourceWithScriptSet();
auto s = new TestScript("foobar");
source.Set.Add(s);
@ -82,7 +80,7 @@ TEST_CASE("Script source with single item script set.", "[Battling, Scripting]")
CHECK(first->GetName() == "foobar");
}
TEST_CASE("Script source with multiple item script set.", "[Battling, Scripting]") {
TEST_CASE("Script source with multiple item script set.") {
auto source = ScriptSourceWithScriptSet();
auto s = new TestScript("foobar");
auto s2 = new TestScript("foobar2");

View File

@ -1,6 +1,6 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../../src/Battling/Flow/TurnOrdering.hpp"
#include "../../src/Battling/TurnChoices/AttackTurnChoice.hpp"
#include "../../src/Battling/TurnChoices/PassTurnChoice.hpp"
@ -9,7 +9,7 @@
using namespace CreatureLib;
using namespace CreatureLib::Battling;
TEST_CASE("Turn ordering: Attack before pass", "[Battling]") {
TEST_CASE("Turn ordering: Attack before pass") {
auto lib = TestLibrary::Get();
auto learnedAttack =
LearnedAttack(lib->GetAttackLibrary()->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);
@ -25,7 +25,7 @@ TEST_CASE("Turn ordering: Attack before pass", "[Battling]") {
CHECK(vec[1] == choice1);
}
TEST_CASE("Turn ordering: High priority goes before no priority", "[Battling]") {
TEST_CASE("Turn ordering: High priority goes before no priority") {
const auto& l = TestLibrary::Get()->GetAttackLibrary();
auto a1 = new LearnedAttack(l->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("highPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
@ -44,7 +44,7 @@ TEST_CASE("Turn ordering: High priority goes before no priority", "[Battling]")
delete a2;
}
TEST_CASE("Turn ordering: Higher priority goes before high priority", "[Battling]") {
TEST_CASE("Turn ordering: Higher priority goes before high priority") {
const auto& l = TestLibrary::Get()->GetAttackLibrary();
auto a1 = new LearnedAttack(l->Get("highPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
@ -62,7 +62,7 @@ TEST_CASE("Turn ordering: Higher priority goes before high priority", "[Battling
delete a2;
}
TEST_CASE("Turn ordering: High priority goes before low priority", "[Battling]") {
TEST_CASE("Turn ordering: High priority goes before low priority") {
const auto& l = TestLibrary::Get()->GetAttackLibrary();
auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("higherPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
@ -81,7 +81,7 @@ TEST_CASE("Turn ordering: High priority goes before low priority", "[Battling]")
delete a2;
}
TEST_CASE("Turn ordering: No priority goes before low priority", "[Battling]") {
TEST_CASE("Turn ordering: No priority goes before low priority") {
const auto& l = TestLibrary::Get()->GetAttackLibrary();
auto a1 = new LearnedAttack(l->Get("lowPriority"_cnc.GetHash()), AttackLearnMethod::Unknown);
auto a2 = new LearnedAttack(l->Get("standard"_cnc.GetHash()), AttackLearnMethod::Unknown);

View File

@ -1,22 +1,21 @@
#ifdef TESTS_BUILD
#include <cstring>
#include "../CInterface/Core.hpp"
#include "../extern/catch.hpp"
#include "../src/Library/Exceptions/CreatureException.hpp"
#include "../extern/doctest.hpp"
TEST_CASE("When throwing exception, what() is readable", "[Utilities][Exception]") {
TEST_CASE("When throwing exception, what() is readable") {
bool hasCaught = false;
try {
THROW("foobar");
} catch (const ArbUt::Exception& e) {
hasCaught = true;
INFO(e.what());
REQUIRE(std::string(e.what()) == "[ExceptionTests.cpp:10] foobar");
REQUIRE(std::string(e.what()) == "[ExceptionTests.cpp:9] foobar");
}
REQUIRE(hasCaught);
}
TEST_CASE("C Interface exception", "[Utilities][Exception]") {
TEST_CASE("C Interface exception") {
ExceptionHandler::SetLastArbUtException("foo", ArbUt::Exception("foobar"), 1);
REQUIRE(std::string(ExceptionHandler::GetLastException()) == "[foo] foobar");

View File

@ -1,5 +1,5 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../../src/Battling/Models/Battle.hpp"
#include "../../src/Battling/Models/BattleParty.hpp"
#include "../../src/Battling/Models/CreateCreature.hpp"
@ -11,7 +11,7 @@
using namespace CreatureLib;
using namespace Battling;
TEST_CASE("Create Party", "[Integrations]") {
TEST_CASE("Create Party") {
auto library = TestLibrary::Get();
auto c1 =
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
@ -20,7 +20,7 @@ TEST_CASE("Create Party", "[Integrations]") {
REQUIRE(battleParty.GetParty()->GetAtIndex(0) == c1);
}
TEST_CASE("Create Battle", "[Integrations]") {
TEST_CASE("Create Battle") {
auto library = TestLibrary::Get();
auto c1 =
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
@ -34,7 +34,7 @@ TEST_CASE("Create Battle", "[Integrations]") {
auto battle = Battle(library, {battleParty1, battleParty2});
}
TEST_CASE("Use damaging move", "[Integrations]") {
TEST_CASE("Use damaging move") {
auto library = TestLibrary::Get();
auto c1 =
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
@ -56,7 +56,7 @@ TEST_CASE("Use damaging move", "[Integrations]") {
REQUIRE(c2->GetCurrentHealth() < c2->GetBoostedStat(Statistic::Health));
}
TEST_CASE("Run more turns", "[Integrations]") {
TEST_CASE("Run more turns") {
auto library = TestLibrary::Get();
auto c1 =
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
@ -83,7 +83,7 @@ TEST_CASE("Run more turns", "[Integrations]") {
battle.TrySetChoice(new PassTurnChoice(c3));
}
TEST_CASE("Finish battle when all battle of one side have fainted", "[Integrations]") {
TEST_CASE("Finish battle when all battle of one side have fainted") {
auto library = TestLibrary::Get();
auto c1 =
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
@ -117,7 +117,7 @@ TEST_CASE("Finish battle when all battle of one side have fainted", "[Integratio
REQUIRE(result.GetWinningSide() == 0);
}
TEST_CASE("When creature is dealt enough damage, faint it and mark battle as ended", "[Integrations]") {
TEST_CASE("When creature is dealt enough damage, faint it and mark battle as ended") {
auto library = TestLibrary::Get();
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
@ -147,7 +147,7 @@ TEST_CASE("When creature is dealt enough damage, faint it and mark battle as end
REQUIRE(result.GetWinningSide() == 0);
}
TEST_CASE("When another creature is available on faint, make sure the battle hasn't ended", "[Integrations]") {
TEST_CASE("When another creature is available on faint, make sure the battle hasn't ended") {
auto library = TestLibrary::Get();
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
@ -186,7 +186,7 @@ TEST_CASE("When another creature is available on faint, make sure the battle has
REQUIRE(result.GetWinningSide() == 0);
}
TEST_CASE("Switch Creature in", "[Integrations]") {
TEST_CASE("Switch Creature in") {
auto library = TestLibrary::Get();
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
@ -213,7 +213,7 @@ TEST_CASE("Switch Creature in", "[Integrations]") {
REQUIRE(battle.GetCreature(CreatureIndex(0, 0)) == c2);
}
TEST_CASE("Switch Creature in with event listener", "[Integrations]") {
TEST_CASE("Switch Creature in with event listener") {
auto library = TestLibrary::Get();
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
@ -244,7 +244,7 @@ TEST_CASE("Switch Creature in with event listener", "[Integrations]") {
REQUIRE(battle.GetCreature(CreatureIndex(0, 0)) == c2);
}
TEST_CASE("Switch Creature in, but have attack aimed at it. Attack should hit new creature", "[Integrations]") {
TEST_CASE("Switch Creature in, but have attack aimed at it. Attack should hit new creature") {
auto library = TestLibrary::Get();
auto c1 =
CreateCreature(library, "testSpecies1"_cnc, 50).WithAttack("standard"_cnc, AttackLearnMethod::Unknown).Create();
@ -269,7 +269,7 @@ TEST_CASE("Switch Creature in, but have attack aimed at it. Attack should hit ne
REQUIRE(c1->GetCurrentHealth() == c1->GetBoostedStat(Library::Statistic::Health));
}
TEST_CASE("Switch Creature in, mark as seen opponent for opponent", "[Integrations]") {
TEST_CASE("Switch Creature in, mark as seen opponent for opponent") {
auto library = TestLibrary::Get();
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)
@ -309,7 +309,7 @@ TEST_CASE("Switch Creature in, mark as seen opponent for opponent", "[Integratio
REQUIRE(seen.contains(c2));
}
TEST_CASE("Flee Battle", "[Integrations]") {
TEST_CASE("Flee Battle") {
auto library = TestLibrary::Get();
auto c1 = CreateCreature(library, "testSpecies1"_cnc, 100)
.WithAttack("standard"_cnc, AttackLearnMethod::Unknown)

View File

@ -1,10 +1,10 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../../src/Library/BaseLibrary.hpp"
#include "../TestLibrary/TestLibrary.hpp"
using namespace CreatureLib::Library;
TEST_CASE("Iterate over library", "[Library]") {
TEST_CASE("Iterate over library") {
auto& lib = TestLibrary::Get()->GetSpeciesLibrary();
auto i = 0;
for (auto b : *lib) {

View File

@ -1,29 +1,29 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../../src/Library/EffectParameter.hpp"
using namespace CreatureLib::Library;
TEST_CASE("Bool EffectParameter", "[Library]") {
TEST_CASE("Bool EffectParameter") {
auto p = EffectParameter(true);
REQUIRE(p.AsBool());
auto p2 = EffectParameter(false);
REQUIRE_FALSE(p2.AsBool());
}
TEST_CASE("Int EffectParameter", "[Library]") {
TEST_CASE("Int EffectParameter") {
auto p = EffectParameter((int64_t)684);
REQUIRE(p.AsInt() == 684);
REQUIRE(p.AsFloat() == 684);
}
TEST_CASE("String EffectParameter", "[Library]") {
TEST_CASE("String EffectParameter") {
auto p = EffectParameter((ArbUt::StringView) "foobar"_cnc);
REQUIRE(p.AsString() == "foobar");
}
TEST_CASE("Float EffectParameter", "[Library]") {
TEST_CASE("Float EffectParameter") {
auto p = EffectParameter(1.5f);
REQUIRE(p.AsFloat() == Approx(1.5f));
REQUIRE(p.AsFloat() == doctest::Approx(1.5f));
REQUIRE(p.AsInt() == 1);
}

View File

@ -1,11 +1,11 @@
#ifdef TESTS_BUILD
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../../src/Library/CreatureData/CreatureSpecies.hpp"
using namespace CreatureLib::Library;
TEST_CASE("Set Variant", "[Library]") {
TEST_CASE("Set Variant") {
auto defaultVariant = new SpeciesVariant("default", 0, 0, 0, {0, 1}, StatisticSet<uint16_t>(), {}, {}, nullptr);
auto c = CreatureSpecies(0, "foo", defaultVariant, 0, "", 0);
auto secondVariant = new SpeciesVariant("second", 0, 0, 0, {0, 1}, StatisticSet<uint16_t>(), {}, {}, nullptr);

View File

@ -1,34 +1,34 @@
#ifdef TESTS_BUILD
#define CATCH_CONFIG_MAIN
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
#include "../../extern/catch.hpp"
#include "../../extern/doctest.hpp"
#include "../TestLibrary/TestLibrary.hpp"
TEST_CASE("Can Create Species Library", "[Library]") {
TEST_CASE("Can Create Species Library") {
auto l = TestLibrary::BuildSpeciesLibrary();
REQUIRE(l != nullptr);
delete l;
}
TEST_CASE("Can Create Attack Library", "[Library]") {
TEST_CASE("Can Create Attack Library") {
auto l = TestLibrary::BuildAttackLibrary();
REQUIRE(l != nullptr);
delete l;
}
TEST_CASE("Can Create Item Library", "[Library]") {
TEST_CASE("Can Create Item Library") {
auto l = TestLibrary::BuildItemLibrary();
REQUIRE(l != nullptr);
delete l;
}
TEST_CASE("Can Create Growth Rate Library", "[Library]") {
TEST_CASE("Can Create Growth Rate Library") {
auto l = TestLibrary::BuildGrowthRateLibrary();
REQUIRE(l != nullptr);
delete l;
}
TEST_CASE("Can Create Data Library", "[Library]") {
TEST_CASE("Can Create Data Library") {
auto l = TestLibrary::Get();
REQUIRE(l != nullptr);
}