diff options
-rw-r--r-- | ChangeLog.adoc | 2 | ||||
-rw-r--r-- | doc/en/weechat_dev.en.adoc | 1 | ||||
-rw-r--r-- | doc/fr/weechat_dev.fr.adoc | 1 | ||||
-rw-r--r-- | doc/ja/weechat_dev.ja.adoc | 1 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 3 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-channel.cpp | 99 |
7 files changed, 106 insertions, 2 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index b0b951cf7..43cd7b4c4 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -85,7 +85,7 @@ Tests:: * core: add CI with GitHub Actions, move codecov.io upload to GitHub Actions * core: switch to Ubuntu Bionic on Travis CI, use pylint3 to lint Python scripts * core: run tests on plugins only if the plugins are enabled and compiled - * irc: add tests on IRC color functions + * irc: add tests on IRC color and channel functions Build:: diff --git a/doc/en/weechat_dev.en.adoc b/doc/en/weechat_dev.en.adoc index f691688dc..10ed469b9 100644 --- a/doc/en/weechat_dev.en.adoc +++ b/doc/en/weechat_dev.en.adoc @@ -411,6 +411,7 @@ WeeChat "core" is located in following directories: | test-gui-nick.cpp | Tests: nicks. | plugins/ | Root of unit tests for plugins. | irc/ | Root of unit tests for IRC plugin. +| test-irc-channel.cpp | Tests: IRC channels. | test-irc-color.cpp | Tests: IRC colors. | test-irc-config.cpp | Tests: IRC configuration. | test-irc-ignore.cpp | Tests: IRC ignores. diff --git a/doc/fr/weechat_dev.fr.adoc b/doc/fr/weechat_dev.fr.adoc index ea7dbfa49..1b964ac83 100644 --- a/doc/fr/weechat_dev.fr.adoc +++ b/doc/fr/weechat_dev.fr.adoc @@ -413,6 +413,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants : | test-gui-nick.cpp | Tests : pseudos. | plugins/ | Racine des tests unitaires pour les extensions. | irc/ | Racine des tests unitaires pour l'extension IRC. +| test-irc-channel.cpp | Tests : canaux IRC. | test-irc-color.cpp | Tests : couleurs IRC. | test-irc-config.cpp | Tests : configuration IRC. | test-irc-ignore.cpp | Tests : ignores IRC. diff --git a/doc/ja/weechat_dev.ja.adoc b/doc/ja/weechat_dev.ja.adoc index 985936048..744283d06 100644 --- a/doc/ja/weechat_dev.ja.adoc +++ b/doc/ja/weechat_dev.ja.adoc @@ -426,6 +426,7 @@ WeeChat "core" は以下のディレクトリに配置されています: | plugins/ | プラグインの単体テストを収める最上位ディレクトリ | irc/ | IRC プラグインの単体テストを収める最上位ディレクトリ // TRANSLATION MISSING +| test-irc-channel.cpp | Tests: IRC channels. | test-irc-color.cpp | Tests: IRC colors. | test-irc-config.cpp | テスト: IRC 設定 // TRANSLATION MISSING diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5c6bd1abb..5b24c7b2d 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -50,6 +50,7 @@ set(LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC unit/plugins/test-plugins.cpp) if(ENABLE_IRC) list(APPEND LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC + unit/plugins/irc/test-irc-channel.cpp unit/plugins/irc/test-irc-color.cpp unit/plugins/irc/test-irc-config.cpp unit/plugins/irc/test-irc-ignore.cpp diff --git a/tests/Makefile.am b/tests/Makefile.am index 2f4b214f7..f97fe676f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -65,7 +65,8 @@ tests_SOURCES = tests.cpp \ lib_LTLIBRARIES = lib_weechat_unit_tests_plugins.la if PLUGIN_IRC -tests_irc = unit/plugins/irc/test-irc-color.cpp \ +tests_irc = unit/plugins/irc/test-irc-channel.cpp \ + unit/plugins/irc/test-irc-color.cpp \ unit/plugins/irc/test-irc-config.cpp \ unit/plugins/irc/test-irc-ignore.cpp \ unit/plugins/irc/test-irc-message.cpp \ diff --git a/tests/unit/plugins/irc/test-irc-channel.cpp b/tests/unit/plugins/irc/test-irc-channel.cpp new file mode 100644 index 000000000..b78818987 --- /dev/null +++ b/tests/unit/plugins/irc/test-irc-channel.cpp @@ -0,0 +1,99 @@ +/* + * test-irc-channel.cpp - test IRC channel functions + * + * Copyright (C) 2019-2020 Sébastien Helleu <flashcode@flashtux.org> + * + * This file is part of WeeChat, the extensible chat client. + * + * WeeChat is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * WeeChat is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with WeeChat. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "CppUTest/TestHarness.h" + +extern "C" +{ +#include <string.h> +#include "src/plugins/irc/irc-channel.h" +#include "src/plugins/irc/irc-server.h" +} + +TEST_GROUP(IrcChannel) +{ +}; + +/* + * Tests functions: + * irc_channel_valid + */ + +TEST(IrcChannel, Valid) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * irc_channel_is_channel + */ + +TEST(IrcChannel, IsChannel) +{ + struct t_irc_server *server; + + /* no server, default chantypes = "#&+!" */ + + /* empty channel */ + LONGS_EQUAL(0, irc_channel_is_channel (NULL, NULL)); + LONGS_EQUAL(0, irc_channel_is_channel (NULL, "")); + + /* not a channel */ + LONGS_EQUAL(0, irc_channel_is_channel (NULL, "abc")); + LONGS_EQUAL(0, irc_channel_is_channel (NULL, "/abc")); + LONGS_EQUAL(0, irc_channel_is_channel (NULL, ":abc")); + + /* valid channel */ + LONGS_EQUAL(1, irc_channel_is_channel (NULL, "#abc")); + LONGS_EQUAL(1, irc_channel_is_channel (NULL, "##abc")); + LONGS_EQUAL(1, irc_channel_is_channel (NULL, "&abc")); + LONGS_EQUAL(1, irc_channel_is_channel (NULL, "&&abc")); + LONGS_EQUAL(1, irc_channel_is_channel (NULL, "+abc")); + LONGS_EQUAL(1, irc_channel_is_channel (NULL, "++abc")); + LONGS_EQUAL(1, irc_channel_is_channel (NULL, "!abc")); + LONGS_EQUAL(1, irc_channel_is_channel (NULL, "!!abc")); + + /* server with chantypes = "#" */ + server = irc_server_alloc ("my_ircd"); + CHECK(server); + if (server->chantypes) + free (server->chantypes); + server->chantypes = strdup ("#"); + + /* empty channel */ + LONGS_EQUAL(0, irc_channel_is_channel (server, NULL)); + LONGS_EQUAL(0, irc_channel_is_channel (server, "")); + + /* not a channel */ + LONGS_EQUAL(0, irc_channel_is_channel (server, "abc")); + LONGS_EQUAL(0, irc_channel_is_channel (server, "/abc")); + LONGS_EQUAL(0, irc_channel_is_channel (server, ":abc")); + LONGS_EQUAL(0, irc_channel_is_channel (server, "&abc")); + LONGS_EQUAL(0, irc_channel_is_channel (server, "+abc")); + LONGS_EQUAL(0, irc_channel_is_channel (server, "!abc")); + + /* valid channel */ + LONGS_EQUAL(1, irc_channel_is_channel (server, "#abc")); + LONGS_EQUAL(1, irc_channel_is_channel (server, "##abc")); + + irc_server_free (server); +} |