diff options
author | Treeston <treeston.mmoc@gmail.com> | 2020-08-30 02:50:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-30 02:50:25 +0200 |
commit | 2f7d2ef3e979ecd0536f3a3713e56c8e59652a47 (patch) | |
tree | b2d6805fcf1bbaae435b87b4d4713cd2cd772e77 /tests | |
parent | c08180d9bc7cb203746650a9b2fc775efbeb2540 (diff) |
Core/ChatCommands: C++17 cleanup (again) (PR #25323)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/game/ChatCommand.cpp | 58 |
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; - } - ); + }); + } } |