aboutsummaryrefslogtreecommitdiff
path: root/tests/game/ChatCommand.cpp
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2020-09-20 02:50:38 +0200
committerShauren <shauren.trinity@gmail.com>2022-02-27 20:08:41 +0100
commit3fd2eb126cbed36292fa5defc024c2b93e8d8671 (patch)
tree6068f6e874d7552fcf00a92ca75a85381323a038 /tests/game/ChatCommand.cpp
parent7a2c3af98831364988db25dd1bdd8ca10464c641 (diff)
[3.3.5] ChatCommands, the other half: chat command resolution refactor (PR #25463)
(cherry picked from commit 1eca51b417678b9a48b28552925d5694105f82bb)
Diffstat (limited to 'tests/game/ChatCommand.cpp')
-rw-r--r--tests/game/ChatCommand.cpp26
1 files changed, 24 insertions, 2 deletions
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 <typename F>
-static void TestChatCommand(char const* c, F f, Optional<bool> expected = true)
+static void TestChatCommand(std::string_view c, F f, Optional<bool> 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<uint16, uint32> v)
+ {
+ REQUIRE(v.holds_alternative<uint32>());
+ REQUIRE(v.get<uint32>() == 0x1ffff);
+ return true;
+ });
+ TestChatCommand("0xffff", [](ChatHandler*, Variant<uint16, uint32> v)
+ {
+ REQUIRE(v.holds_alternative<uint16>());
+ REQUIRE(v.get<uint16>() == 0xffff);
+ return true;
+ });
+ TestChatCommand("0x1ffff", [](ChatHandler*, Variant<uint32, uint16> v)
+ {
+ REQUIRE(v.holds_alternative<uint32>());
+ REQUIRE(v.get<uint32>() == 0x1ffff);
+ return true;
+ });
+ }
}