1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-01 07:16:37 +02:00

tests: add tests on plugin config functions

This commit is contained in:
Sébastien Helleu
2023-12-02 13:24:42 +01:00
parent f4926cbd20
commit 52f32e5612
7 changed files with 179 additions and 2 deletions
+1 -1
View File
@@ -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::
+1
View File
@@ -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.
+2 -1
View File
@@ -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.
+2
View File
@@ -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
+2
View File
@@ -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 | Тестови: калкулација израза.
+1
View File
@@ -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)
+170
View File
@@ -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 */
}