summaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-06-12 21:18:42 +0200
committerSébastien Helleu <flashcode@flashtux.org>2021-06-15 18:56:41 +0200
commit70b66c4f6b708269712f71c52d7ca0c2d6766b94 (patch)
treeedaa5c72d3ce32268531237bbfbb1e15a7839652 /tests/unit
parent0525922ee4b50911c44b1c4d5b79c19a5f0660ee (diff)
downloadweechat-70b66c4f6b708269712f71c52d7ca0c2d6766b94.zip
irc: add command /setname, add support of message and capability "setname" (closes #1653)
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/plugins/irc/test-irc-protocol.cpp50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp
index 596a040aa..6b9f2a7e2 100644
--- a/tests/unit/plugins/irc/test-irc-protocol.cpp
+++ b/tests/unit/plugins/irc/test-irc-protocol.cpp
@@ -1259,6 +1259,56 @@ TEST(IrcProtocolWithServer, quit)
/*
* Tests functions:
+ * irc_protocol_cb_setname (without setname capability)
+ */
+
+TEST(IrcProtocolWithServer, setname_without_setname_cap)
+{
+ struct t_irc_nick *ptr_nick;
+
+ server_recv (":server 001 alice");
+ server_recv (":alice!user@host JOIN #test");
+
+ ptr_nick = ptr_server->channels->nicks;
+
+ POINTERS_EQUAL(NULL, ptr_nick->realname);
+
+ /* not enough arguments */
+ server_recv (":alice!user@host SETNAME");
+ POINTERS_EQUAL(NULL, ptr_nick->realname);
+
+ server_recv (":alice!user@host SETNAME :new realname");
+ POINTERS_EQUAL(NULL, ptr_nick->realname);
+}
+
+/*
+ * Tests functions:
+ * irc_protocol_cb_setname (with setname capability)
+ */
+
+TEST(IrcProtocolWithServer, setname_with_setname_cap)
+{
+ struct t_irc_nick *ptr_nick;
+
+ /* assume "setname" capability is enabled in server */
+ hashtable_set (ptr_server->cap_list, "setname", NULL);
+
+ server_recv (":server 001 alice");
+ server_recv (":alice!user@host JOIN #test");
+
+ ptr_nick = ptr_server->channels->nicks;
+
+ POINTERS_EQUAL(NULL, ptr_nick->realname);
+
+ server_recv (":alice!user@host SETNAME :new realname");
+ STRCMP_EQUAL("new realname", ptr_nick->realname);
+
+ server_recv (":alice!user@host SETNAME :new realname2");
+ STRCMP_EQUAL("new realname2", ptr_nick->realname);
+}
+
+/*
+ * Tests functions:
* irc_protocol_cb_topic
*/