From 68ecfb16a121fb20098a21f5ca89d7027a49e636 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Helleu?= Date: Mon, 29 Aug 2022 22:45:28 +0200 Subject: irc: fix target buffer of generic errors when they contain a target nick (closes #1814) --- tests/unit/plugins/irc/test-irc-protocol.cpp | 65 ++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'tests') diff --git a/tests/unit/plugins/irc/test-irc-protocol.cpp b/tests/unit/plugins/irc/test-irc-protocol.cpp index 8bb918c6c..d61e5168d 100644 --- a/tests/unit/plugins/irc/test-irc-protocol.cpp +++ b/tests/unit/plugins/irc/test-irc-protocol.cpp @@ -3715,6 +3715,71 @@ TEST(IrcProtocolWithServer, 368) CHECK_SRV("-- [#xyz] End of Channel Ban List"); } +/* + * Tests functions: + * irc_protocol_cb_401 (no such nick/channel) + */ + +TEST(IrcProtocolWithServer, 401) +{ + SRV_INIT_JOIN; + + /* not enough parameters */ + RECV(":server 401"); + CHECK_ERROR_PARAMS("401", 0, 2); + RECV(":server 401 alice"); + CHECK_ERROR_PARAMS("401", 1, 2); + + RECV(":server 401 alice bob"); + CHECK_SRV("-- bob"); + RECV(":server 401 alice bob :No such nick/channel"); + CHECK_SRV("-- bob: No such nick/channel"); +} + +/* + * Tests functions: + * irc_protocol_cb_402 (no such server) + */ + +TEST(IrcProtocolWithServer, 402) +{ + SRV_INIT_JOIN; + + /* not enough parameters */ + RECV(":server 402"); + CHECK_ERROR_PARAMS("402", 0, 2); + RECV(":server 402 alice"); + CHECK_ERROR_PARAMS("402", 1, 2); + + RECV(":server 402 alice server"); + CHECK_SRV("-- server"); + RECV(":server 402 alice server :No such server"); + CHECK_SRV("-- server: No such server"); +} + +/* + * Tests functions: + * irc_protocol_cb_404 (cannot send to channel) + */ + +TEST(IrcProtocolWithServer, 404) +{ + SRV_INIT_JOIN; + + /* not enough parameters */ + RECV(":server 404"); + CHECK_ERROR_PARAMS("404", 0, 2); + RECV(":server 404 alice"); + CHECK_ERROR_PARAMS("404", 1, 2); + + RECV(":server 404 alice #test"); + CHECK_SRV("-- #test"); + RECV(":server 404 alice #test :Cannot send to channel"); + CHECK_CHAN("-- #test: Cannot send to channel"); + RECV(":server 404 alice #test2 :Cannot send to channel"); + CHECK_SRV("-- #test2: Cannot send to channel"); +} + /* * Tests functions: * irc_protocol_cb_432 (erroneous nickname, not connected) -- cgit v1.2.3