mirror of
https://git.jabber.space/devs/cproof.git
synced 2026-07-27 21:56:21 +00:00
Use defaults for /statuses commands
This commit is contained in:
@@ -79,6 +79,7 @@ test_sources = \
|
|||||||
tests/test_jid.c \
|
tests/test_jid.c \
|
||||||
tests/test_parser.c \
|
tests/test_parser.c \
|
||||||
tests/test_roster_list.c \
|
tests/test_roster_list.c \
|
||||||
|
tests/test_preferences.c \
|
||||||
tests/testsuite.c
|
tests/testsuite.c
|
||||||
|
|
||||||
main_source = src/main.c
|
main_source = src/main.c
|
||||||
|
|||||||
@@ -393,6 +393,7 @@ _get_default_boolean(preference_t pref)
|
|||||||
case PREF_STATUSES:
|
case PREF_STATUSES:
|
||||||
case PREF_AUTOAWAY_CHECK:
|
case PREF_AUTOAWAY_CHECK:
|
||||||
case PREF_OTR_WARN:
|
case PREF_OTR_WARN:
|
||||||
|
case PREF_STATUSES_MUC:
|
||||||
return TRUE;
|
return TRUE;
|
||||||
default:
|
default:
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -408,6 +409,9 @@ _get_default_string(preference_t pref)
|
|||||||
return "off";
|
return "off";
|
||||||
case PREF_OTR_LOG:
|
case PREF_OTR_LOG:
|
||||||
return "redact";
|
return "redact";
|
||||||
|
case PREF_STATUSES_CONSOLE:
|
||||||
|
case PREF_STATUSES_CHAT:
|
||||||
|
return "all";
|
||||||
default:
|
default:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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_subcmd(void **state);
|
||||||
void cmd_statuses_shows_usage_when_bad_console_setting(void **state);
|
void cmd_statuses_shows_usage_when_bad_console_setting(void **state);
|
||||||
void cmd_statuses_shows_usage_when_bad_chat_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_jid.h"
|
||||||
#include "test_parser.h"
|
#include "test_parser.h"
|
||||||
#include "test_roster_list.h"
|
#include "test_roster_list.h"
|
||||||
|
#include "test_preferences.h"
|
||||||
|
|
||||||
#define PROF_RUN_TESTS(name) fprintf(stderr, "\n-> Running %s\n", #name); \
|
#define PROF_RUN_TESTS(name) fprintf(stderr, "\n-> Running %s\n", #name); \
|
||||||
fflush(stderr); \
|
fflush(stderr); \
|
||||||
@@ -356,6 +357,18 @@ int main(int argc, char* argv[]) {
|
|||||||
delete_config_dir),
|
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;
|
int bak, new;
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
bak = dup(1);
|
bak = dup(1);
|
||||||
@@ -377,6 +390,7 @@ int main(int argc, char* argv[]) {
|
|||||||
PROF_RUN_TESTS(cmd_sub_tests);
|
PROF_RUN_TESTS(cmd_sub_tests);
|
||||||
PROF_RUN_TESTS(contact_tests);
|
PROF_RUN_TESTS(contact_tests);
|
||||||
PROF_RUN_TESTS(cmd_statuses_tests);
|
PROF_RUN_TESTS(cmd_statuses_tests);
|
||||||
|
PROF_RUN_TESTS(preferences_tests);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
dup2(bak, 1);
|
dup2(bak, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user