diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2024-03-31 11:23:37 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2024-04-07 13:18:13 +0200 |
commit | f507be41284ec6b06f0a43011a4658e5f786d5f4 (patch) | |
tree | 8e17f7dd6840fa4ba8d1f101f0ff333607d54b4c | |
parent | a3f3c9d09c3d10de015507415093811cb6f62374 (diff) | |
download | weechat-f507be41284ec6b06f0a43011a4658e5f786d5f4.zip |
tests: add tests on relay remote functions (issue #2066)
-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-- | doc/sr/weechat_dev.sr.adoc | 2 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/unit/plugins/relay/test-relay-remote.cpp | 290 |
6 files changed, 297 insertions, 0 deletions
diff --git a/doc/en/weechat_dev.en.adoc b/doc/en/weechat_dev.en.adoc index 98f02dcc3..f4c435224 100644 --- a/doc/en/weechat_dev.en.adoc +++ b/doc/en/weechat_dev.en.adoc @@ -481,6 +481,7 @@ WeeChat "core" is located in following directories: | relay/ | Root of unit tests for Relay plugin. | test-relay-auth.cpp | Tests: clients authentication. | test-relay-http.cpp | Tests: HTTP functions for Relay plugin. +| test-relay-remote.cpp | Tests: remote functions for Relay plugin. | test-relay-websocket.cpp | Tests: websocket functions for Relay plugin. | api/ | Root of unit tests for Relay "api" protocol. | test-relay-api.cpp | Tests: Relay "api" protocol: general functions. diff --git a/doc/fr/weechat_dev.fr.adoc b/doc/fr/weechat_dev.fr.adoc index a3337b8c3..7a65611f1 100644 --- a/doc/fr/weechat_dev.fr.adoc +++ b/doc/fr/weechat_dev.fr.adoc @@ -483,6 +483,7 @@ Le cœur de WeeChat est situé dans les répertoires suivants : | relay/ | Racine des tests unitaires pour l'extension Relay. | test-relay-auth.cpp | Tests : authentification des clients. | test-relay-http.cpp | Tests : fonctions HTTP pour l'extension Relay. +| test-relay-remote.cpp | Tests : fonctions remote pour l'extension Relay. | test-relay-websocket.cpp | Tests : fonctions websocket pour l'extension Relay. | api/ | Racine des tests unitaires pour le protocole relay "api". | test-relay-api.cpp | Tests : protocole relay "api" : fonctions générales. diff --git a/doc/ja/weechat_dev.ja.adoc b/doc/ja/weechat_dev.ja.adoc index 4901581cf..33c9c0f82 100644 --- a/doc/ja/weechat_dev.ja.adoc +++ b/doc/ja/weechat_dev.ja.adoc @@ -569,6 +569,8 @@ WeeChat "core" は以下のディレクトリに配置されています: // TRANSLATION MISSING | test-relay-http.cpp | Tests: HTTP functions for Relay plugin. // TRANSLATION MISSING +| test-relay-remote.cpp | Tests: remote functions for Relay plugin. +// TRANSLATION MISSING | test-relay-websocket.cpp | Tests: websocket functions for Relay plugin. // TRANSLATION MISSING | api/ | Root of unit tests for Relay "api" protocol. diff --git a/doc/sr/weechat_dev.sr.adoc b/doc/sr/weechat_dev.sr.adoc index d6016231c..6314a841e 100644 --- a/doc/sr/weechat_dev.sr.adoc +++ b/doc/sr/weechat_dev.sr.adoc @@ -489,6 +489,8 @@ WeeChat „језгро” се налази у следећим директо | relay/ | Корен unit тестова за Релеј додатак. | test-relay-auth.cpp | Тестови: аутентификација клијената. | test-relay-http.cpp | Тестови: HTTP функције за Релеј додатак. +// TRANSLATION MISSING +| test-relay-remote.cpp | Tests: remote functions for Relay plugin. | test-relay-websocket.cpp | Тестови: websocket функције за Релеј додатак. | api/ | Root of unit tests for Relay "api" protocol. | test-relay-api.cpp | Tests: Relay "api" protocol: general functions. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 41a338574..cbce96b30 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -135,6 +135,7 @@ if (ENABLE_RELAY) list(APPEND LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC unit/plugins/relay/test-relay-auth.cpp unit/plugins/relay/test-relay-http.cpp + unit/plugins/relay/test-relay-remote.cpp unit/plugins/relay/test-relay-websocket.cpp unit/plugins/relay/irc/test-relay-irc.cpp ) diff --git a/tests/unit/plugins/relay/test-relay-remote.cpp b/tests/unit/plugins/relay/test-relay-remote.cpp new file mode 100644 index 000000000..aab1f032f --- /dev/null +++ b/tests/unit/plugins/relay/test-relay-remote.cpp @@ -0,0 +1,290 @@ +/* + * test-relay-remote.cpp - test relay remote functions + * + * Copyright (C) 2024 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 <stdio.h> +#include <string.h> +#include "src/plugins/relay/relay.h" +#include "src/plugins/relay/relay-remote.h" + +extern char *relay_remote_get_address (const char *url); +} + +TEST_GROUP(RelayRemote) +{ +}; + +/* + * Tests functions: + * relay_remote_search_option + */ + +TEST(RelayRemote, SearchOption) +{ + LONGS_EQUAL(-1, relay_remote_search_option (NULL)); + LONGS_EQUAL(-1, relay_remote_search_option ("")); + LONGS_EQUAL(-1, relay_remote_search_option ("zzz")); + + LONGS_EQUAL(0, relay_remote_search_option ("url")); +} + +/* + * Tests functions: + * relay_remote_valid + */ + +TEST(RelayRemote, Valid) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_search + */ + +TEST(RelayRemote, Search) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_search_by_number + */ + +TEST(RelayRemote, SearchByNumber) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_name_valid + */ + +TEST(RelayRemote, NameValid) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_url_valid + */ + +TEST(RelayRemote, UrlValid) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_send_signal + */ + +TEST(RelayRemote, SendSignal) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_get_address + */ + +TEST(RelayRemote, GetAddress) +{ + POINTERS_EQUAL(NULL, relay_remote_get_address (NULL)); + POINTERS_EQUAL(NULL, relay_remote_get_address ("")); + POINTERS_EQUAL(NULL, relay_remote_get_address ("zzz")); + + STRCMP_EQUAL("", relay_remote_get_address ("http://")); + STRCMP_EQUAL("", relay_remote_get_address ("https://")); + + STRCMP_EQUAL("localhost", relay_remote_get_address ("https://localhost")); + STRCMP_EQUAL("example.com", relay_remote_get_address ("https://example.com")); + STRCMP_EQUAL("example.com", relay_remote_get_address ("https://example.com:8000")); + STRCMP_EQUAL("example.com", relay_remote_get_address ("https://example.com:8000/")); +} + +/* + * Tests functions: + * relay_remote_get_port + */ + +TEST(RelayRemote, GetPort) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_alloc + */ + +TEST(RelayRemote, Alloc) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_find_pos + */ + +TEST(RelayRemote, FindPos) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_add + */ + +TEST(RelayRemote, Add) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_new_with_options + */ + +TEST(RelayRemote, NewWithOptions) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_new + */ + +TEST(RelayRemote, New) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_new_with_infolist + */ + +TEST(RelayRemote, NewWithInfolist) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_set_status + */ + +TEST(RelayRemote, SetStatus) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_connect + */ + +TEST(RelayRemote, Connect) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_rename + */ + +TEST(RelayRemote, Rename) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_free + */ + +TEST(RelayRemote, Free) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_free_all + */ + +TEST(RelayRemote, FreeAll) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_disconnect + */ + +TEST(RelayRemote, Disconnect) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_disconnect_all + */ + +TEST(RelayRemote, DisconnectAll) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_add_to_infolist + */ + +TEST(RelayRemote, AddToInfolist) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * relay_remote_print_log + */ + +TEST(RelayRemote, PrintLog) +{ + /* TODO: write tests */ +} |