summaryrefslogtreecommitdiff
path: root/tests/unit/plugins/test-plugin-config.cpp
blob: ddfc5cb5a3dbf8f0e41921f1fffb25ab3d236746 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*
 * test-plugin-config.cpp - tests plugins config functions
 *
 * Copyright (C) 2023-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 <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 */
}