tests: add unit tests on IRC functions irc_message_get_{nick,address}_from_host

This commit is contained in:
Sébastien Helleu 2019-08-03 10:50:32 +02:00
parent 478ca22054
commit 28d79d0c93
7 changed files with 134 additions and 1 deletions

View File

@ -42,7 +42,7 @@ Bug fixes::
Tests::
* unit: add tests on IRC ignore functions
* unit: add tests on IRC ignore and message functions
Build::

View File

@ -406,6 +406,7 @@ WeeChat "core" is located in following directories:
|             test-irc-color.cpp | Tests: IRC colors.
|             test-irc-config.cpp | Tests: IRC configuration.
|             test-irc-ignore.cpp | Tests: IRC ignores.
|             test-irc-message.cpp | Tests: IRC messages.
|             test-irc-mode.cpp | Tests: IRC modes.
|             test-irc-protocol.cpp | Tests: IRC protocol.

View File

@ -408,6 +408,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants :
|             test-irc-color.cpp | Tests : couleurs IRC.
|             test-irc-config.cpp | Tests : configuration IRC.
|             test-irc-ignore.cpp | Tests : ignores IRC.
|             test-irc-message.cpp | Tests : messages IRC.
|             test-irc-mode.cpp | Tests : modes IRC.
|             test-irc-protocol.cpp | Tests : protocole IRC.
|===

View File

@ -415,6 +415,8 @@ WeeChat "core" は以下のディレクトリに配置されています:
// TRANSLATION MISSING
|             test-irc-ignore.cpp | Tests: IRC ignores.
// TRANSLATION MISSING
|             test-irc-message.cpp | Tests: IRC messages.
// TRANSLATION MISSING
|             test-irc-mode.cpp | Tests: IRC modes.
|             test-irc-protocol.cpp | テスト: IRC プロトコル
|===

View File

@ -47,6 +47,7 @@ set(LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC
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
unit/plugins/irc/test-irc-mode.cpp
unit/plugins/irc/test-irc-protocol.cpp
)

View File

@ -64,6 +64,7 @@ lib_LTLIBRARIES = lib_weechat_unit_tests_plugins.la
lib_weechat_unit_tests_plugins_la_SOURCES = 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 \
unit/plugins/irc/test-irc-mode.cpp \
unit/plugins/irc/test-irc-protocol.cpp

View File

@ -0,0 +1,127 @@
/*
* test-irc-message.cpp - test IRC message functions
*
* Copyright (C) 2019 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 "src/plugins/irc/irc-message.h"
}
#define NICK_256_WITH_SPACE "nick_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
"xxxxxxxxxxxxxx_64_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
"xxxxxx_128_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_256 test"
TEST_GROUP(IrcMessage)
{
};
/*
* Tests functions:
* irc_message_parse
* irc_message_parse_to_hashtable
*/
TEST(IrcMessage, Parse)
{
/* TODO: write tests */
}
/*
* Tests functions:
* irc_message_convert_charset
*/
TEST(IrcMessage, ConvertCharset)
{
/* TODO: write tests */
}
/*
* Tests functions:
* irc_message_get_nick_from_host
*/
TEST(IrcMessage, GetNickFromHost)
{
POINTERS_EQUAL(NULL, irc_message_get_nick_from_host (NULL));
STRCMP_EQUAL("", irc_message_get_nick_from_host (""));
STRCMP_EQUAL("nick", irc_message_get_nick_from_host ("nick"));
STRCMP_EQUAL("nick", irc_message_get_nick_from_host ("nick "));
STRCMP_EQUAL("nick", irc_message_get_nick_from_host ("nick test"));
STRCMP_EQUAL("nick", irc_message_get_nick_from_host (":nick "));
STRCMP_EQUAL("nick", irc_message_get_nick_from_host (":nick!host"));
STRCMP_EQUAL("nick", irc_message_get_nick_from_host (":nick!user@host"));
STRCMP_EQUAL("nick_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"x_64_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"xxxx_12",
irc_message_get_nick_from_host (NICK_256_WITH_SPACE));
}
/*
* Tests functions:
* irc_message_get_address_from_host
*/
TEST(IrcMessage, GetAddressFromHost)
{
POINTERS_EQUAL(NULL, irc_message_get_address_from_host (NULL));
STRCMP_EQUAL("", irc_message_get_address_from_host (""));
STRCMP_EQUAL("host", irc_message_get_address_from_host ("host"));
STRCMP_EQUAL("host", irc_message_get_address_from_host ("host "));
STRCMP_EQUAL("host", irc_message_get_address_from_host ("host test"));
STRCMP_EQUAL("host", irc_message_get_address_from_host (":host "));
STRCMP_EQUAL("host", irc_message_get_address_from_host (":nick!host"));
STRCMP_EQUAL("user@host",
irc_message_get_address_from_host (":nick!user@host"));
STRCMP_EQUAL("nick_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"x_64_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"xxxx_128_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
"xxxxxxxxxxxx_25",
irc_message_get_address_from_host (NICK_256_WITH_SPACE));
}
/*
* Tests functions:
* irc_message_replace_vars
*/
TEST(IrcMessage, ReplaceVars)
{
/* TODO: write tests */
}
/*
* Tests functions:
* irc_message_split_add
* irc_message_split_string
* irc_message_split_join
* irc_message_split_privmsg_notice
* irc_message_split_005
* irc_message_split
*/
TEST(IrcMessage, Split)
{
/* TODO: write tests */
}