aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2020-09-01 00:38:46 +0200
committerGitHub <noreply@github.com>2020-09-01 00:38:46 +0200
commit3fbbe7cfbe1bc51db12bdc1ec7b21c16d1716366 (patch)
treedfeb5042850efebde2c1ad79ca2db85f1da45d0f /tests
parentb2895f31ec835e24d7e30944dc2fc8c5853e10dd (diff)
Core/Misc: DBC std::array refactors, and |Hachievement unit tests
Diffstat (limited to 'tests')
-rw-r--r--tests/DummyData.cpp23
-rw-r--r--tests/DummyData.h37
-rw-r--r--tests/game/Hyperlinks.cpp20
3 files changed, 78 insertions, 2 deletions
diff --git a/tests/DummyData.cpp b/tests/DummyData.cpp
index 916edb0accd..b6b70363bc7 100644
--- a/tests/DummyData.cpp
+++ b/tests/DummyData.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
@@ -17,6 +17,7 @@
#include "DummyData.h"
+#include "AchievementMgr.h"
#include "ItemDefines.h"
#include "ItemTemplate.h"
#include "ObjectMgr.h"
@@ -127,3 +128,23 @@
SetItemLocale(6948, LocaleConstant::LOCALE_esMX, "Piedra de hogar");
}
+
+static UnitTestDataLoader::DBC<AchievementEntry, &AchievementEntry::ID> achievements(sAchievementStore);
+/*static*/ void UnitTestDataLoader::LoadAchievementTemplates()
+{
+ auto loader = achievements.Loader();
+
+ AchievementEntry& toc5 = loader.Add();
+ toc5.ID = 4298;
+ toc5.Faction = 1;
+ toc5.InstanceID = 650;
+ toc5.Title.fill("");
+ toc5.Title[LOCALE_enUS] = "Heroic: Trial of the Champion";
+ toc5.Title[LOCALE_esES] = "Heroico: Prueba del Campe\xc3\xb3n";
+ toc5.Title[LOCALE_esMX] = "Heroico: Prueba del Campe\xc3\xb3n";
+ toc5.Category = 14921;
+ toc5.Points = 10;
+ toc5.Flags = 0;
+ toc5.MinimumCriteria = 0;
+ toc5.SharesCriteria = 0;
+}
diff --git a/tests/DummyData.h b/tests/DummyData.h
index 98812d3b6b8..f1cf76c073a 100644
--- a/tests/DummyData.h
+++ b/tests/DummyData.h
@@ -20,6 +20,7 @@
#include "Common.h"
#include "Define.h"
+#include "DBCStore.h"
#include <string_view>
@@ -28,6 +29,42 @@ struct ItemTemplate;
class UnitTestDataLoader
{
public:
+ template <typename T, uint32 T::*ID>
+ class DBC
+ {
+ class LoaderGuard
+ {
+ public:
+ LoaderGuard(DBC& d) : _d(d) {}
+ ~LoaderGuard() { _d.Dump(); }
+
+ T& Add() { return _d._storage.emplace_back(); }
+ private:
+ DBC& _d;
+ };
+
+ public:
+ DBC(DBCStorage<T>& store) : _store(store) {}
+ LoaderGuard Loader() { return {*this}; }
+ void Dump()
+ {
+ delete[] _store._indexTable.AsT;
+ for (T const& entry : _storage)
+ if (entry.*ID >= _store._indexTableSize)
+ _store._indexTableSize = entry.*ID + 1;
+ _store._indexTable.AsT = new T*[_store._indexTableSize];
+ for (size_t i = 0; i < _store._indexTableSize; ++i)
+ _store._indexTable.AsT[i] = nullptr;
+ for (T& entry : _storage)
+ _store._indexTable.AsT[entry.*ID] = &entry;
+ }
+
+ private:
+ std::vector<T> _storage;
+ DBCStorage<T>& _store;
+ };
+
+ static void LoadAchievementTemplates();
static void LoadItemTemplates();
private:
diff --git a/tests/game/Hyperlinks.cpp b/tests/game/Hyperlinks.cpp
index e7ac5287f74..4648d295328 100644
--- a/tests/game/Hyperlinks.cpp
+++ b/tests/game/Hyperlinks.cpp
@@ -1,4 +1,4 @@
-/*
+/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
@@ -72,3 +72,21 @@ TEST_CASE("|Hitem validation", "[Hyperlinks]")
REQUIRE(false == CheckAllLinks("This is a |cffffffff|Hitem:6948:-1:0:0:0:0:0:0:-1|h[Hearthstone]|h|r that is quite negative."));
}
}
+
+TEST_CASE("|Hachievement validation", "[Hyperlinks]")
+{
+ UnitTestDataLoader::LoadAchievementTemplates();
+ sWorld->setIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY, 1);
+
+ REQUIRE(true == CheckAllLinks("|cffffff00|Hachievement:4298:00000000000000FD:0:0:0:-1:0:0:0:0|h[Heroic: Trial of the Champion]|h|r"));
+ REQUIRE(false == CheckAllLinks("|cffffff00|Hachievement|h[Heroic: Trial of the Champion]|h|r"));
+ REQUIRE(false == CheckAllLinks("|cffffff00|Hachievement:1:00000000000000FD:0:0:0:-1:0:0:0:0|h[Heroic: Trial of the Champion]|h|r"));
+ REQUIRE(false == CheckAllLinks("|cffff0000|Hachievement:4298:00000000000000FD:0:0:0:-1:0:0:0:0|h[Heroic: Trial of the Champion]|h|r"));
+ REQUIRE(false == CheckAllLinks("|cffffff00|Hachievement:4298:00000000000000XY:0:0:0:-1:0:0:0:0|h[Heroic: Trial of the Champion]|h|r"));
+ REQUIRE(true == CheckAllLinks("|cffffff00|Hachievement:4298:00000000000000FD:1:12:20:12:0:0:0:0|h[Heroic: Trial of the Champion]|h|r"));
+ REQUIRE(false == CheckAllLinks("|cffffff00|Hachievement:4298:00000000000000FD:1:12:40:12:0:0:0:0|h[Heroic: Trial of the Champion]|h|r"));
+ REQUIRE(false == CheckAllLinks("|cffffff00|Hachievement:4298:00000000000000FD:1:14:20:12:0:0:0:0|h[Heroic: Trial of the Champion]|h|r"));
+ REQUIRE(false == CheckAllLinks("|cffffff00|Hachievement:4298:00000000000000FD:1:0:0:-1:0:0:0:0|h[Heroic: Trial of the Champion]|h|r"));
+
+ REQUIRE(true == CheckAllLinks("|cffffff00|Hachievement:4298:00000000000000FD:1:12:20:12:0:0:0:0|h[Heroico: Prueba del Campe\xc3\xb3n]|h|r"));
+}