summaryrefslogtreecommitdiff
path: root/tests/unit/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2023-05-14 14:09:49 +0200
committerSébastien Helleu <flashcode@flashtux.org>2023-05-14 15:32:47 +0200
commit283c9d7ccffbcae0eee8fb3693597973b2fca55a (patch)
tree97f7ad62e533a223c2ff92a7ad8cf642def90644 /tests/unit/plugins
parentac83130dd7a42134551381b86e4bb47bbc24b3c1 (diff)
downloadweechat-283c9d7ccffbcae0eee8fb3693597973b2fca55a.zip
irc: do not allow send of empty messages (single line or multiline)
Diffstat (limited to 'tests/unit/plugins')
-rw-r--r--tests/unit/plugins/irc/test-irc-message.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/unit/plugins/irc/test-irc-message.cpp b/tests/unit/plugins/irc/test-irc-message.cpp
index 39a232c5a..3939060e9 100644
--- a/tests/unit/plugins/irc/test-irc-message.cpp
+++ b/tests/unit/plugins/irc/test-irc-message.cpp
@@ -948,6 +948,24 @@ convert_irc_charset_cb (const void *pointer, void *data,
/*
* Tests functions:
+ * irc_message_is_empty
+ */
+
+TEST(IrcMessage, IsEmpty)
+{
+ LONGS_EQUAL(1, irc_message_is_empty (NULL));
+ LONGS_EQUAL(1, irc_message_is_empty (""));
+ LONGS_EQUAL(1, irc_message_is_empty ("\n"));
+ LONGS_EQUAL(1, irc_message_is_empty ("\n\n\n\n\n\n\n\n"));
+
+ LONGS_EQUAL(0, irc_message_is_empty (" "));
+ LONGS_EQUAL(0, irc_message_is_empty ("\n "));
+ LONGS_EQUAL(0, irc_message_is_empty ("\n \n"));
+ LONGS_EQUAL(0, irc_message_is_empty ("test"));
+}
+
+/*
+ * Tests functions:
* irc_message_convert_charset
*/
@@ -1516,6 +1534,12 @@ TEST(IrcMessage, Split)
(const char *)hashtable_get (hashtable, "msg1"));
hashtable_free (hashtable);
+ /* PRIVMSG with no content: no split (not allowed) */
+ hashtable = irc_message_split (server, "PRIVMSG #channel :");
+ CHECK(hashtable);
+ LONGS_EQUAL(0, hashtable->items_count);
+ hashtable_free (hashtable);
+
/* PRIVMSG with small content: no split */
hashtable = irc_message_split (server, "PRIVMSG #channel :test");
CHECK(hashtable);