diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-12-02 13:24:42 +0100 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-12-02 13:24:42 +0100 |
commit | 52f32e5612b9343c67cf346aac9feaba489e1987 (patch) | |
tree | ca9f141c1e891e0f234122f323ed4b736d293ce1 | |
parent | f4926cbd20d5cef4fa8215be374d7337cbd8c257 (diff) | |
download | weechat-52f32e5612b9343c67cf346aac9feaba489e1987.zip |
tests: add tests on plugin config functions
-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 | 3 | ||||
-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/test-plugin-config.cpp | 170 |
7 files changed, 179 insertions, 2 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc index 6a5248202..a959e06e0 100644 --- a/ChangeLog.adoc +++ b/ChangeLog.adoc @@ -58,7 +58,7 @@ Bug fixes:: Tests:: - * core: add tests on plugin API info functions + * core: add tests on plugin config and plugin API info functions Build:: diff --git a/doc/en/weechat_dev.en.adoc b/doc/en/weechat_dev.en.adoc index 8eee6afe1..2c80c97cd 100644 --- a/doc/en/weechat_dev.en.adoc +++ b/doc/en/weechat_dev.en.adoc @@ -404,6 +404,7 @@ WeeChat "core" is located in following directories: | unit/ | Root of unit tests. | test-plugins.cpp | Tests: plugins. | test-plugin-api-info.cpp | Tests: plugin API info functions. +| test-plugin-config.cpp | Tests: plugin config functions. | core/ | Root of unit tests for core. | test-core-arraylist.cpp | Tests: arraylists. | test-core-calc.cpp | Tests: calculation of expressions. diff --git a/doc/fr/weechat_dev.fr.adoc b/doc/fr/weechat_dev.fr.adoc index 36e46b54d..cb6ff932c 100644 --- a/doc/fr/weechat_dev.fr.adoc +++ b/doc/fr/weechat_dev.fr.adoc @@ -405,7 +405,8 @@ Le cœur de WeeChat est situé dans les répertoires suivants : | unparse.py | Conversion de code Python vers d'autres langages, utilisé par le script testapigen.py. | unit/ | Racine des tests unitaires. | test-plugins.cpp | Tests : extensions. -| test-plugin-api-info.cpp | Tests : fonctions info de l'API. +| test-plugin-api-info.cpp | Tests : fonctions info de l'API extension. +| test-plugin-config.cpp | Tests : fonctions config de l'extension. | core/ | Racine des tests unitaires pour le cœur. | test-core-arraylist.cpp | Tests : listes avec tableau (« arraylists »). | test-core-calc.cpp | Tests : calcul d'expressions. diff --git a/doc/ja/weechat_dev.ja.adoc b/doc/ja/weechat_dev.ja.adoc index 4b33cd8e3..9c9b16d41 100644 --- a/doc/ja/weechat_dev.ja.adoc +++ b/doc/ja/weechat_dev.ja.adoc @@ -432,6 +432,8 @@ WeeChat "core" は以下のディレクトリに配置されています: | test-plugins.cpp | テスト: プラグイン // TRANSLATION MISSING | test-plugin-api-info.cpp | Tests: plugin API info functions. +// TRANSLATION MISSING +| test-plugin-config.cpp | Tests: plugin config functions. | core/ | core 向け単体テスト用のルートディレクトリ | test-core-arraylist.cpp | テスト: 配列リスト // TRANSLATION MISSING diff --git a/doc/sr/weechat_dev.sr.adoc b/doc/sr/weechat_dev.sr.adoc index 08c5dcdcf..31ced3447 100644 --- a/doc/sr/weechat_dev.sr.adoc +++ b/doc/sr/weechat_dev.sr.adoc @@ -407,6 +407,8 @@ WeeChat „језгро” се налази у следећим директо | test-plugins.cpp | Тестови: plugins. // TRANSLATION MISSING | test-plugin-api-info.cpp | Tests: plugin API info functions. +// TRANSLATION MISSING +| test-plugin-config.cpp | Tests: plugin config functions. | core/ | Корен unit тестова језгра. | test-core-arraylist.cpp | Тестови: arraylists. | test-core-calc.cpp | Тестови: калкулација израза. diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a81c72da3..3501d4ee8 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -65,6 +65,7 @@ add_library(weechat_unit_tests_core STATIC ${LIB_WEECHAT_UNIT_TESTS_CORE_SRC}) set(LIB_WEECHAT_UNIT_TESTS_PLUGINS_SRC unit/plugins/test-plugins.cpp unit/plugins/test-plugin-api-info.cpp + unit/plugins/test-plugin-config.cpp ) if(ENABLE_ALIAS) diff --git a/tests/unit/plugins/test-plugin-config.cpp b/tests/unit/plugins/test-plugin-config.cpp new file mode 100644 index 000000000..538d0d178 --- /dev/null +++ b/tests/unit/plugins/test-plugin-config.cpp @@ -0,0 +1,170 @@ +/* + * test-plugin-config.cpp - tests plugins config functions + * + * Copyright (C) 2023 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 <https://www.gnu.org/licenses/>. + */ + +#include "CppUTest/TestHarness.h" + +#include "tests/tests.h" + +extern "C" +{ +#include "src/core/wee-config-file.h" +#include "src/plugins/weechat-plugin.h" +#include "src/plugins/plugin-config.h" +} + +TEST_GROUP(PluginConfig) +{ +}; + +/* + * Tests functions: + * plugin_config_search + * plugin_config_set_internal + * plugin_config_set + * plugin_config_desc_changed_cb + * plugin_config_set_desc_internal + * plugin_config_set_desc + */ + +TEST(PluginConfig, Set) +{ + struct t_config_option *ptr_option, *ptr_option_desc; + + POINTERS_EQUAL(NULL, plugin_config_search (NULL, NULL)); + POINTERS_EQUAL(NULL, plugin_config_search ("python", NULL)); + POINTERS_EQUAL(NULL, plugin_config_search ("python", "test")); + + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE, + plugin_config_set ("python", "test", "the old value")); + ptr_option = plugin_config_search ("python", "test"); + STRCMP_EQUAL("the old value", CONFIG_STRING(ptr_option)); + + LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED, + plugin_config_set ("python", "test", "the new value")); + ptr_option = plugin_config_search ("python", "test"); + STRCMP_EQUAL("the new value", CONFIG_STRING(ptr_option)); + + config_file_search_with_string ("plugins.desc.python.test", + NULL, NULL, &ptr_option_desc, NULL); + POINTERS_EQUAL(NULL, ptr_option_desc); + + plugin_config_set_desc ("python", "test", "the old description"); + config_file_search_with_string ("plugins.desc.python.test", + NULL, NULL, &ptr_option_desc, NULL); + CHECK(ptr_option_desc); + STRCMP_EQUAL("the old description", CONFIG_STRING(ptr_option_desc)); + + plugin_config_set_desc ("python", "test", "the new description"); + config_file_search_with_string ("plugins.desc.python.test", + NULL, NULL, &ptr_option_desc, NULL); + CHECK(ptr_option_desc); + STRCMP_EQUAL("the new description", CONFIG_STRING(ptr_option_desc)); + + config_file_option_free (ptr_option_desc, 1); + config_file_search_with_string ("plugins.desc.python.test", + NULL, NULL, &ptr_option_desc, NULL); + POINTERS_EQUAL(NULL, ptr_option_desc); + + config_file_option_free (ptr_option, 1); + config_file_search_with_string ("plugins.var.python.test", + NULL, NULL, &ptr_option, NULL); + POINTERS_EQUAL(NULL, ptr_option); +} + +/* + * Tests functions: + * plugin_config_reload + */ + +TEST(PluginConfig, Reload) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * plugin_config_create_option + */ + +TEST(PluginConfig, CreateOption) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * plugin_config_create_desc + */ + +TEST(PluginConfig, CreateDesc) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * plugin_config_delete_desc + */ + +TEST(PluginConfig, DeleteDesc) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * plugin_config_init + */ + +TEST(PluginConfig, Init) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * plugin_config_read + */ + +TEST(PluginConfig, Read) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * plugin_config_write + */ + +TEST(PluginConfig, Write) +{ + /* TODO: write tests */ +} + +/* + * Tests functions: + * plugin_config_end + */ + +TEST(PluginConfig, End) +{ + /* TODO: write tests */ +} |