diff options
-rw-r--r-- | tests/unit/plugins/irc/test-irc-protocol.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index b67b42831..ec1c50059 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -105,6 +105,10 @@ extern char *irc_protocol_cap_to_enable (const char *capabilities, "\"" __command "\" (received: " #__params ", " \ "expected: at least " #__expected_params ")"); +#define CHECK_ERROR_NICK(__command) \ + CHECK_SRV("=!= irc: command \"" __command "\" received without " \ + "nick"); + #define CHECK_ERROR_PARSE(__command, __message) \ CHECK_SRV("=!= irc: failed to parse command \"" __command "\" " \ "(please report to developers): \"" __message "\""); @@ -932,6 +936,16 @@ TEST(IrcProtocolWithServer, invite) { SRV_INIT; + /* not enough parameters */ + RECV(":bob!user@host INVITE"); + CHECK_ERROR_PARAMS("invite", 0, 2); + RECV(":bob!user@host INVITE alice"); + CHECK_ERROR_PARAMS("invite", 1, 2); + + /* missing nick */ + RECV("INVITE alice #channel"); + CHECK_ERROR_NICK("invite"); + RECV(":bob!user@host INVITE alice #channel"); CHECK_SRV("-- You have been invited to #channel by bob"); RECV(":bob!user@host INVITE xxx #channel"); @@ -956,6 +970,10 @@ TEST(IrcProtocolWithServer, join) RECV(":alice!user@host JOIN"); CHECK_ERROR_PARAMS("join", 0, 1); + /* missing nick */ + RECV("JOIN #test"); + CHECK_ERROR_NICK("join"); + POINTERS_EQUAL(NULL, ptr_server->channels); /* join of a user while the channel does not yet exist in local */ @@ -1067,6 +1085,10 @@ TEST(IrcProtocolWithServer, kick) RECV(":alice!user@host KICK #test"); CHECK_ERROR_PARAMS("kick", 1, 2); + /* missing nick */ + RECV("KICK #test bob"); + CHECK_ERROR_NICK("kick"); + STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name); /* channel not found */ @@ -1120,6 +1142,10 @@ TEST(IrcProtocolWithServer, kill) RECV(":alice!user@host KILL"); CHECK_ERROR_PARAMS("kill", 0, 1); + /* missing nick */ + RECV("KILL alice"); + CHECK_ERROR_NICK("kill"); + STRCMP_EQUAL("bob", ptr_channel->nicks->next_nick->name); /* kill without a reason */ @@ -1165,6 +1191,10 @@ TEST(IrcProtocolWithServer, mode) RECV(":admin MODE #test"); CHECK_ERROR_PARAMS("mode", 1, 2); + /* missing nick */ + RECV("MODE #test +nt"); + CHECK_ERROR_NICK("mode"); + POINTERS_EQUAL(NULL, ptr_channel->modes); /* channel mode */ @@ -1253,6 +1283,10 @@ TEST(IrcProtocolWithServer, nick) STRCMP_EQUAL("alice", ptr_nick1->name); STRCMP_EQUAL("bob", ptr_nick2->name); + /* missing nick */ + RECV("NICK alice_away"); + CHECK_ERROR_NICK("nick"); + /* new nick for alice */ RECV(":alice!user@host NICK alice_away"); CHECK_SRV("-- You are now known as alice_away"); @@ -1441,6 +1475,10 @@ TEST(IrcProtocolWithServer, part) RECV(":alice!user@host PART"); CHECK_ERROR_PARAMS("part", 0, 1); + /* missing nick */ + RECV("PART #test"); + CHECK_ERROR_NICK("part"); + STRCMP_EQUAL("#test", ptr_server->channels->name); CHECK(ptr_server->channels->nicks); LONGS_EQUAL(0, ptr_server->channels->part); |