summaryrefslogtreecommitdiff
path: root/tests/unit/plugins/irc
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2022-08-15 18:14:03 +0200
committerSébastien Helleu <flashcode@flashtux.org>2022-08-15 18:14:03 +0200
commite61441081520bcada6de699229ce9af241302665 (patch)
tree36a650c58231e206ef1d4a2c3c28d9c0140dc954 /tests/unit/plugins/irc
parentfb14e67364f603723a48b3622ccf11c89efbe951 (diff)
downloadweechat-e61441081520bcada6de699229ce9af241302665.zip
irc: fix extract of isupport value when it is last in list and without value (closes #1807)
Diffstat (limited to 'tests/unit/plugins/irc')
-rw-r--r--tests/unit/plugins/irc/test-irc-protocol.cpp10
-rw-r--r--tests/unit/plugins/irc/test-irc-server.cpp72
2 files changed, 75 insertions, 7 deletions
diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp
index 5e48bf5d8..8bb918c6c 100644
--- a/tests/unit/plugins/irc/test-irc-protocol.cpp
+++ b/tests/unit/plugins/irc/test-irc-protocol.cpp
@@ -2155,8 +2155,7 @@ TEST(IrcProtocolWithServer, 005_full)
STRCMP_EQUAL("#", ptr_server->chantypes);
STRCMP_EQUAL("eIbq,k,flj,CFLMPQScgimnprstuz", ptr_server->chanmodes);
LONGS_EQUAL(100, ptr_server->monitor);
- CHECK(ptr_server->isupport[0] == ' ');
- STRCMP_EQUAL(IRC_MSG_005, ptr_server->isupport + 1);
+ STRCMP_EQUAL(IRC_MSG_005, ptr_server->isupport);
/* check that realloc of info is OK if we receive the message again */
RECV(":server 005 alice " IRC_MSG_005 " :are supported");
@@ -2171,8 +2170,7 @@ TEST(IrcProtocolWithServer, 005_full)
STRCMP_EQUAL("#", ptr_server->chantypes);
STRCMP_EQUAL("eIbq,k,flj,CFLMPQScgimnprstuz", ptr_server->chanmodes);
LONGS_EQUAL(100, ptr_server->monitor);
- CHECK(ptr_server->isupport[0] == ' ');
- STRCMP_EQUAL(IRC_MSG_005 " " IRC_MSG_005, ptr_server->isupport + 1);
+ STRCMP_EQUAL(IRC_MSG_005 " " IRC_MSG_005, ptr_server->isupport);
}
/*
@@ -2193,12 +2191,12 @@ TEST(IrcProtocolWithServer, 005_multiple_messages)
CHECK_SRV("-- PREFIX=(ohv)@%+ are supported");
STRCMP_EQUAL("ohv", ptr_server->prefix_modes);
STRCMP_EQUAL("@%+", ptr_server->prefix_chars);
- STRCMP_EQUAL(" PREFIX=(ohv)@%+", ptr_server->isupport);
+ STRCMP_EQUAL("PREFIX=(ohv)@%+", ptr_server->isupport);
RECV(":server 005 alice HOSTLEN=24 :are supported");
CHECK_SRV("-- HOSTLEN=24 are supported");
LONGS_EQUAL(24, ptr_server->host_max_length);
- STRCMP_EQUAL(" PREFIX=(ohv)@%+ HOSTLEN=24", ptr_server->isupport);
+ STRCMP_EQUAL("PREFIX=(ohv)@%+ HOSTLEN=24", ptr_server->isupport);
}
/*
diff --git a/tests/unit/plugins/irc/test-irc-server.cpp b/tests/unit/plugins/irc/test-irc-server.cpp
index 3932bf9e3..cf60429c1 100644
--- a/tests/unit/plugins/irc/test-irc-server.cpp
+++ b/tests/unit/plugins/irc/test-irc-server.cpp
@@ -275,7 +275,77 @@ TEST(IrcServer, GetAlternateNick)
TEST(IrcServer, GetIsupportValue)
{
- /* TODO: write tests */
+ struct t_irc_server *server;
+
+ server = irc_server_alloc ("test_clienttagdeny");
+ CHECK(server);
+
+ if (server->isupport)
+ free (server->isupport);
+ server->isupport = strdup ("");
+
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, NULL));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, ""));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "TEST"));
+
+ if (server->isupport)
+ free (server->isupport);
+ server->isupport = strdup ("AWAYLEN=307 BOT=B CASEMAPPING=ascii "
+ "CHANLIMIT=#:10 EMPTY= INVEX KICKLEN=307 WHOX");
+
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, NULL));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, ""));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "xxx"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "AWAYLE"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "WHO"));
+
+ STRCMP_EQUAL("307", irc_server_get_isupport_value (server, "AWAYLEN"));
+ STRCMP_EQUAL("B", irc_server_get_isupport_value (server, "BOT"));
+ STRCMP_EQUAL("ascii", irc_server_get_isupport_value (server, "CASEMAPPING"));
+ STRCMP_EQUAL("#:10", irc_server_get_isupport_value (server, "CHANLIMIT"));
+ STRCMP_EQUAL("", irc_server_get_isupport_value (server, "EMPTY"));
+ STRCMP_EQUAL("", irc_server_get_isupport_value (server, "INVEX"));
+ STRCMP_EQUAL("307", irc_server_get_isupport_value (server, "KICKLEN"));
+ STRCMP_EQUAL("", irc_server_get_isupport_value (server, "WHOX"));
+
+ if (server->isupport)
+ free (server->isupport);
+ server->isupport = strdup ("TEST SECOND");
+
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "T"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "TES"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "EST"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "TESTT"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "SEC"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "COND"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "SECONDD"));
+
+ STRCMP_EQUAL("", irc_server_get_isupport_value (server, "TEST"));
+ STRCMP_EQUAL("", irc_server_get_isupport_value (server, "SECOND"));
+
+ if (server->isupport)
+ free (server->isupport);
+ server->isupport = strdup ("TEST=abc");
+
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "T"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "TES"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "EST"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "TESTT"));
+
+ STRCMP_EQUAL("abc", irc_server_get_isupport_value (server, "TEST"));
+
+ if (server->isupport)
+ free (server->isupport);
+ server->isupport = strdup (" TEST=abc ");
+
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "T"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "TES"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "EST"));
+ POINTERS_EQUAL(NULL, irc_server_get_isupport_value (server, "TESTT"));
+
+ STRCMP_EQUAL("abc", irc_server_get_isupport_value (server, "TEST"));
+
+ irc_server_free (server);
}
/*