tests: add tests on IRC function irc_channel_is_channel
This commit is contained in:
parent
2a60a25443
commit
bf964de939
@ -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::
|
||||
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 \
|
||||
|
99
tests/unit/plugins/irc/test-irc-channel.cpp
Normal file
99
tests/unit/plugins/irc/test-irc-channel.cpp
Normal file
@ -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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user