mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
[3.3.5] Core/ChatCommands: Show error messages from argument parsers (PR #25443)
(cherry picked from commit 75f9e7396e)
This commit is contained in:
@@ -17,15 +17,24 @@
|
||||
|
||||
#include "tc_catch2.h"
|
||||
|
||||
#include "Chat.h"
|
||||
#include "ChatCommand.h"
|
||||
|
||||
using namespace Trinity::ChatCommands;
|
||||
using namespace std::string_view_literals;
|
||||
|
||||
struct DummyChatHandler : ChatHandler
|
||||
{
|
||||
DummyChatHandler() : ChatHandler(nullptr) {}
|
||||
void SendSysMessage(std::string_view, bool) override {}
|
||||
char const* GetTrinityString(uint32) const override { return ""; }
|
||||
};
|
||||
|
||||
template <typename F>
|
||||
static void TestChatCommand(char const* c, F f, Optional<bool> expected = true)
|
||||
{
|
||||
bool r = ChatCommand("", 0, false, +f, "")(nullptr, c);
|
||||
DummyChatHandler handler;
|
||||
bool r = ChatCommand("", 0, false, +f, "")(&handler, c);
|
||||
if (expected)
|
||||
REQUIRE(r == *expected);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user