1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-12 14:14:48 +02:00

core: add function config_file_option_set_default

This commit is contained in:
Sébastien Helleu
2023-03-04 14:28:52 +01:00
parent 79f7c1cf83
commit 55d9989b85
5 changed files with 976 additions and 456 deletions
+327
View File
@@ -1856,6 +1856,333 @@ config_file_option_set_null (struct t_config_option *option, int run_callback)
return rc;
}
/*
* Sets the default value for an option.
*
* Returns:
* WEECHAT_CONFIG_OPTION_SET_OK_CHANGED: OK, default value has been changed
* WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE: OK, default value not changed
* WEECHAT_CONFIG_OPTION_SET_ERROR: error
*/
int
config_file_option_set_default (struct t_config_option *option,
const char *value,
int run_callback)
{
int value_int, i, rc, new_value_ok, old_value_was_null, old_value;
long number;
char *error;
if (!option)
return WEECHAT_CONFIG_OPTION_SET_ERROR;
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
if (option->callback_check_value)
{
if (!(int)(option->callback_check_value) (
option->callback_check_value_pointer,
option->callback_check_value_data,
option,
value))
{
return WEECHAT_CONFIG_OPTION_SET_ERROR;
}
}
if (value)
{
old_value_was_null = (option->default_value == NULL);
switch (option->type)
{
case CONFIG_OPTION_TYPE_BOOLEAN:
if (!option->default_value)
{
option->default_value = malloc (sizeof (int));
if (option->default_value)
{
if (strcmp (value, "toggle") == 0)
{
CONFIG_BOOLEAN_DEFAULT(option) = CONFIG_BOOLEAN_TRUE;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
else
{
if (config_file_string_boolean_is_valid (value))
{
value_int = config_file_string_to_boolean (value);
CONFIG_BOOLEAN_DEFAULT(option) = value_int;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
else
{
free (option->default_value);
option->default_value = NULL;
}
}
}
}
else
{
if (strcmp (value, "toggle") == 0)
{
CONFIG_BOOLEAN_DEFAULT(option) =
(CONFIG_BOOLEAN_DEFAULT(option) == CONFIG_BOOLEAN_TRUE) ?
CONFIG_BOOLEAN_FALSE : CONFIG_BOOLEAN_TRUE;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
else
{
if (config_file_string_boolean_is_valid (value))
{
value_int = config_file_string_to_boolean (value);
if (value_int == CONFIG_BOOLEAN_DEFAULT(option))
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
else
{
CONFIG_BOOLEAN_DEFAULT(option) = value_int;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
}
}
}
break;
case CONFIG_OPTION_TYPE_INTEGER:
old_value = 0;
if (!option->default_value)
option->default_value = malloc (sizeof (int));
else
old_value = CONFIG_INTEGER_DEFAULT(option);
if (option->default_value)
{
if (option->string_values)
{
value_int = -1;
if (strncmp (value, "++", 2) == 0)
{
error = NULL;
number = strtol (value + 2, &error, 10);
if (error && !error[0])
{
number = number % (option->max + 1);
value_int = (old_value + number) %
(option->max + 1);
}
}
else if (strncmp (value, "--", 2) == 0)
{
error = NULL;
number = strtol (value + 2, &error, 10);
if (error && !error[0])
{
number = number % (option->max + 1);
value_int = (old_value + (option->max + 1) - number) %
(option->max + 1);
}
}
else
{
for (i = 0; option->string_values[i]; i++)
{
if (strcmp (option->string_values[i], value) == 0)
{
value_int = i;
break;
}
}
}
if (value_int >= 0)
{
if (old_value_was_null
|| (value_int != old_value))
{
CONFIG_INTEGER_DEFAULT(option) = value_int;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
else
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
else
{
if (old_value_was_null)
{
free (option->default_value);
option->default_value = NULL;
}
}
}
else
{
new_value_ok = 0;
if (strncmp (value, "++", 2) == 0)
{
error = NULL;
number = strtol (value + 2, &error, 10);
if (error && !error[0])
{
value_int = old_value + number;
if (value_int <= option->max)
new_value_ok = 1;
}
}
else if (strncmp (value, "--", 2) == 0)
{
error = NULL;
number = strtol (value + 2, &error, 10);
if (error && !error[0])
{
value_int = old_value - number;
if (value_int >= option->min)
new_value_ok = 1;
}
}
else
{
error = NULL;
number = strtol (value, &error, 10);
if (error && !error[0])
{
value_int = number;
if ((value_int >= option->min)
&& (value_int <= option->max))
new_value_ok = 1;
}
}
if (new_value_ok)
{
if (old_value_was_null
|| (value_int != old_value))
{
CONFIG_INTEGER_DEFAULT(option) = value_int;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
else
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
else
{
if (old_value_was_null)
{
free (option->default_value);
option->default_value = NULL;
}
}
}
}
break;
case CONFIG_OPTION_TYPE_STRING:
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
if (!option->default_value
|| (strcmp (CONFIG_STRING_DEFAULT(option), value) != 0))
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
if (option->default_value)
{
free (option->default_value);
option->default_value = NULL;
}
option->default_value = strdup (value);
if (!option->default_value)
rc = WEECHAT_CONFIG_OPTION_SET_ERROR;
break;
case CONFIG_OPTION_TYPE_COLOR:
old_value = 0;
if (!option->default_value)
option->default_value = malloc (sizeof (int));
else
old_value = CONFIG_COLOR_DEFAULT(option);
if (option->default_value)
{
value_int = -1;
new_value_ok = 0;
if (strncmp (value, "++", 2) == 0)
{
error = NULL;
number = strtol (value + 2, &error, 10);
if (error && !error[0])
{
if (gui_color_assign_by_diff (&value_int,
gui_color_get_name (old_value),
number))
new_value_ok = 1;
}
}
else if (strncmp (value, "--", 2) == 0)
{
error = NULL;
number = strtol (value + 2, &error, 10);
if (error && !error[0])
{
if (gui_color_assign_by_diff (&value_int,
gui_color_get_name (old_value),
-1 * number))
new_value_ok = 1;
}
}
else
{
if (gui_color_assign (&value_int, value))
new_value_ok = 1;
}
if (new_value_ok)
{
if (old_value_was_null
|| (value_int != old_value))
{
CONFIG_COLOR_DEFAULT(option) = value_int;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
else
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
else
{
if (old_value_was_null)
{
free (option->default_value);
option->default_value = NULL;
}
}
}
break;
case CONFIG_NUM_OPTION_TYPES:
break;
}
if (old_value_was_null && option->default_value)
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
else
{
if (option->null_value_allowed && option->default_value)
{
free (option->default_value);
option->default_value = NULL;
rc = WEECHAT_CONFIG_OPTION_SET_OK_CHANGED;
}
else
rc = WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
}
/* run callback if asked and value was changed */
if ((rc == WEECHAT_CONFIG_OPTION_SET_OK_CHANGED)
&& run_callback && option->callback_change)
{
(void) (option->callback_change) (
option->callback_change_pointer,
option->callback_change_data,
option);
}
/* run config hook(s) */
if ((rc != WEECHAT_CONFIG_OPTION_SET_ERROR)
&& option->config_file && option->section)
{
config_file_hook_config_exec (option);
}
return rc;
}
/*
* Unsets/resets an option.
*
+3
View File
@@ -286,6 +286,9 @@ extern int config_file_option_set (struct t_config_option *option,
const char *value, int run_callback);
extern int config_file_option_set_null (struct t_config_option *option,
int run_callback);
extern int config_file_option_set_default (struct t_config_option *option,
const char *value,
int run_callback);
extern int config_file_option_toggle (struct t_config_option *option,
const char **values, int num_values,
int run_callback);
+321 -315
View File
File diff suppressed because it is too large Load Diff
+12
View File
@@ -127,11 +127,23 @@ struct t_config_look_word_char_item
};
extern struct t_config_file *weechat_config_file;
extern struct t_config_section *weechat_config_section_debug;
extern struct t_config_section *weechat_config_section_startup;
extern struct t_config_section *weechat_config_section_look;
extern struct t_config_section *weechat_config_section_palette;
extern struct t_config_section *weechat_config_section_color;
extern struct t_config_section *weechat_config_section_completion;
extern struct t_config_section *weechat_config_section_history;
extern struct t_config_section *weechat_config_section_network;
extern struct t_config_section *weechat_config_section_proxy;
extern struct t_config_section *weechat_config_section_plugin;
extern struct t_config_section *weechat_config_section_signal;
extern struct t_config_section *weechat_config_section_bar;
extern struct t_config_section *weechat_config_section_custom_bar_item;
extern struct t_config_section *weechat_config_section_layout;
extern struct t_config_section *weechat_config_section_notify;
extern struct t_config_section *weechat_config_section_filter;
extern struct t_config_section *weechat_config_section_key[];
extern struct t_config_option *config_startup_command_after_plugins;
+313 -141
View File
@@ -40,10 +40,80 @@ extern int config_file_string_boolean_is_valid (const char *text);
extern const char *config_file_option_escape (const char *name);
}
struct t_config_option *ptr_option_bool = NULL;
struct t_config_option *ptr_option_int = NULL;
struct t_config_option *ptr_option_int_str = NULL;
struct t_config_option *ptr_option_str = NULL;
struct t_config_option *ptr_option_col = NULL;
TEST_GROUP(CoreConfigFile)
{
};
TEST_GROUP(CoreConfigFileWithNewOptions)
{
static int option_str_check_cb (const void *pointer,
void *data,
struct t_config_option *option,
const char *value)
{
(void) pointer;
(void) data;
(void) option;
return ((strcmp (value, "xxx") == 0) || (strcmp (value, "zzz") == 0)) ?
0 : 1;
}
void setup ()
{
ptr_option_bool = config_file_new_option (
weechat_config_file, weechat_config_section_look,
"test_boolean", "boolean", "", NULL, 0, 0, "off", NULL, 0,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
ptr_option_int = config_file_new_option (
weechat_config_file, weechat_config_section_look,
"test_integer", "integer", "", NULL, 0, 123456, "100", NULL, 0,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
ptr_option_int_str = config_file_new_option (
weechat_config_file, weechat_config_section_look,
"test_integer_values", "integer", "", "v1|v2|v3", 0, 0, "v1", NULL, 0,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
ptr_option_str = config_file_new_option (
weechat_config_file, weechat_config_section_look,
"test_string", "string", "", NULL, 0, 0, "value", NULL, 0,
&option_str_check_cb, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
ptr_option_col = config_file_new_option (
weechat_config_file, weechat_config_section_color,
"test_color", "color", "", NULL, 0, 0, "blue", NULL, 0,
NULL, NULL, NULL,
NULL, NULL, NULL,
NULL, NULL, NULL);
}
void teardown ()
{
config_file_option_free (ptr_option_bool, 0);
ptr_option_bool = NULL;
config_file_option_free (ptr_option_int, 0);
ptr_option_int = NULL;
config_file_option_free (ptr_option_int_str, 0);
ptr_option_int_str = NULL;
config_file_option_free (ptr_option_str, 0);
ptr_option_str = NULL;
config_file_option_free (ptr_option_col, 0);
ptr_option_col = NULL;
}
};
/*
* Tests functions:
* config_file_valid
@@ -496,11 +566,11 @@ TEST(CoreConfigFile, StringToBoolean)
/*
* Tests functions:
* config_file_option_reset
* config_file_option_set
* config_file_option_reset
*/
TEST(CoreConfigFile, OptionReset)
TEST(CoreConfigFileWithNewOptions, OptionSetReset)
{
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_reset (NULL, 1));
@@ -508,104 +578,101 @@ TEST(CoreConfigFile, OptionReset)
config_file_option_set (NULL, NULL, 1));
/* boolean */
LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit));
LONGS_EQUAL(0, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set (config_look_confirm_quit, "zzz", 1));
config_file_option_set (ptr_option_bool, "zzz", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_look_confirm_quit, "on", 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_set (ptr_option_bool, "on", 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_look_confirm_quit, "toggle", 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_set (ptr_option_bool, "toggle", 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_look_confirm_quit, "toggle", 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_set (ptr_option_bool, "toggle", 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_reset (config_look_confirm_quit, 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_reset (ptr_option_bool, 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(ptr_option_bool));
/* integer */
LONGS_EQUAL(100, CONFIG_INTEGER(config_look_mouse_timer_delay));
LONGS_EQUAL(100, CONFIG_INTEGER(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set (config_look_mouse_timer_delay, "zzz", 1));
config_file_option_set (ptr_option_int, "zzz", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set (config_look_mouse_timer_delay, "-500", 1));
config_file_option_set (ptr_option_int, "-500", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set (config_look_mouse_timer_delay, "99999999", 1));
config_file_option_set (ptr_option_int, "99999999", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_look_mouse_timer_delay, "50", 1));
LONGS_EQUAL(50, CONFIG_INTEGER(config_look_mouse_timer_delay));
config_file_option_set (ptr_option_int, "50", 1));
LONGS_EQUAL(50, CONFIG_INTEGER(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_look_mouse_timer_delay, "++15", 1));
LONGS_EQUAL(65, CONFIG_INTEGER(config_look_mouse_timer_delay));
config_file_option_set (ptr_option_int, "++15", 1));
LONGS_EQUAL(65, CONFIG_INTEGER(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_look_mouse_timer_delay, "--3", 1));
LONGS_EQUAL(62, CONFIG_INTEGER(config_look_mouse_timer_delay));
config_file_option_set (ptr_option_int, "--3", 1));
LONGS_EQUAL(62, CONFIG_INTEGER(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_reset (config_look_mouse_timer_delay, 1));
LONGS_EQUAL(100, CONFIG_INTEGER(config_look_mouse_timer_delay));
config_file_option_reset (ptr_option_int, 1));
LONGS_EQUAL(100, CONFIG_INTEGER(ptr_option_int));
/* integer with string values */
LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_MESSAGE,
CONFIG_INTEGER(config_look_align_end_of_lines));
LONGS_EQUAL(0, CONFIG_INTEGER(ptr_option_int_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set (config_look_align_end_of_lines, "zzz", 1));
config_file_option_set (ptr_option_int_str, "zzz", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_look_align_end_of_lines, "time", 1));
LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_TIME,
CONFIG_INTEGER(config_look_align_end_of_lines));
config_file_option_set (ptr_option_int_str, "v2", 1));
LONGS_EQUAL(1, CONFIG_INTEGER(ptr_option_int_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_reset (config_look_align_end_of_lines, 1));
LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_MESSAGE,
CONFIG_INTEGER(config_look_align_end_of_lines));
config_file_option_reset (ptr_option_int_str, 1));
LONGS_EQUAL(0, CONFIG_INTEGER(ptr_option_int_str));
/* string */
STRCMP_EQUAL("-", CONFIG_STRING(config_look_separator_horizontal));
STRCMP_EQUAL("value", CONFIG_STRING(ptr_option_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set (config_look_separator_horizontal, "zzz", 1));
config_file_option_set (ptr_option_str, "xxx", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_look_separator_horizontal, "+", 1));
STRCMP_EQUAL("+", CONFIG_STRING(config_look_separator_horizontal));
config_file_option_set (ptr_option_str, "test", 1));
STRCMP_EQUAL("test", CONFIG_STRING(ptr_option_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_reset (config_look_separator_horizontal, 1));
STRCMP_EQUAL("-", CONFIG_STRING(config_look_separator_horizontal));
config_file_option_reset (ptr_option_str, 1));
STRCMP_EQUAL("value", CONFIG_STRING(ptr_option_str));
/* color */
LONGS_EQUAL(0, CONFIG_COLOR(config_color_chat));
LONGS_EQUAL(9, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set (config_color_chat, "zzz", 1));
config_file_option_set (ptr_option_col, "zzz", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, "red", 1));
LONGS_EQUAL(3, CONFIG_COLOR(config_color_chat));
config_file_option_set (ptr_option_col, "red", 1));
LONGS_EQUAL(3, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, "++5", 1));
LONGS_EQUAL(8, CONFIG_COLOR(config_color_chat));
config_file_option_set (ptr_option_col, "++5", 1));
LONGS_EQUAL(8, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, "--3", 1));
LONGS_EQUAL(5, CONFIG_COLOR(config_color_chat));
config_file_option_set (ptr_option_col, "--3", 1));
LONGS_EQUAL(5, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, "%red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_BLINK_FLAG, CONFIG_COLOR(config_color_chat));
config_file_option_set (ptr_option_col, "%red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_BLINK_FLAG, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, ".red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_DIM_FLAG, CONFIG_COLOR(config_color_chat));
config_file_option_set (ptr_option_col, ".red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_DIM_FLAG, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, "*red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_BOLD_FLAG, CONFIG_COLOR(config_color_chat));
config_file_option_set (ptr_option_col, "*red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_BOLD_FLAG, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, "!red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_REVERSE_FLAG, CONFIG_COLOR(config_color_chat));
config_file_option_set (ptr_option_col, "!red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_REVERSE_FLAG, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, "/red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_ITALIC_FLAG, CONFIG_COLOR(config_color_chat));
config_file_option_set (ptr_option_col, "/red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_ITALIC_FLAG, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, "_red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_UNDERLINE_FLAG, CONFIG_COLOR(config_color_chat));
config_file_option_set (ptr_option_col, "_red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_UNDERLINE_FLAG, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, "|red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_KEEPATTR_FLAG, CONFIG_COLOR(config_color_chat));
config_file_option_set (ptr_option_col, "|red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_KEEPATTR_FLAG, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set (config_color_chat, "%.*!/_|red", 1));
config_file_option_set (ptr_option_col, "%.*!/_|red", 1));
LONGS_EQUAL(3
| GUI_COLOR_EXTENDED_BLINK_FLAG
| GUI_COLOR_EXTENDED_DIM_FLAG
@@ -614,11 +681,10 @@ TEST(CoreConfigFile, OptionReset)
| GUI_COLOR_EXTENDED_ITALIC_FLAG
| GUI_COLOR_EXTENDED_UNDERLINE_FLAG
| GUI_COLOR_EXTENDED_KEEPATTR_FLAG,
CONFIG_COLOR(config_color_chat));
CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_reset (config_color_chat, 1));
LONGS_EQUAL(0, CONFIG_COLOR(config_color_chat));
config_file_option_reset (ptr_option_col, 1));
LONGS_EQUAL(9, CONFIG_COLOR(ptr_option_col));
}
/*
@@ -626,7 +692,7 @@ TEST(CoreConfigFile, OptionReset)
* config_file_option_toggle
*/
TEST(CoreConfigFile, OptionToggle)
TEST(CoreConfigFileWithNewOptions, OptionToggle)
{
const char *value_boolean_ok[] = { "on", NULL };
const char *values_boolean_ok[] = { "on", "off", NULL };
@@ -634,156 +700,151 @@ TEST(CoreConfigFile, OptionToggle)
const char *value_integer_ok[] = { "50", NULL };
const char *values_integer_ok[] = { "75", "92", NULL };
const char *values_integer_error[] = { "-500", "99999999", NULL };
const char *value_integer_str_ok[] = { "time", NULL };
const char *values_integer_str_ok[] = { "prefix", "suffix", NULL };
const char *value_integer_str_ok[] = { "v2", NULL };
const char *values_integer_str_ok[] = { "v2", "v3", NULL };
const char *values_integer_str_error[] = { "xxx", "zzz", NULL };
const char *value_string_ok[] = { "+", NULL };
const char *values_string_ok[] = { "$", "*", NULL };
const char *values_string_error[] = { "xxx", "zzz", NULL };
const char *value_color_ok[] = { "red", NULL };
const char *values_color_ok[] = { "green", "blue", NULL };
const char *values_color_ok[] = { "green", "cyan", NULL };
const char *values_color_error[] = { "xxx", "zzz", NULL };
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_toggle (NULL, NULL, 0, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_toggle (config_look_confirm_quit, NULL, -1, 1));
config_file_option_toggle (ptr_option_bool, NULL, -1, 1));
/* boolean */
LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit));
LONGS_EQUAL(0, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_toggle (config_look_confirm_quit,
config_file_option_toggle (ptr_option_bool,
values_boolean_error, 2, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_confirm_quit, NULL, 0, 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_toggle (ptr_option_bool, NULL, 0, 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_confirm_quit, NULL, 0, 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_toggle (ptr_option_bool, NULL, 0, 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_confirm_quit, value_boolean_ok, 1, 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_toggle (ptr_option_bool, value_boolean_ok, 1, 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_confirm_quit, value_boolean_ok, 1, 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_toggle (ptr_option_bool, value_boolean_ok, 1, 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_confirm_quit, values_boolean_ok, 2, 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_toggle (ptr_option_bool, values_boolean_ok, 2, 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_confirm_quit, values_boolean_ok, 2, 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_toggle (ptr_option_bool, values_boolean_ok, 2, 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE,
config_file_option_reset (config_look_confirm_quit, 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(config_look_confirm_quit));
config_file_option_reset (ptr_option_bool, 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN(ptr_option_bool));
/* integer */
LONGS_EQUAL(100, CONFIG_INTEGER(config_look_mouse_timer_delay));
LONGS_EQUAL(100, CONFIG_INTEGER(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_toggle (config_look_mouse_timer_delay,
config_file_option_toggle (ptr_option_int,
values_integer_error, 2, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_toggle (config_look_mouse_timer_delay,
config_file_option_toggle (ptr_option_int,
NULL, 0, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_mouse_timer_delay,
config_file_option_toggle (ptr_option_int,
value_integer_ok, 1, 1));
LONGS_EQUAL(50, CONFIG_INTEGER(config_look_mouse_timer_delay));
LONGS_EQUAL(50, CONFIG_INTEGER(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_mouse_timer_delay,
config_file_option_toggle (ptr_option_int,
value_integer_ok, 1, 1));
LONGS_EQUAL(100, CONFIG_INTEGER(config_look_mouse_timer_delay));
LONGS_EQUAL(100, CONFIG_INTEGER(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_mouse_timer_delay,
config_file_option_toggle (ptr_option_int,
values_integer_ok, 2, 1));
LONGS_EQUAL(75, CONFIG_INTEGER(config_look_mouse_timer_delay));
LONGS_EQUAL(75, CONFIG_INTEGER(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_mouse_timer_delay,
config_file_option_toggle (ptr_option_int,
values_integer_ok, 2, 1));
LONGS_EQUAL(92, CONFIG_INTEGER(config_look_mouse_timer_delay));
LONGS_EQUAL(92, CONFIG_INTEGER(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_reset (config_look_mouse_timer_delay, 1));
LONGS_EQUAL(100, CONFIG_INTEGER(config_look_mouse_timer_delay));
config_file_option_reset (ptr_option_int, 1));
LONGS_EQUAL(100, CONFIG_INTEGER(ptr_option_int));
/* integer with string values */
LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_MESSAGE,
CONFIG_INTEGER(config_look_align_end_of_lines));
LONGS_EQUAL(0, CONFIG_INTEGER(ptr_option_int_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_toggle (config_look_align_end_of_lines,
config_file_option_toggle (ptr_option_int_str,
values_integer_str_error, 2, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_toggle (config_look_align_end_of_lines,
config_file_option_toggle (ptr_option_int_str,
NULL, 0, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_align_end_of_lines,
config_file_option_toggle (ptr_option_int_str,
value_integer_str_ok, 1, 1));
LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_TIME,
CONFIG_INTEGER(config_look_align_end_of_lines));
LONGS_EQUAL(1, CONFIG_INTEGER(ptr_option_int_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_align_end_of_lines,
config_file_option_toggle (ptr_option_int_str,
values_integer_str_ok, 2, 1));
LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_PREFIX,
CONFIG_INTEGER(config_look_align_end_of_lines));
LONGS_EQUAL(2, CONFIG_INTEGER(ptr_option_int_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_align_end_of_lines,
config_file_option_toggle (ptr_option_int_str,
values_integer_str_ok, 2, 1));
LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_SUFFIX,
CONFIG_INTEGER(config_look_align_end_of_lines));
LONGS_EQUAL(1, CONFIG_INTEGER(ptr_option_int_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_reset (config_look_align_end_of_lines, 1));
LONGS_EQUAL(CONFIG_LOOK_ALIGN_END_OF_LINES_MESSAGE,
CONFIG_INTEGER(config_look_align_end_of_lines));
config_file_option_reset (ptr_option_int_str, 1));
LONGS_EQUAL(0, CONFIG_INTEGER(ptr_option_int_str));
/* string */
STRCMP_EQUAL("-", CONFIG_STRING(config_look_separator_horizontal));
STRCMP_EQUAL("value", CONFIG_STRING(ptr_option_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_toggle (config_look_separator_horizontal,
config_file_option_toggle (ptr_option_str,
values_string_error, 2, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_separator_horizontal,
config_file_option_toggle (ptr_option_str,
NULL, 0, 1));
STRCMP_EQUAL("", CONFIG_STRING(config_look_separator_horizontal));
STRCMP_EQUAL("", CONFIG_STRING(ptr_option_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_separator_horizontal,
config_file_option_toggle (ptr_option_str,
NULL, 0, 1));
STRCMP_EQUAL("-", CONFIG_STRING(config_look_separator_horizontal));
STRCMP_EQUAL("value", CONFIG_STRING(ptr_option_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_separator_horizontal,
config_file_option_toggle (ptr_option_str,
value_string_ok, 1, 1));
STRCMP_EQUAL("+", CONFIG_STRING(config_look_separator_horizontal));
STRCMP_EQUAL("+", CONFIG_STRING(ptr_option_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_separator_horizontal,
config_file_option_toggle (ptr_option_str,
values_string_ok, 2, 1));
STRCMP_EQUAL("$", CONFIG_STRING(config_look_separator_horizontal));
STRCMP_EQUAL("$", CONFIG_STRING(ptr_option_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_look_separator_horizontal,
config_file_option_toggle (ptr_option_str,
values_string_ok, 2, 1));
STRCMP_EQUAL("*", CONFIG_STRING(config_look_separator_horizontal));
STRCMP_EQUAL("*", CONFIG_STRING(ptr_option_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_reset (config_look_separator_horizontal, 1));
STRCMP_EQUAL("-", CONFIG_STRING(config_look_separator_horizontal));
config_file_option_reset (ptr_option_str, 1));
STRCMP_EQUAL("value", CONFIG_STRING(ptr_option_str));
/* color */
LONGS_EQUAL(0, CONFIG_COLOR(config_color_chat));
LONGS_EQUAL(9, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_toggle (config_color_chat,
config_file_option_toggle (ptr_option_col,
values_color_error, 2, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_toggle (config_color_chat, NULL, 0, 1));
config_file_option_toggle (ptr_option_col, NULL, 0, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_color_chat,
config_file_option_toggle (ptr_option_col,
value_color_ok, 1, 1));
LONGS_EQUAL(3, CONFIG_COLOR(config_color_chat));
LONGS_EQUAL(3, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_color_chat,
config_file_option_toggle (ptr_option_col,
values_color_ok, 2, 1));
LONGS_EQUAL(5, CONFIG_COLOR(config_color_chat));
LONGS_EQUAL(5, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_toggle (config_color_chat,
config_file_option_toggle (ptr_option_col,
values_color_ok, 2, 1));
LONGS_EQUAL(9, CONFIG_COLOR(config_color_chat));
LONGS_EQUAL(13, CONFIG_COLOR(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_reset (config_color_chat, 1));
LONGS_EQUAL(0, CONFIG_COLOR(config_color_chat));
config_file_option_reset (ptr_option_col, 1));
LONGS_EQUAL(9, CONFIG_COLOR(ptr_option_col));
}
/*
@@ -796,6 +857,117 @@ TEST(CoreConfigFile, OptionSetNull)
/* TODO: write tests */
}
/*
* Tests functions:
* config_file_option_set_default
*/
TEST(CoreConfigFileWithNewOptions, OptionSetDefault)
{
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set_default (NULL, NULL, 1));
/* boolean */
LONGS_EQUAL(0, CONFIG_BOOLEAN_DEFAULT(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE,
config_file_option_set_default (ptr_option_bool, NULL, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set_default (ptr_option_bool, "zzz", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_bool, "on", 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN_DEFAULT(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_bool, "toggle", 1));
LONGS_EQUAL(0, CONFIG_BOOLEAN_DEFAULT(ptr_option_bool));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_bool, "toggle", 1));
LONGS_EQUAL(1, CONFIG_BOOLEAN_DEFAULT(ptr_option_bool));
/* integer */
LONGS_EQUAL(100, CONFIG_INTEGER_DEFAULT(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE,
config_file_option_set_default (ptr_option_int, NULL, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set_default (ptr_option_int, "zzz", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set_default (ptr_option_int, "-500", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set_default (ptr_option_int, "99999999", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_int, "50", 1));
LONGS_EQUAL(50, CONFIG_INTEGER_DEFAULT(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_int, "++15", 1));
LONGS_EQUAL(65, CONFIG_INTEGER_DEFAULT(ptr_option_int));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_int, "--3", 1));
LONGS_EQUAL(62, CONFIG_INTEGER_DEFAULT(ptr_option_int));
/* integer with string values */
LONGS_EQUAL(0, CONFIG_INTEGER_DEFAULT(ptr_option_int_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE,
config_file_option_set_default (ptr_option_int_str, NULL, 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set_default (ptr_option_int_str, "zzz", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_int_str, "v2", 1));
LONGS_EQUAL(1, CONFIG_INTEGER_DEFAULT(ptr_option_int_str));
/* string */
STRCMP_EQUAL("value", CONFIG_STRING_DEFAULT(ptr_option_str));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set_default (ptr_option_str, "xxx", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_str, "test", 1));
STRCMP_EQUAL("test", CONFIG_STRING_DEFAULT(ptr_option_str));
/* color */
LONGS_EQUAL(9, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_ERROR,
config_file_option_set_default (ptr_option_col, "zzz", 1));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, "red", 1));
LONGS_EQUAL(3, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, "++5", 1));
LONGS_EQUAL(8, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, "--3", 1));
LONGS_EQUAL(5, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, "%red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_BLINK_FLAG, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, ".red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_DIM_FLAG, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, "*red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_BOLD_FLAG, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, "!red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_REVERSE_FLAG, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, "/red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_ITALIC_FLAG, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, "_red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_UNDERLINE_FLAG, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, "|red", 1));
LONGS_EQUAL(3 | GUI_COLOR_EXTENDED_KEEPATTR_FLAG, CONFIG_COLOR_DEFAULT(ptr_option_col));
LONGS_EQUAL(WEECHAT_CONFIG_OPTION_SET_OK_CHANGED,
config_file_option_set_default (ptr_option_col, "%.*!/_|red", 1));
LONGS_EQUAL(3
| GUI_COLOR_EXTENDED_BLINK_FLAG
| GUI_COLOR_EXTENDED_DIM_FLAG
| GUI_COLOR_EXTENDED_BOLD_FLAG
| GUI_COLOR_EXTENDED_REVERSE_FLAG
| GUI_COLOR_EXTENDED_ITALIC_FLAG
| GUI_COLOR_EXTENDED_UNDERLINE_FLAG
| GUI_COLOR_EXTENDED_KEEPATTR_FLAG,
CONFIG_COLOR_DEFAULT(ptr_option_col));
}
/*
* Tests functions:
* config_file_option_unset