summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2024-01-05 21:17:19 +0100
committerSébastien Helleu <flashcode@flashtux.org>2024-01-05 21:36:58 +0100
commit57a206287a805900628a2b8f863f3f1488c6ab9a (patch)
tree335afa201bd8c7f7ed8791208f7ea63c808b2848 /tests/unit
parenteb8ca14d8373557e812f107b6c458656658345b1 (diff)
downloadweechat-57a206287a805900628a2b8f863f3f1488c6ab9a.zip
irc: fix display of self messages in case of message split failure
When the message sends inconsistent max lengths in message 005, the split of self message fails and causes a display issue: the channel name is displayed with the message: nick | #channel :this is a test instead of: nick | this is a test
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/plugins/irc/test-irc-message.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/plugins/irc/test-irc-message.cpp b/tests/unit/plugins/irc/test-irc-message.cpp
index e3e6b4c9f..aed8d4fe8 100644
--- a/tests/unit/plugins/irc/test-irc-message.cpp
+++ b/tests/unit/plugins/irc/test-irc-message.cpp
@@ -1137,6 +1137,7 @@ TEST(IrcMessage, Split)
struct t_hashtable *hashtable;
const char *ptr_msg, *pos1, *pos2;
char batch_ref[512], msg[4096];
+ int old_nick_max_length;
server = irc_server_alloc ("test_split_msg");
CHECK(server);
@@ -1552,6 +1553,21 @@ TEST(IrcMessage, Split)
(const char *)hashtable_get (hashtable, "args1"));
hashtable_free (hashtable);
+ /* PRIVMSG with small content but inconsistent max length: no split */
+ old_nick_max_length = server->nick_max_length;
+ server->nick_max_length = 4096;
+ hashtable = irc_message_split (server, "PRIVMSG #channel :test");
+ CHECK(hashtable);
+ LONGS_EQUAL(3, hashtable->items_count);
+ STRCMP_EQUAL("1",
+ (const char *)hashtable_get (hashtable, "count"));
+ STRCMP_EQUAL("PRIVMSG #channel :test",
+ (const char *)hashtable_get (hashtable, "msg1"));
+ STRCMP_EQUAL("test",
+ (const char *)hashtable_get (hashtable, "args1"));
+ hashtable_free (hashtable);
+ server->nick_max_length = old_nick_max_length;
+
/* PRIVMSG with 512 bytes of content: 1 split */
hashtable = irc_message_split (server,
"PRIVMSG #channel :" LOREM_IPSUM_512);