diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2019-08-03 10:50:32 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2019-08-03 11:30:35 +0200 |
commit | 28d79d0c93f971e9c09461eceb041574aa05d83b (patch) | |
tree | 4b38344ebe4e6a496f68030b7c21ab7666575287 | |
parent | 478ca220540ddad75cba4f204e4ff68c1fb535ac (diff) | |
download | weechat-28d79d0c93f971e9c09461eceb041574aa05d83b.zip |
tests: add unit tests on IRC functions irc_message_get_{nick,address}_from_host
-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 | 2 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/unit/plugins/irc/test-irc-message.cpp | 127 |
7 files changed, 134 insertions, 1 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 7e5cd30cb..490cea521 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -42,7 +42,7 @@ Bug fixes:: Tests:: - * unit: add tests on IRC ignore functions + * unit: add tests on IRC ignore and message functions Build:: diff --git a/doc/en/weechat_dev.en.adoc b/doc/en/weechat_dev.en.adoc index f7c2432f8..55364249a 100644 --- a/doc/en/weechat_dev.en.adoc +++ b/doc/en/weechat_dev.en.adoc @@ -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. diff --git a/doc/fr/weechat_dev.fr.adoc b/doc/fr/weechat_dev.fr.adoc index bf948b313..a5649ceca 100644 --- a/doc/fr/weechat_dev.fr.adoc +++ b/doc/fr/weechat_dev.fr.adoc @@ -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. |=== diff --git a/doc/ja/weechat_dev.ja.adoc b/doc/ja/weechat_dev.ja.adoc index f0530ba42..ee042b6f7 100644 --- a/doc/ja/weechat_dev.ja.adoc +++ b/doc/ja/weechat_dev.ja.adoc @@ -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 プロトコル |=== diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ead52cf32..5846e7967 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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 ) diff --git a/tests/Makefile.am b/tests/Makefile.am index 32cab6040..62a9d2721 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 diff --git a/tests/unit/plugins/irc/test-irc-message.cpp b/tests/unit/plugins/irc/test-irc-message.cpp new file mode 100644 index 000000000..5c06680c2 --- /dev/null +++ b/tests/unit/plugins/irc/test-irc-message.cpp @@ -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 */ +} |