diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/DummyData.cpp | 21 | ||||
-rw-r--r-- | tests/DummyData.h | 37 | ||||
-rw-r--r-- | tests/game/Hyperlinks.cpp | 18 |
3 files changed, 76 insertions, 0 deletions
diff --git a/tests/DummyData.cpp b/tests/DummyData.cpp index e5d0427e908..4d89a2b02aa 100644 --- a/tests/DummyData.cpp +++ b/tests/DummyData.cpp @@ -17,6 +17,7 @@ #include "DummyData.h" +#include "DB2Stores.h" #include "ItemDefines.h" #include "ItemTemplate.h" #include "ObjectMgr.h" @@ -56,3 +57,23 @@ const_cast<ItemSparseEntry*>(t.ExtendedData)->OverallQualityID = ITEM_QUALITY_NORMAL; SetItemLocale(6948, LOCALE_esMX, "Piedra de hogar"); } + +static UnitTestDataLoader::DB2<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.Str.fill(""); + toc5.Title.Str[LOCALE_enUS] = "Heroic: Trial of the Champion"; + toc5.Title.Str[LOCALE_esES] = "Heroico: Prueba del Campe\xc3\xb3n"; + toc5.Title.Str[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..35ec4d62e86 100644 --- a/tests/DummyData.h +++ b/tests/DummyData.h @@ -20,6 +20,7 @@ #include "Common.h" #include "Define.h" +#include "DB2Store.h" #include <string_view> @@ -28,6 +29,42 @@ struct ItemTemplate; class UnitTestDataLoader { public: + template <typename T, uint32 T::*ID> + class DB2 + { + class LoaderGuard + { + public: + LoaderGuard(DB2& d) : _d(d) {} + ~LoaderGuard() { _d.Dump(); } + + T& Add() { return _d._storage.emplace_back(); } + private: + DB2& _d; + }; + + public: + DB2(DB2Storage<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; + DB2Storage<T>& _store; + }; + + static void LoadAchievementTemplates(); static void LoadItemTemplates(); private: diff --git a/tests/game/Hyperlinks.cpp b/tests/game/Hyperlinks.cpp index 7a1c3821a2c..a4f01a37992 100644 --- a/tests/game/Hyperlinks.cpp +++ b/tests/game/Hyperlinks.cpp @@ -72,3 +72,21 @@ TEST_CASE("|Hitem validation", "[Hyperlinks]") REQUIRE(false == CheckAllLinks("This is a |cffffffff|Hitem:6948:-1:::::::60:::::|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:Player-0-000000FD: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:Player-0-000000FD:0:0:0:-1:0:0:0:0|h[Heroic: Trial of the Champion]|h|r")); + REQUIRE(false == CheckAllLinks("|cffff0000|Hachievement:4298:Player-0-000000FD: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:Player-0-000000FD:1:12:20:12:0:0:0:0|h[Heroic: Trial of the Champion]|h|r")); + REQUIRE(false == CheckAllLinks("|cffffff00|Hachievement:4298:Player-0-000000FD:1:12:40:12:0:0:0:0|h[Heroic: Trial of the Champion]|h|r")); + REQUIRE(false == CheckAllLinks("|cffffff00|Hachievement:4298:Player-0-000000FD:1:14:20:12:0:0:0:0|h[Heroic: Trial of the Champion]|h|r")); + REQUIRE(false == CheckAllLinks("|cffffff00|Hachievement:4298:Player-0-000000FD:1:0:0:-1:0:0:0:0|h[Heroic: Trial of the Champion]|h|r")); + + REQUIRE(true == CheckAllLinks("|cffffff00|Hachievement:4298:Player-0-000000FD:1:12:20:12:0:0:0:0|h[Heroico: Prueba del Campe\xc3\xb3n]|h|r")); +} |