Use defaults for /statuses commands
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
void create_config_dir(void **state);
|
||||
void delete_config_dir(void **state);
|
||||
|
||||
void cmd_statuses_shows_usage_when_bad_subcmd(void **state);
|
||||
void cmd_statuses_shows_usage_when_bad_console_setting(void **state);
|
||||
void cmd_statuses_shows_usage_when_bad_chat_setting(void **state);
|
||||
|
||||
41
tests/test_preferences.c
Normal file
41
tests/test_preferences.c
Normal file
@@ -0,0 +1,41 @@
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
|
||||
#include "config/preferences.h"
|
||||
|
||||
void statuses_console_defaults_to_all(void **state)
|
||||
{
|
||||
prefs_load();
|
||||
char *setting = prefs_get_string(PREF_STATUSES_CONSOLE);
|
||||
|
||||
assert_non_null(setting);
|
||||
assert_string_equal("all", setting);
|
||||
|
||||
prefs_close();
|
||||
}
|
||||
|
||||
void statuses_chat_defaults_to_all(void **state)
|
||||
{
|
||||
prefs_load();
|
||||
char *setting = prefs_get_string(PREF_STATUSES_CHAT);
|
||||
|
||||
assert_non_null(setting);
|
||||
assert_string_equal("all", setting);
|
||||
|
||||
prefs_close();
|
||||
}
|
||||
|
||||
void statuses_muc_defaults_to_on(void **state)
|
||||
{
|
||||
prefs_load();
|
||||
gboolean setting = prefs_get_boolean(PREF_STATUSES_MUC);
|
||||
|
||||
assert_true(setting);
|
||||
|
||||
prefs_close();
|
||||
}
|
||||
3
tests/test_preferences.h
Normal file
3
tests/test_preferences.h
Normal file
@@ -0,0 +1,3 @@
|
||||
void statuses_console_defaults_to_all(void **state);
|
||||
void statuses_chat_defaults_to_all(void **state);
|
||||
void statuses_muc_defaults_to_on(void **state);
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "test_jid.h"
|
||||
#include "test_parser.h"
|
||||
#include "test_roster_list.h"
|
||||
#include "test_preferences.h"
|
||||
|
||||
#define PROF_RUN_TESTS(name) fprintf(stderr, "\n-> Running %s\n", #name); \
|
||||
fflush(stderr); \
|
||||
@@ -356,6 +357,18 @@ int main(int argc, char* argv[]) {
|
||||
delete_config_dir),
|
||||
};
|
||||
|
||||
const UnitTest preferences_tests[] = {
|
||||
unit_test_setup_teardown(statuses_console_defaults_to_all,
|
||||
create_config_dir,
|
||||
delete_config_dir),
|
||||
unit_test_setup_teardown(statuses_chat_defaults_to_all,
|
||||
create_config_dir,
|
||||
delete_config_dir),
|
||||
unit_test_setup_teardown(statuses_muc_defaults_to_on,
|
||||
create_config_dir,
|
||||
delete_config_dir),
|
||||
};
|
||||
|
||||
int bak, new;
|
||||
fflush(stdout);
|
||||
bak = dup(1);
|
||||
@@ -377,6 +390,7 @@ int main(int argc, char* argv[]) {
|
||||
PROF_RUN_TESTS(cmd_sub_tests);
|
||||
PROF_RUN_TESTS(contact_tests);
|
||||
PROF_RUN_TESTS(cmd_statuses_tests);
|
||||
PROF_RUN_TESTS(preferences_tests);
|
||||
|
||||
fflush(stdout);
|
||||
dup2(bak, 1);
|
||||
|
||||
Reference in New Issue
Block a user