From 283c9d7ccffbcae0eee8fb3693597973b2fca55a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Sun, 14 May 2023 14:09:49 +0200 Subject: irc: do not allow send of empty messages (single line or multiline) --- tests/unit/plugins/irc/test-irc-message.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/unit/plugins') 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 @@ -946,6 +946,24 @@ convert_irc_charset_cb (const void *pointer, void *data, return new_string; } +/* + * 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); -- cgit v1.2.3