fix: don't post contents of unknown commands to chat (#6272)
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user