summaryrefslogtreecommitdiff
path: root/tests/unit/plugins
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-02-03 18:30:32 +0100
committerSébastien Helleu <flashcode@flashtux.org>2021-02-03 18:30:32 +0100
commita34959a619be41796b3de988c71717d1b313db2e (patch)
treea8e4365e77a0d59b03691ac314f5abfb97e4c62c /tests/unit/plugins
parent42a86f0a36aaa2283196d832fba01cd6730b7443 (diff)
downloadweechat-a34959a619be41796b3de988c71717d1b313db2e.zip
irc: add info "irc_is_message_ignored"
Diffstat (limited to 'tests/unit/plugins')
-rw-r--r--tests/unit/plugins/irc/test-irc-message.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/unit/plugins/irc/test-irc-message.cpp b/tests/unit/plugins/irc/test-irc-message.cpp
index 8abb8dc0a..c23c65b39 100644
--- a/tests/unit/plugins/irc/test-irc-message.cpp
+++ b/tests/unit/plugins/irc/test-irc-message.cpp
@@ -29,6 +29,7 @@ extern "C"
#include "src/core/wee-hashtable.h"
#include "src/core/wee-hook.h"
#include "src/plugins/irc/irc-config.h"
+#include "src/plugins/irc/irc-ignore.h"
#include "src/plugins/irc/irc-message.h"
#include "src/plugins/irc/irc-server.h"
}
@@ -649,6 +650,46 @@ TEST(IrcMessage, GetAddressFromHost)
/*
* Tests functions:
+ * irc_message_ignored
+ */
+
+TEST(IrcMessage, Ignored)
+{
+ struct t_irc_server *server;
+ struct t_irc_ignore *ignore1, *ignore2;
+
+ server = irc_server_alloc ("test_ignore");
+ CHECK(server);
+
+ ignore1 = irc_ignore_new ("^alice@host1$", "test_ignore", "#test1");
+ ignore2 = irc_ignore_new ("^bob@host2$", "test_ignore", "#test2");
+
+ LONGS_EQUAL(0, irc_message_ignored (NULL, NULL));
+ LONGS_EQUAL(0, irc_message_ignored (NULL, ""));
+ LONGS_EQUAL(0, irc_message_ignored (NULL,
+ ":alice@host1 PRIVMSG #test1 :hi!"));
+
+ LONGS_EQUAL(1, irc_message_ignored (server,
+ ":alice@host1 PRIVMSG #test1 :hi!"));
+ LONGS_EQUAL(0, irc_message_ignored (server,
+ ":alice@host1 PRIVMSG #test :hi!"));
+ LONGS_EQUAL(0, irc_message_ignored (server,
+ ":alice@host2 PRIVMSG #test1 :hi!"));
+
+ LONGS_EQUAL(1, irc_message_ignored (server,
+ ":bob@host2 PRIVMSG #test2 :hi!"));
+ LONGS_EQUAL(0, irc_message_ignored (server,
+ ":bob@host2 PRIVMSG #test :hi!"));
+ LONGS_EQUAL(0, irc_message_ignored (server,
+ ":bob2@host2 PRIVMSG #test2 :hi!"));
+
+ irc_ignore_free (ignore1);
+ irc_ignore_free (ignore2);
+ irc_server_free (server);
+}
+
+/*
+ * Tests functions:
* irc_message_replace_vars
*/