From 1eca51b417678b9a48b28552925d5694105f82bb Mon Sep 17 00:00:00 2001 From: Treeston Date: Sun, 20 Sep 2020 02:50:38 +0200 Subject: [3.3.5] ChatCommands, the other half: chat command resolution refactor (PR #25463) --- tests/game/ChatCommand.cpp | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/game/ChatCommand.cpp b/tests/game/ChatCommand.cpp index af5cfd783ad..ddf5bf32d08 100644 --- a/tests/game/ChatCommand.cpp +++ b/tests/game/ChatCommand.cpp @@ -31,10 +31,10 @@ struct DummyChatHandler : ChatHandler }; template -static void TestChatCommand(char const* c, F f, Optional expected = true) +static void TestChatCommand(std::string_view c, F f, Optional expected = true) { DummyChatHandler handler; - bool r = ChatCommand("", 0, false, +f, "")(&handler, c); + bool r = Trinity::Impl::ChatCommands::CommandInvoker(*+f)(&handler, c); if (expected) REQUIRE(r == *expected); } @@ -111,4 +111,26 @@ TEST_CASE("Command argument parsing", "[ChatCommand]") return true; }); } + + SECTION("Variant<>") + { + TestChatCommand("0x1ffff", [](ChatHandler*, Variant v) + { + REQUIRE(v.holds_alternative()); + REQUIRE(v.get() == 0x1ffff); + return true; + }); + TestChatCommand("0xffff", [](ChatHandler*, Variant v) + { + REQUIRE(v.holds_alternative()); + REQUIRE(v.get() == 0xffff); + return true; + }); + TestChatCommand("0x1ffff", [](ChatHandler*, Variant v) + { + REQUIRE(v.holds_alternative()); + REQUIRE(v.get() == 0x1ffff); + return true; + }); + } } -- cgit v1.2.3