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

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

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);