aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2020-08-30 02:50:25 +0200
committerShauren <shauren.trinity@gmail.com>2022-02-04 21:21:17 +0100
commit45e9e943115badd1a10ce18dc660408564e4aac9 (patch)
tree3e573ba9d5da2c8eada7c71f923b5fcdc814459c /tests
parent175fb7056b32d5455b59d83cc0f46fc55d905307 (diff)
Core/ChatCommands: C++17 cleanup (again) (PR #25323)
(cherry picked from commit 2f7d2ef3e979ecd0536f3a3713e56c8e59652a47)
Diffstat (limited to 'tests')
-rw-r--r--tests/game/ChatCommand.cpp58
1 files changed, 41 insertions, 17 deletions
diff --git a/tests/game/ChatCommand.cpp b/tests/game/ChatCommand.cpp
index 5aab641deba..f484b5806c5 100644
--- a/tests/game/ChatCommand.cpp
+++ b/tests/game/ChatCommand.cpp
@@ -27,7 +27,7 @@ static void TestChatCommand(char const* c, F f, Optional<bool> expected = true)
{
bool r = ChatCommand("", 0, false, +f, "")(nullptr, c);
if (expected)
- ASSERT(r == *expected);
+ REQUIRE(r == *expected);
}
TEST_CASE("Command return pass-through", "[ChatCommand]")
@@ -38,27 +38,51 @@ TEST_CASE("Command return pass-through", "[ChatCommand]")
TEST_CASE("Command argument parsing", "[ChatCommand]")
{
- TestChatCommand("42", [](ChatHandler*, uint32 u)
+ SECTION("Single uint32 argument")
{
- REQUIRE(u == 42);
- return true;
- });
+ TestChatCommand("42", [](ChatHandler*, uint32 u)
+ {
+ REQUIRE(u == 42);
+ return true;
+ });
+ TestChatCommand("true", [](ChatHandler*, uint32) { return true; }, false);
+ }
- TestChatCommand("true", [](ChatHandler*, uint32) { return true; }, false);
+ SECTION("std::vector<uint8>")
+ {
+ TestChatCommand("1 2 3 4 5 6 7 8 9 10", [](ChatHandler*, std::vector<uint8> v)
+ {
+ REQUIRE(v.size() == 10);
+ for (size_t i = 0; i < 10; ++i)
+ REQUIRE(v[i] == (i + 1));
+ return true;
+ });
+ }
- TestChatCommand("1 2 3 4 5 6 7 8 9 10", [](ChatHandler*, std::vector<uint8> v)
+ SECTION("Hyperlink<player>")
{
- REQUIRE(v.size() == 10);
- for (size_t i = 0; i < 10; ++i)
- REQUIRE(v[i] == (i + 1));
- return true;
- });
+ TestChatCommand("|cffff0000|Hplayer:Test|h[Test]|h|r",
+ [](ChatHandler*, Hyperlink<player> player)
+ {
+ REQUIRE("Test"sv == *player);
+ return true;
+ }
+ );
+ }
- TestChatCommand("|cffff0000|Hplayer:Test|h[Test]|h|r",
- [](ChatHandler*, Hyperlink<player> player)
+ SECTION("Two strings")
+ {
+ TestChatCommand("two strings", [](ChatHandler*, std::string_view v1, std::string_view v2)
+ {
+ REQUIRE(v1 == "two");
+ REQUIRE(v2 == "strings");
+ return true;
+ });
+ TestChatCommand("two strings", [](ChatHandler*, std::string_view) { return true; }, false);
+ TestChatCommand("two strings", [](ChatHandler*, Tail t)
{
- REQUIRE("Test"sv == *player);
+ REQUIRE(t == "two strings");
return true;
- }
- );
+ });
+ }
}