fix: don't post contents of unknown commands to chat (#6272)

This commit is contained in:
pajlada
2025-06-15 15:46:24 +02:00
committed by GitHub
parent 7f9dfd4aea
commit f26d6d57de
9 changed files with 126 additions and 20 deletions
+53
View File
@@ -0,0 +1,53 @@
#include "providers/twitch/TwitchChannel.hpp"
#include "Test.hpp"
#include <QString>
#include <vector>
namespace chatterino::detail {
TEST(TwitchChannelDetail_isUnknownCommand, good)
{
// clang-format off
std::vector<QString> cases{
"/me hello",
".me hello",
"/ hello",
". hello",
"/ /hello",
". .hello",
"/ .hello",
". /hello",
};
// clang-format on
for (const auto &input : cases)
{
ASSERT_FALSE(isUnknownCommand(input))
<< input << " should not be considered an unknown command";
}
}
TEST(TwitchChannelDetail_isUnknownCommand, bad)
{
// clang-format off
std::vector<QString> cases{
"/badcommand",
".badcommand",
"/badcommand hello",
".badcommand hello",
"/@badcommand hello",
".@badcommand hello",
};
// clang-format on
for (const auto &input : cases)
{
ASSERT_TRUE(isUnknownCommand(input))
<< input << " should be considered an unknown command";
}
}
} // namespace chatterino::detail