aboutsummaryrefslogtreecommitdiff
path: root/tests/game
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2020-08-31 16:56:56 +0200
committerShauren <shauren.trinity@gmail.com>2022-02-04 22:11:42 +0100
commitc82b107b6b9e80b9b0d7b08f360d0b54bd6900c5 (patch)
treea41a63c57faa8c4b8541aac19e1e844de180c420 /tests/game
parentc3bd803da3e2d90bba746238fa78e79b40a97a34 (diff)
UnitTests: Add a first set of item hyperlink tests
(cherry picked from commit 5394b2ef0f1c7b48e8886257b93698358abb575f)
Diffstat (limited to 'tests/game')
-rw-r--r--tests/game/Hyperlinks.cpp59
1 files changed, 47 insertions, 12 deletions
diff --git a/tests/game/Hyperlinks.cpp b/tests/game/Hyperlinks.cpp
index ff9062af905..7a1c3821a2c 100644
--- a/tests/game/Hyperlinks.cpp
+++ b/tests/game/Hyperlinks.cpp
@@ -17,23 +17,58 @@
#include "tc_catch2.h"
+#include "DummyData.h"
#include "Hyperlinks.h"
-#include "ChatCommand.h"
+#include "World.h"
using namespace std::string_view_literals;
using namespace Trinity::Hyperlinks;
TEST_CASE("Basic link structure", "[Hyperlinks]")
{
- HyperlinkInfo info = ParseSingleHyperlink("|c12345678|Htag:data1:data2:data3:data4:data5|h[Text]|h|rtail");
- REQUIRE(info.ok);
- REQUIRE(info.color == 0x12345678);
- REQUIRE(info.color.a == 0x12);
- REQUIRE(info.color.r == 0x34);
- REQUIRE(info.color.g == 0x56);
- REQUIRE(info.color.b == 0x78);
- REQUIRE(info.tag == "tag");
- REQUIRE(info.data == "data1:data2:data3:data4:data5");
- REQUIRE(info.text == "Text");
- REQUIRE(info.tail == "tail");
+ SECTION("Link without data")
+ {
+ HyperlinkInfo info = ParseSingleHyperlink("|cabcdef01|HTag|h[text]|h|r");
+ REQUIRE(info.ok);
+ REQUIRE(info.color == 0xabcdef01);
+ REQUIRE(info.color.a == 0xab);
+ REQUIRE(info.color.r == 0xcd);
+ REQUIRE(info.color.g == 0xef);
+ REQUIRE(info.color.b == 0x01);
+ REQUIRE(info.tag == "Tag");
+ REQUIRE(info.data == "");
+ REQUIRE(info.text == "text");
+ REQUIRE(info.tail == "");
+ }
+ SECTION("Link with data")
+ {
+ HyperlinkInfo info = ParseSingleHyperlink("|c12345678|Htag:data1:data2:data3:data4:data5|h[Text]|h|rtail");
+ REQUIRE(info.ok);
+ REQUIRE(info.color == 0x12345678);
+ REQUIRE(info.color.a == 0x12);
+ REQUIRE(info.color.r == 0x34);
+ REQUIRE(info.color.g == 0x56);
+ REQUIRE(info.color.b == 0x78);
+ REQUIRE(info.tag == "tag");
+ REQUIRE(info.data == "data1:data2:data3:data4:data5");
+ REQUIRE(info.text == "Text");
+ REQUIRE(info.tail == "tail");
+ }
+}
+
+TEST_CASE("|Hitem validation", "[Hyperlinks]")
+{
+ UnitTestDataLoader::LoadItemTemplates();
+ sWorld->setIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY, 1);
+
+ SECTION("Basic item link")
+ {
+ REQUIRE(true == CheckAllLinks("This is my |cffffffff|Hitem:6948::::::::60:::::|h[Hearthstone]|h|r. There are many like it, but this one is mine."));
+ REQUIRE(true == CheckAllLinks("Some might call it their |cffffffff|Hitem:6948::::::::60:::::|h[Piedra de hogar]|h|r. They all still take you home."));
+ REQUIRE(false == CheckAllLinks("However, if you call it a |cffffffff|Hitem:6948::::::::60:::::|h|h[Doormat]|h|r, that's a step too far. Get it? Step?"));
+ REQUIRE(false == CheckAllLinks("Or if you try to pronounce |cffffffff|Hitem::::::::::::::|h|h[Cthulhu fhtagn]|h|r. Also too far."));
+ REQUIRE(false == CheckAllLinks("I'm out of witty one-liners. |cffffffff|Hitem|h[This]|h|r is just lacking data."));
+ REQUIRE(false == CheckAllLinks("This is a mis-colored |cffa335ee|Hitem:6948::::::::60:::::|h[Hearthstone]|h|r."));
+ REQUIRE(false == CheckAllLinks("This is a |cffffffff|Hitem:6948:-1:::::::60:::::|h[Hearthstone]|h|r that is quite negative."));
+ }
}