diff options
Diffstat (limited to 'tests')
66 files changed, 4364 insertions, 2522 deletions
diff --git a/tests/unittests/config/stub_accounts.c b/tests/unittests/config/stub_accounts.c index ce2c3379..19a0bdcb 100644 --- a/tests/unittests/config/stub_accounts.c +++ b/tests/unittests/config/stub_accounts.c @@ -6,202 +6,309 @@ #include "common.h" #include "config/account.h" -void accounts_load(void) {} -void accounts_close(void) {} +void +accounts_load(void) +{ +} +void +accounts_close(void) +{ +} -char * accounts_find_all(char *prefix) +char* +accounts_find_all(char* prefix) { return NULL; } -char * accounts_find_enabled(char *prefix, void *context) +char* +accounts_find_enabled(char* prefix, void* context) { return NULL; } -void accounts_reset_all_search(void) {} -void accounts_reset_enabled_search(void) {} +void +accounts_reset_all_search(void) +{ +} +void +accounts_reset_enabled_search(void) +{ +} -void accounts_add(const char *jid, const char *altdomain, const int port) +void +accounts_add(const char* jid, const char* altdomain, const int port) { check_expected(jid); check_expected(altdomain); check_expected(port); } -int accounts_remove(const char *jid) +int +accounts_remove(const char* jid) { return 0; } -gchar** accounts_get_list(void) +gchar** +accounts_get_list(void) { - return mock_ptr_type(gchar **); + return mock_ptr_type(gchar**); } -ProfAccount* accounts_get_account(const char * const name) +ProfAccount* +accounts_get_account(const char* const name) { check_expected(name); return mock_ptr_type(ProfAccount*); } -gboolean accounts_enable(const char * const name) +gboolean +accounts_enable(const char* const name) { check_expected(name); return mock_type(gboolean); } -gboolean accounts_disable(const char * const name) +gboolean +accounts_disable(const char* const name) { check_expected(name); return mock_type(gboolean); } -gboolean accounts_rename(const char * const account_name, - const char * const new_name) +gboolean +accounts_rename(const char* const account_name, + const char* const new_name) { check_expected(account_name); check_expected(new_name); return mock_type(gboolean); } -gboolean accounts_account_exists(const char * const account_name) +gboolean +accounts_account_exists(const char* const account_name) { check_expected(account_name); return mock_type(gboolean); } -void accounts_set_jid(const char * const account_name, const char * const value) +void +accounts_set_jid(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_server(const char * const account_name, const char * const value) +void +accounts_set_server(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_port(const char * const account_name, const int value) {} +void +accounts_set_port(const char* const account_name, const int value) +{ +} -void accounts_set_resource(const char * const account_name, const char * const value) +void +accounts_set_resource(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_password(const char * const account_name, const char * const value) +void +accounts_set_password(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_eval_password(const char * const account_name, const char * const value) +void +accounts_set_eval_password(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_muc_service(const char * const account_name, const char * const value) +void +accounts_set_muc_service(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_muc_nick(const char * const account_name, const char * const value) +void +accounts_set_muc_nick(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_otr_policy(const char * const account_name, const char * const value) +void +accounts_set_otr_policy(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -void accounts_set_last_presence(const char * const account_name, const char * const value) {} -void accounts_set_last_status(const char * const account_name, const char * const value) {} -void accounts_set_last_activity(const char * const account_name) {} -void accounts_set_pgp_keyid(const char * const account_name, const char * const value) {} -void accounts_set_script_start(const char * const account_name, const char * const value) {} -void accounts_set_theme(const char * const account_name, const char * const value) {} -void accounts_set_tls_policy(const char * const account_name, const char * const value) {} -void accounts_set_auth_policy(const char * const account_name, const char * const value) {} +void +accounts_set_last_presence(const char* const account_name, const char* const value) +{ +} +void +accounts_set_last_status(const char* const account_name, const char* const value) +{ +} +void +accounts_set_last_activity(const char* const account_name) +{ +} +void +accounts_set_pgp_keyid(const char* const account_name, const char* const value) +{ +} +void +accounts_set_script_start(const char* const account_name, const char* const value) +{ +} +void +accounts_set_theme(const char* const account_name, const char* const value) +{ +} +void +accounts_set_tls_policy(const char* const account_name, const char* const value) +{ +} +void +accounts_set_auth_policy(const char* const account_name, const char* const value) +{ +} -void accounts_set_login_presence(const char * const account_name, const char * const value) +void +accounts_set_login_presence(const char* const account_name, const char* const value) { check_expected(account_name); check_expected(value); } -resource_presence_t accounts_get_login_presence(const char * const account_name) +resource_presence_t +accounts_get_login_presence(const char* const account_name) { return RESOURCE_ONLINE; } -char * accounts_get_last_status(const char * const account_name) +char* +accounts_get_last_status(const char* const account_name) { return NULL; } -resource_presence_t accounts_get_last_presence(const char * const account_name) +resource_presence_t +accounts_get_last_presence(const char* const account_name) { check_expected(account_name); return mock_type(resource_presence_t); } -void accounts_set_priority_online(const char * const account_name, const gint value) +void +accounts_set_priority_online(const char* const account_name, const gint value) { check_expected(account_name); check_expected(value); } -void accounts_set_priority_chat(const char * const account_name, const gint value) +void +accounts_set_priority_chat(const char* const account_name, const gint value) { check_expected(account_name); check_expected(value); } -void accounts_set_priority_away(const char * const account_name, const gint value) +void +accounts_set_priority_away(const char* const account_name, const gint value) { check_expected(account_name); check_expected(value); } -void accounts_set_priority_xa(const char * const account_name, const gint value) +void +accounts_set_priority_xa(const char* const account_name, const gint value) { check_expected(account_name); check_expected(value); } -void accounts_set_priority_dnd(const char * const account_name, const gint value) +void +accounts_set_priority_dnd(const char* const account_name, const gint value) { check_expected(account_name); check_expected(value); } -void accounts_set_priority_all(const char * const account_name, const gint value) {} -gint accounts_get_priority_for_presence_type(const char * const account_name, - resource_presence_t presence_type) +void +accounts_set_priority_all(const char* const account_name, const gint value) +{ +} +gint +accounts_get_priority_for_presence_type(const char* const account_name, + resource_presence_t presence_type) { return 0; } -void accounts_clear_password(const char * const account_name) {} -void accounts_clear_eval_password(const char * const account_name) {} -void accounts_clear_server(const char * const account_name) {} -void accounts_clear_port(const char * const account_name) {} -void accounts_clear_otr(const char * const account_name) {} -void accounts_clear_pgp_keyid(const char * const account_name) {} -void accounts_clear_script_start(const char * const account_name) {} -void accounts_clear_theme(const char * const account_name) {} -void accounts_clear_muc(const char * const account_name) {} -void accounts_clear_resource(const char * const account_name) {} -void accounts_add_otr_policy(const char * const account_name, const char * const contact_jid, const char * const policy) {} -char* accounts_get_last_activity(const char *const account_name) +void +accounts_clear_password(const char* const account_name) +{ +} +void +accounts_clear_eval_password(const char* const account_name) +{ +} +void +accounts_clear_server(const char* const account_name) +{ +} +void +accounts_clear_port(const char* const account_name) +{ +} +void +accounts_clear_otr(const char* const account_name) +{ +} +void +accounts_clear_pgp_keyid(const char* const account_name) +{ +} +void +accounts_clear_script_start(const char* const account_name) +{ +} +void +accounts_clear_theme(const char* const account_name) +{ +} +void +accounts_clear_muc(const char* const account_name) +{ +} +void +accounts_clear_resource(const char* const account_name) +{ +} +void +accounts_add_otr_policy(const char* const account_name, const char* const contact_jid, const char* const policy) +{ +} +char* +accounts_get_last_activity(const char* const account_name) { return NULL; } -void accounts_add_omemo_state(const char *const account_name, const char *const contact_jid, gboolean enabled) {} +void +accounts_add_omemo_state(const char* const account_name, const char* const contact_jid, gboolean enabled) +{ +} diff --git a/tests/unittests/database/stub_database.c b/tests/unittests/database/stub_database.c index 4c79c273..15a4478b 100644 --- a/tests/unittests/database/stub_database.c +++ b/tests/unittests/database/stub_database.c @@ -26,9 +26,28 @@ #include "database.h" -gboolean log_database_init(ProfAccount *account) { return TRUE; } -void log_database_add_incoming(ProfMessage *message) {} -void log_database_add_outgoing_chat(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc) {} -void log_database_add_outgoing_muc(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc) {} -void log_database_add_outgoing_muc_pm(const char * const id, const char * const barejid, const char * const message, const char *const replace_id, prof_enc_t enc) {} -void log_database_close(void) {} +gboolean +log_database_init(ProfAccount* account) +{ + return TRUE; +} +void +log_database_add_incoming(ProfMessage* message) +{ +} +void +log_database_add_outgoing_chat(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc) +{ +} +void +log_database_add_outgoing_muc(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc) +{ +} +void +log_database_add_outgoing_muc_pm(const char* const id, const char* const barejid, const char* const message, const char* const replace_id, prof_enc_t enc) +{ +} +void +log_database_close(void) +{ +} diff --git a/tests/unittests/helpers.c b/tests/unittests/helpers.c index e85045e6..e309b559 100644 --- a/tests/unittests/helpers.c +++ b/tests/unittests/helpers.c @@ -12,7 +12,8 @@ #include "config/preferences.h" #include "xmpp/chat_session.h" -void create_config_dir(void **state) +void +create_config_dir(void** state) { setenv("XDG_CONFIG_HOME", "./tests/files/xdg_config_home", 1); if (!mkdir_recursive("./tests/files/xdg_config_home/profanity")) { @@ -20,13 +21,15 @@ void create_config_dir(void **state) } } -void remove_config_dir(void **state) +void +remove_config_dir(void** state) { rmdir("./tests/files/xdg_config_home/profanity"); rmdir("./tests/files/xdg_config_home"); } -void create_data_dir(void **state) +void +create_data_dir(void** state) { setenv("XDG_DATA_HOME", "./tests/files/xdg_data_home", 1); if (!mkdir_recursive("./tests/files/xdg_data_home/profanity")) { @@ -34,23 +37,26 @@ void create_data_dir(void **state) } } -void remove_data_dir(void **state) +void +remove_data_dir(void** state) { rmdir("./tests/files/xdg_data_home/profanity"); rmdir("./tests/files/xdg_data_home"); } -void load_preferences(void **state) +void +load_preferences(void** state) { create_config_dir(state); - FILE *f = fopen("./tests/files/xdg_config_home/profanity/profrc", "ab+"); + FILE* f = fopen("./tests/files/xdg_config_home/profanity/profrc", "ab+"); if (f) { prefs_load(NULL); } fclose(f); } -void close_preferences(void **state) +void +close_preferences(void** state) { prefs_close(); remove("./tests/files/xdg_config_home/profanity/profrc"); @@ -58,27 +64,29 @@ void close_preferences(void **state) rmdir("./tests/files"); } -void init_chat_sessions(void **state) +void +init_chat_sessions(void** state) { load_preferences(NULL); chat_sessions_init(); } -void close_chat_sessions(void **state) +void +close_chat_sessions(void** state) { chat_sessions_clear(); close_preferences(NULL); } int -utf8_pos_to_col(char *str, int utf8_pos) +utf8_pos_to_col(char* str, int utf8_pos) { int col = 0; int i = 0; - for (i = 0; i<utf8_pos; i++) { + for (i = 0; i < utf8_pos; i++) { col++; - gchar *ch = g_utf8_offset_to_pointer(str, i); + gchar* ch = g_utf8_offset_to_pointer(str, i); gunichar uni = g_utf8_get_char(ch); if (g_unichar_iswide(uni)) { col++; @@ -97,22 +105,22 @@ glist_set_cmp(GCompareFunc func) } int -glist_contents_equal(const void *actual, const void *expected) +glist_contents_equal(const void* actual, const void* expected) { - GList *ac = (GList *)actual; - GList *ex = (GList *)expected; + GList* ac = (GList*)actual; + GList* ex = (GList*)expected; - GList *p = ex; + GList* p = ex; printf("\nExpected\n"); - while(ex) { + while (ex) { printf("\n\n%s\n", (char*)p->data); ex = g_list_next(ex); } printf("\n\n"); p = ac; printf("\nActual\n"); - while(ac) { - printf("\n\n%s\n", (char *)p->data); + while (ac) { + printf("\n\n%s\n", (char*)p->data); ac = g_list_next(ac); } printf("\n\n"); @@ -121,7 +129,7 @@ glist_contents_equal(const void *actual, const void *expected) return 0; } - GList *ex_curr = ex; + GList* ex_curr = ex; while (ex_curr != NULL) { if (g_list_find_custom(ac, ex_curr->data, cmp_func) == NULL) { return 0; diff --git a/tests/unittests/helpers.h b/tests/unittests/helpers.h index 75d446d0..6c00fb51 100644 --- a/tests/unittests/helpers.h +++ b/tests/unittests/helpers.h @@ -1,12 +1,12 @@ #include "glib.h" -void load_preferences(void **state); -void close_preferences(void **state); +void load_preferences(void** state); +void close_preferences(void** state); -void init_chat_sessions(void **state); -void close_chat_sessions(void **state); +void init_chat_sessions(void** state); +void close_chat_sessions(void** state); -int utf8_pos_to_col(char *str, int utf8_pos); +int utf8_pos_to_col(char* str, int utf8_pos); void glist_set_cmp(GCompareFunc func); -int glist_contents_equal(const void *actual, const void *expected); \ No newline at end of file +int glist_contents_equal(const void* actual, const void* expected); \ No newline at end of file diff --git a/tests/unittests/log/stub_log.c b/tests/unittests/log/stub_log.c index 5861a895..ee3780a7 100644 --- a/tests/unittests/log/stub_log.c +++ b/tests/unittests/log/stub_log.c @@ -26,50 +26,131 @@ #include "log.h" -void log_init(log_level_t filter, char *log_file) {} -log_level_t log_get_filter(void) +void +log_init(log_level_t filter, char* log_file) +{ +} +log_level_t +log_get_filter(void) { return mock_type(log_level_t); } -void log_reinit(void) {} -void log_close(void) {} -void log_debug(const char * const msg, ...) {} -void log_info(const char * const msg, ...) {} -void log_warning(const char * const msg, ...) {} -void log_error(const char * const msg, ...) {} -void log_msg(log_level_t level, const char * const area, const char * const msg) {} +void +log_reinit(void) +{ +} +void +log_close(void) +{ +} +void +log_debug(const char* const msg, ...) +{ +} +void +log_info(const char* const msg, ...) +{ +} +void +log_warning(const char* const msg, ...) +{ +} +void +log_error(const char* const msg, ...) +{ +} +void +log_msg(log_level_t level, const char* const area, const char* const msg) +{ +} -const char * get_log_file_location(void) +const char* +get_log_file_location(void) { - return mock_ptr_type(char *); + return mock_ptr_type(char*); } -log_level_t log_level_from_string(char *log_level) +log_level_t +log_level_from_string(char* log_level) { return mock_type(log_level_t); } -void log_stderr_init(log_level_t level) {} -void log_stderr_close(void) {} -void log_stderr_handler(void) {} +void +log_stderr_init(log_level_t level) +{ +} +void +log_stderr_close(void) +{ +} +void +log_stderr_handler(void) +{ +} -void chat_log_init(void) {} +void +chat_log_init(void) +{ +} -void chat_log_msg_out(const char * const barejid, const char * const msg, const char *const resource) {} -void chat_log_otr_msg_out(const char * const barejid, const char * const msg, const char *const resource) {} -void chat_log_pgp_msg_out(const char * const barejid, const char * const msg, const char *const resource) {} -void chat_log_omemo_msg_out(const char *const barejid, const char *const msg, const char *const resource) {} +void +chat_log_msg_out(const char* const barejid, const char* const msg, const char* const resource) +{ +} +void +chat_log_otr_msg_out(const char* const barejid, const char* const msg, const char* const resource) +{ +} +void +chat_log_pgp_msg_out(const char* const barejid, const char* const msg, const char* const resource) +{ +} +void +chat_log_omemo_msg_out(const char* const barejid, const char* const msg, const char* const resource) +{ +} -void chat_log_msg_in(ProfMessage *message) {} -void chat_log_otr_msg_in(ProfMessage *message) {} -void chat_log_pgp_msg_in(ProfMessage *message) {} -void chat_log_omemo_msg_in(ProfMessage *message) {} +void +chat_log_msg_in(ProfMessage* message) +{ +} +void +chat_log_otr_msg_in(ProfMessage* message) +{ +} +void +chat_log_pgp_msg_in(ProfMessage* message) +{ +} +void +chat_log_omemo_msg_in(ProfMessage* message) +{ +} -void chat_log_close(void) {} +void +chat_log_close(void) +{ +} -void groupchat_log_init(void) {} -void groupchat_log_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg) {} -void groupchat_log_msg_out(const gchar *const room, const gchar *const msg) {} -void groupchat_log_omemo_msg_in(const gchar *const room, const gchar *const nick, const gchar *const msg) {} -void groupchat_log_omemo_msg_out(const gchar *const room, const gchar *const msg) {} +void +groupchat_log_init(void) +{ +} +void +groupchat_log_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg) +{ +} +void +groupchat_log_msg_out(const gchar* const room, const gchar* const msg) +{ +} +void +groupchat_log_omemo_msg_in(const gchar* const room, const gchar* const nick, const gchar* const msg) +{ +} +void +groupchat_log_omemo_msg_out(const gchar* const room, const gchar* const msg) +{ +} diff --git a/tests/unittests/omemo/stub_omemo.c b/tests/unittests/omemo/stub_omemo.c index fe5d27c5..448d5a0d 100644 --- a/tests/unittests/omemo/stub_omemo.c +++ b/tests/unittests/omemo/stub_omemo.c @@ -3,39 +3,51 @@ #include "config/account.h" #include "ui/ui.h" -void omemo_init(void) {} -void omemo_close(void) {} +void +omemo_init(void) +{ +} +void +omemo_close(void) +{ +} char* -omemo_fingerprint_autocomplete(const char *const search_str, gboolean previous) +omemo_fingerprint_autocomplete(const char* const search_str, gboolean previous) { return NULL; } -void omemo_fingerprint_autocomplete_reset(void) {} +void +omemo_fingerprint_autocomplete_reset(void) +{ +} -char * -omemo_format_fingerprint(const char *const fingerprint) +char* +omemo_format_fingerprint(const char* const fingerprint) { return NULL; } -void omemo_generate_crypto_materials(ProfAccount *account) {} +void +omemo_generate_crypto_materials(ProfAccount* account) +{ +} gboolean -omemo_automatic_start(const char *const jid) +omemo_automatic_start(const char* const jid) { return TRUE; } gboolean -omemo_is_trusted_identity(const char *const jid, const char *const fingerprint) +omemo_is_trusted_identity(const char* const jid, const char* const fingerprint) { return TRUE; } -GList * -omemo_known_device_identities(const char *const jid) +GList* +omemo_known_device_identities(const char* const jid) { return NULL; } @@ -46,25 +58,52 @@ omemo_loaded(void) return TRUE; } -void omemo_on_connect(ProfAccount *account) {} -void omemo_on_disconnect(void) {} +void +omemo_on_connect(ProfAccount* account) +{ +} +void +omemo_on_disconnect(void) +{ +} -char * -omemo_on_message_send(ProfWin *win, const char *const message, gboolean request_receipt, gboolean muc) +char* +omemo_on_message_send(ProfWin* win, const char* const message, gboolean request_receipt, gboolean muc) { return NULL; } -char * +char* omemo_own_fingerprint(gboolean formatted) { return NULL; } -void omemo_start_muc_sessions(const char *const roomjid) {} -void omemo_start_session(const char *const barejid) {} -void omemo_trust(const char *const jid, const char *const fingerprint_formatted) {} -void omemo_untrust(const char *const jid, const char *const fingerprint_formatted) {} -void omemo_devicelist_publish(GList *device_list) {} -void omemo_publish_crypto_materials(void) {} -void omemo_start_sessions(void) {} +void +omemo_start_muc_sessions(const char* const roomjid) +{ +} +void +omemo_start_session(const char* const barejid) +{ +} +void +omemo_trust(const char* const jid, const char* const fingerprint_formatted) +{ +} +void +omemo_untrust(const char* const jid, const char* const fingerprint_formatted) +{ +} +void +omemo_devicelist_publish(GList* device_list) +{ +} +void +omemo_publish_crypto_materials(void) +{ +} +void +omemo_start_sessions(void) +{ +} diff --git a/tests/unittests/otr/stub_otr.c b/tests/unittests/otr/stub_otr.c index dffecfec..d6827c66 100644 --- a/tests/unittests/otr/stub_otr.c +++ b/tests/unittests/otr/stub_otr.c @@ -11,104 +11,154 @@ #include "otr/otr.h" -OtrlUserState otr_userstate(void) +OtrlUserState +otr_userstate(void) { return NULL; } -OtrlMessageAppOps* otr_messageops(void) +OtrlMessageAppOps* +otr_messageops(void) { return NULL; } -GHashTable* otr_smpinitators(void) +GHashTable* +otr_smpinitators(void) { return NULL; } -void otr_init(void) {} -void otr_shutdown(void) {} +void +otr_init(void) +{ +} +void +otr_shutdown(void) +{ +} -char* otr_libotr_version(void) +char* +otr_libotr_version(void) { return mock_ptr_type(char*); } -char* otr_start_query(void) +char* +otr_start_query(void) { return mock_ptr_type(char*); } -void otr_poll(void) {} -void otr_on_connect(ProfAccount *account) {} -char* otr_on_message_recv(const char * const barejid, const char * const resource, const char * const message, gboolean *was_decrypted) +void +otr_poll(void) +{ +} +void +otr_on_connect(ProfAccount* account) +{ +} +char* +otr_on_message_recv(const char* const barejid, const char* const resource, const char* const message, gboolean* was_decrypted) { return NULL; } -gboolean otr_on_message_send(ProfChatWin *chatwin, const char * const message, gboolean request_receipt, const char *const replace_id) +gboolean +otr_on_message_send(ProfChatWin* chatwin, const char* const message, gboolean request_receipt, const char* const replace_id) { return FALSE; } -void otr_keygen(ProfAccount *account) +void +otr_keygen(ProfAccount* account) { check_expected(account); } -gboolean otr_key_loaded(void) +gboolean +otr_key_loaded(void) { return mock_type(gboolean); } -char* otr_tag_message(const char * const msg) +char* +otr_tag_message(const char* const msg) { return NULL; } -gboolean otr_is_secure(const char * const recipient) +gboolean +otr_is_secure(const char* const recipient) { return FALSE; } -gboolean otr_is_trusted(const char * const recipient) +gboolean +otr_is_trusted(const char* const recipient) { return FALSE; } -void otr_trust(const char * const recipient) {} -void otr_untrust(const char * const recipient) {} +void +otr_trust(const char* const recipient) +{ +} +void +otr_untrust(const char* const recipient) +{ +} -void otr_smp_secret(const char * const recipient, const char *secret) {} -void otr_smp_question(const char * const recipient, const char *question, const char *answer) {} -void otr_smp_answer(const char * const recipient, const char *answer) {} +void +otr_smp_secret(const char* const recipient, const char* secret) +{ +} +void +otr_smp_question(const char* const recipient, const char* question, const char* answer) +{ +} +void +otr_smp_answer(const char* const recipient, const char* answer) +{ +} -void otr_end_session(const char * const recipient) {} +void +otr_end_session(const char* const recipient) +{ +} -char * otr_get_my_fingerprint(void) +char* +otr_get_my_fingerprint(void) { - return mock_ptr_type(char *); + return mock_ptr_type(char*); } -char * otr_get_their_fingerprint(const char * const recipient) +char* +otr_get_their_fingerprint(const char* const recipient) { check_expected(recipient); - return mock_ptr_type(char *); + return mock_ptr_type(char*); } -char * otr_encrypt_message(const char * const to, const char * const message) +char* +otr_encrypt_message(const char* const to, const char* const message) { return NULL; } -char * otr_decrypt_message(const char * const from, const char * const message, - gboolean *was_decrypted) +char* +otr_decrypt_message(const char* const from, const char* const message, + gboolean* was_decrypted) { return NULL; } -void otr_free_message(char *message) {} +void +otr_free_message(char* message) +{ +} -prof_otrpolicy_t otr_get_policy(const char * const recipient) +prof_otrpolicy_t +otr_get_policy(const char* const recipient) { return PROF_OTRPOLICY_MANUAL; } diff --git a/tests/unittests/pgp/stub_gpg.c b/tests/unittests/pgp/stub_gpg.c index efa6dcd3..807e9b6b 100644 --- a/tests/unittests/pgp/stub_gpg.c +++ b/tests/unittests/pgp/stub_gpg.c @@ -2,10 +2,17 @@ #include "pgp/gpg.h" -void p_gpg_init(void) {} -void p_gpg_close(void) {} +void +p_gpg_init(void) +{ +} +void +p_gpg_close(void) +{ +} -GHashTable* p_gpg_list_keys(void) +GHashTable* +p_gpg_list_keys(void) { return NULL; } @@ -16,65 +23,96 @@ p_gpg_pubkeys(void) return NULL; } -const char* p_gpg_libver(void) +const char* +p_gpg_libver(void) { return NULL; } -void p_gpg_verify(const char * const barejid, const char *const sign) {} +void +p_gpg_verify(const char* const barejid, const char* const sign) +{ +} -char* p_gpg_sign(const char * const str, const char * const fp) +char* +p_gpg_sign(const char* const str, const char* const fp) { return NULL; } -gboolean p_gpg_valid_key(const char * const keyid, char **err_str) +gboolean +p_gpg_valid_key(const char* const keyid, char** err_str) { return FALSE; } -gboolean p_gpg_available(const char * const barejid) +gboolean +p_gpg_available(const char* const barejid) { return FALSE; } -char * p_gpg_decrypt(const char * const cipher) +char* +p_gpg_decrypt(const char* const cipher) { return NULL; } -void p_gpg_on_connect(const char * const barejid) {} -void p_gpg_on_disconnect(void) {} +void +p_gpg_on_connect(const char* const barejid) +{ +} +void +p_gpg_on_disconnect(void) +{ +} -gboolean p_gpg_addkey(const char * const jid, const char * const keyid) +gboolean +p_gpg_addkey(const char* const jid, const char* const keyid) { return TRUE; } -void p_gpg_free_decrypted(char *decrypted) {} +void +p_gpg_free_decrypted(char* decrypted) +{ +} -void p_gpg_free_keys(GHashTable *keys) {} +void +p_gpg_free_keys(GHashTable* keys) +{ +} -void p_gpg_autocomplete_key_reset(void) {} +void +p_gpg_autocomplete_key_reset(void) +{ +} -char * p_gpg_autocomplete_key(const char * const search_str, gboolean previous, void *context) +char* +p_gpg_autocomplete_key(const char* const search_str, gboolean previous, void* context) { return NULL; } -char * -p_gpg_format_fp_str(char *fp) +char* +p_gpg_format_fp_str(char* fp) { return NULL; } -gboolean ox_is_private_key_available(const char *const barejid) { +gboolean +ox_is_private_key_available(const char* const barejid) +{ return FALSE; } -gboolean ox_is_public_key_available(const char *const barejid) { +gboolean +ox_is_public_key_available(const char* const barejid) +{ return FALSE; } -GHashTable* ox_gpg_public_keys(void) { +GHashTable* +ox_gpg_public_keys(void) +{ return NULL; } diff --git a/tests/unittests/test_autocomplete.c b/tests/unittests/test_autocomplete.c index 54b6af81..599cf390 100644 --- a/tests/unittests/test_autocomplete.c +++ b/tests/unittests/test_autocomplete.c @@ -8,31 +8,35 @@ #include "xmpp/contact.h" #include "tools/autocomplete.h" -void clear_empty(void **state) +void +clear_empty(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_free(ac); } -void reset_after_create(void **state) +void +reset_after_create(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_reset(ac); autocomplete_free(ac); } -void find_after_create(void **state) +void +find_after_create(void** state) { Autocomplete ac = autocomplete_new(); - char *result = autocomplete_complete(ac, "hello", TRUE, FALSE); + char* result = autocomplete_complete(ac, "hello", TRUE, FALSE); autocomplete_free(ac); free(result); } -void get_after_create_returns_null(void **state) +void +get_after_create_returns_null(void** state) { Autocomplete ac = autocomplete_new(); - GList *result = autocomplete_create_list(ac); + GList* result = autocomplete_create_list(ac); assert_null(result); @@ -40,11 +44,12 @@ void get_after_create_returns_null(void **state) g_list_free_full(result, free); } -void add_one_and_complete(void **state) +void +add_one_and_complete(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); - char *result = autocomplete_complete(ac, "Hel", TRUE, FALSE); + char* result = autocomplete_complete(ac, "Hel", TRUE, FALSE); assert_string_equal("Hello", result); @@ -52,12 +57,13 @@ void add_one_and_complete(void **state) free(result); } -void add_two_and_complete_returns_first(void **state) +void +add_two_and_complete_returns_first(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Help"); - char *result = autocomplete_complete(ac, "Hel", TRUE, FALSE); + char* result = autocomplete_complete(ac, "Hel", TRUE, FALSE); assert_string_equal("Hello", result); @@ -65,13 +71,14 @@ void add_two_and_complete_returns_first(void **state) free(result); } -void add_two_and_complete_returns_second(void **state) +void +add_two_and_complete_returns_second(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Help"); - char *result1 = autocomplete_complete(ac, "Hel", TRUE, FALSE); - char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE); + char* result1 = autocomplete_complete(ac, "Hel", TRUE, FALSE); + char* result2 = autocomplete_complete(ac, result1, TRUE, FALSE); assert_string_equal("Help", result2); @@ -80,12 +87,13 @@ void add_two_and_complete_returns_second(void **state) free(result2); } -void add_two_adds_two(void **state) +void +add_two_adds_two(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Help"); - GList *result = autocomplete_create_list(ac); + GList* result = autocomplete_create_list(ac); assert_int_equal(2, g_list_length(result)); @@ -93,12 +101,13 @@ void add_two_adds_two(void **state) g_list_free_full(result, free); } -void add_two_same_adds_one(void **state) +void +add_two_same_adds_one(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Hello"); - GList *result = autocomplete_create_list(ac); + GList* result = autocomplete_create_list(ac); assert_int_equal(1, g_list_length(result)); @@ -106,16 +115,17 @@ void add_two_same_adds_one(void **state) g_list_free_full(result, free); } -void add_two_same_updates(void **state) +void +add_two_same_updates(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "Hello"); autocomplete_add(ac, "Hello"); - GList *result = autocomplete_create_list(ac); + GList* result = autocomplete_create_list(ac); - GList *first = g_list_nth(result, 0); + GList* first = g_list_nth(result, 0); - char *str = first->data; + char* str = first->data; assert_string_equal("Hello", str); @@ -123,12 +133,13 @@ void add_two_same_updates(void **state) g_list_free_full(result, free); } -void complete_accented_with_accented(void **state) +void +complete_accented_with_accented(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "èâîô"); - char *result = autocomplete_complete(ac, "èâ", TRUE, FALSE); + char* result = autocomplete_complete(ac, "èâ", TRUE, FALSE); assert_string_equal("èâîô", result); @@ -136,12 +147,13 @@ void complete_accented_with_accented(void **state) free(result); } -void complete_accented_with_base(void **state) +void +complete_accented_with_base(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "èâîô"); - char *result = autocomplete_complete(ac, "ea", TRUE, FALSE); + char* result = autocomplete_complete(ac, "ea", TRUE, FALSE); assert_string_equal("èâîô", result); @@ -149,14 +161,15 @@ void complete_accented_with_base(void **state) free(result); } -void complete_both_with_accented(void **state) +void +complete_both_with_accented(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "eaooooo"); autocomplete_add(ac, "èâîô"); - char *result1 = autocomplete_complete(ac, "èâ", TRUE, FALSE); - char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE); + char* result1 = autocomplete_complete(ac, "èâ", TRUE, FALSE); + char* result2 = autocomplete_complete(ac, result1, TRUE, FALSE); assert_string_equal("èâîô", result2); @@ -165,14 +178,15 @@ void complete_both_with_accented(void **state) free(result2); } -void complete_both_with_base(void **state) +void +complete_both_with_base(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "eaooooo"); autocomplete_add(ac, "èâîô"); - char *result1 = autocomplete_complete(ac, "ea", TRUE, FALSE); - char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE); + char* result1 = autocomplete_complete(ac, "ea", TRUE, FALSE); + char* result2 = autocomplete_complete(ac, result1, TRUE, FALSE); assert_string_equal("èâîô", result2); @@ -182,12 +196,13 @@ void complete_both_with_base(void **state) free(result2); } -void complete_ignores_case(void **state) +void +complete_ignores_case(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "MyBuddy"); - char *result = autocomplete_complete(ac, "myb", TRUE, FALSE); + char* result = autocomplete_complete(ac, "myb", TRUE, FALSE); assert_string_equal("MyBuddy", result); @@ -195,17 +210,18 @@ void complete_ignores_case(void **state) free(result); } -void complete_previous(void **state) +void +complete_previous(void** state) { Autocomplete ac = autocomplete_new(); autocomplete_add(ac, "MyBuddy1"); autocomplete_add(ac, "MyBuddy2"); autocomplete_add(ac, "MyBuddy3"); - char *result1 = autocomplete_complete(ac, "myb", TRUE, FALSE); - char *result2 = autocomplete_complete(ac, result1, TRUE, FALSE); - char *result3 = autocomplete_complete(ac, result2, TRUE, FALSE); - char *result4 = autocomplete_complete(ac, result3, TRUE, TRUE); + char* result1 = autocomplete_complete(ac, "myb", TRUE, FALSE); + char* result2 = autocomplete_complete(ac, result1, TRUE, FALSE); + char* result3 = autocomplete_complete(ac, result2, TRUE, FALSE); + char* result4 = autocomplete_complete(ac, result3, TRUE, TRUE); assert_string_equal("MyBuddy2", result4); diff --git a/tests/unittests/test_autocomplete.h b/tests/unittests/test_autocomplete.h index 746ea2af..3fac7038 100644 --- a/tests/unittests/test_autocomplete.h +++ b/tests/unittests/test_autocomplete.h @@ -1,16 +1,16 @@ -void clear_empty(void **state); -void reset_after_create(void **state); -void find_after_create(void **state); -void get_after_create_returns_null(void **state); -void add_one_and_complete(void **state); -void add_two_and_complete_returns_first(void **state); -void add_two_and_complete_returns_second(void **state); -void add_two_adds_two(void **state); -void add_two_same_adds_one(void **state); -void add_two_same_updates(void **state); -void complete_accented_with_accented(void **state); -void complete_accented_with_base(void **state); -void complete_both_with_accented(void **state); -void complete_both_with_base(void **state); -void complete_ignores_case(void **state); -void complete_previous(void **state); +void clear_empty(void** state); +void reset_after_create(void** state); +void find_after_create(void** state); +void get_after_create_returns_null(void** state); +void add_one_and_complete(void** state); +void add_two_and_complete_returns_first(void** state); +void add_two_and_complete_returns_second(void** state); +void add_two_adds_two(void** state); +void add_two_same_adds_one(void** state); +void add_two_same_updates(void** state); +void complete_accented_with_accented(void** state); +void complete_accented_with_base(void** state); +void complete_both_with_accented(void** state); +void complete_both_with_base(void** state); +void complete_ignores_case(void** state); +void complete_previous(void** state); diff --git a/tests/unittests/test_callbacks.c b/tests/unittests/test_callbacks.c index ec411863..3c5267fe 100644 --- a/tests/unittests/test_callbacks.c +++ b/tests/unittests/test_callbacks.c @@ -9,10 +9,11 @@ #include "plugins/callbacks.h" #include "plugins/plugins.h" -void returns_no_commands(void **state) +void +returns_no_commands(void** state) { callbacks_init(); - GList *commands = plugins_get_command_names(); + GList* commands = plugins_get_command_names(); assert_true(commands == NULL); @@ -20,29 +21,30 @@ void returns_no_commands(void **state) g_list_free(commands); } -void returns_commands(void **state) +void +returns_commands(void** state) { callbacks_init(); - PluginCommand *command1 = malloc(sizeof(PluginCommand)); + PluginCommand* command1 = malloc(sizeof(PluginCommand)); command1->command_name = strdup("command1"); callbacks_add_command("plugin1", command1); - PluginCommand *command2 = malloc(sizeof(PluginCommand)); + PluginCommand* command2 = malloc(sizeof(PluginCommand)); command2->command_name = strdup("command2"); callbacks_add_command("plugin1", command2); - PluginCommand *command3 = malloc(sizeof(PluginCommand)); + PluginCommand* command3 = malloc(sizeof(PluginCommand)); command3->command_name = strdup("command3"); callbacks_add_command("plugin2", command3); - GList *names = plugins_get_command_names(); + GList* names = plugins_get_command_names(); assert_true(g_list_length(names) == 3); gboolean foundCommand1 = FALSE; gboolean foundCommand2 = FALSE; gboolean foundCommand3 = FALSE; - GList *curr = names; + GList* curr = names; while (curr) { if (g_strcmp0(curr->data, "command1") == 0) { foundCommand1 = TRUE; diff --git a/tests/unittests/test_callbacks.h b/tests/unittests/test_callbacks.h index 35751d2e..27130241 100644 --- a/tests/unittests/test_callbacks.h +++ b/tests/unittests/test_callbacks.h @@ -1,2 +1,2 @@ -void returns_no_commands(void **state); -void returns_commands(void **state); +void returns_no_commands(void** state); +void returns_commands(void** state); diff --git a/tests/unittests/test_chat_session.c b/tests/unittests/test_chat_session.c index fd934737..26845dbc 100644 --- a/tests/unittests/test_chat_session.c +++ b/tests/unittests/test_chat_session.c @@ -7,45 +7,49 @@ #include "xmpp/chat_session.h" -void returns_false_when_chat_session_does_not_exist(void **state) +void +returns_false_when_chat_session_does_not_exist(void** state) { - ChatSession *session = chat_session_get("somejid@server.org"); + ChatSession* session = chat_session_get("somejid@server.org"); assert_null(session); } -void creates_chat_session_on_recipient_activity(void **state) +void +creates_chat_session_on_recipient_activity(void** state) { - char *barejid = "myjid@server.org"; - char *resource = "tablet"; + char* barejid = "myjid@server.org"; + char* resource = "tablet"; chat_session_recipient_active(barejid, resource, FALSE); - ChatSession *session = chat_session_get(barejid); + ChatSession* session = chat_session_get(barejid); assert_non_null(session); assert_string_equal(session->resource, resource); } -void replaces_chat_session_on_recipient_activity_with_different_resource(void **state) +void +replaces_chat_session_on_recipient_activity_with_different_resource(void** state) { - char *barejid = "myjid@server.org"; - char *resource1 = "tablet"; - char *resource2 = "mobile"; + char* barejid = "myjid@server.org"; + char* resource1 = "tablet"; + char* resource2 = "mobile"; chat_session_recipient_active(barejid, resource1, FALSE); chat_session_recipient_active(barejid, resource2, FALSE); - ChatSession *session = chat_session_get(barejid); + ChatSession* session = chat_session_get(barejid); assert_string_equal(session->resource, resource2); } -void removes_chat_session(void **state) +void +removes_chat_session(void** state) { - char *barejid = "myjid@server.org"; - char *resource1 = "laptop"; + char* barejid = "myjid@server.org"; + char* resource1 = "laptop"; chat_session_recipient_active(barejid, resource1, FALSE); chat_session_remove(barejid); - ChatSession *session = chat_session_get(barejid); + ChatSession* session = chat_session_get(barejid); assert_null(session); } diff --git a/tests/unittests/test_chat_session.h b/tests/unittests/test_chat_session.h index 4ce03fd5..7f7072f8 100644 --- a/tests/unittests/test_chat_session.h +++ b/tests/unittests/test_chat_session.h @@ -1,4 +1,4 @@ -void returns_false_when_chat_session_does_not_exist(void **state); -void creates_chat_session_on_recipient_activity(void **state); -void replaces_chat_session_on_recipient_activity_with_different_resource(void **state); -void removes_chat_session(void **state); \ No newline at end of file +void returns_false_when_chat_session_does_not_exist(void** state); +void creates_chat_session_on_recipient_activity(void** state); +void replaces_chat_session_on_recipient_activity_with_different_resource(void** state); +void removes_chat_session(void** state); \ No newline at end of file diff --git a/tests/unittests/test_cmd_account.c b/tests/unittests/test_cmd_account.c index 032f4364..69721311 100644 --- a/tests/unittests/test_cmd_account.c +++ b/tests/unittests/test_cmd_account.c @@ -17,9 +17,10 @@ #define CMD_ACCOUNT "/account" -void cmd_account_shows_usage_when_not_connected_and_no_args(void **state) +void +cmd_account_shows_usage_when_not_connected_and_no_args(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -29,12 +30,12 @@ void cmd_account_shows_usage_when_not_connected_and_no_args(void **state) assert_true(result); } - -void cmd_account_shows_account_when_connected_and_no_args(void **state) +void +cmd_account_shows_account_when_connected_and_no_args(void** state) { - ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - gchar *args[] = { NULL }; + ProfAccount* account = account_new("jabber_org", "me@jabber.org", NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { NULL }; will_return(connection_get_status, JABBER_CONNECTED); will_return(session_get_account_name, "account_name"); @@ -47,11 +48,12 @@ void cmd_account_shows_account_when_connected_and_no_args(void **state) assert_true(result); } -void cmd_account_list_shows_accounts(void **state) +void +cmd_account_list_shows_accounts(void** state) { - gchar *args[] = { "list", NULL }; + gchar* args[] = { "list", NULL }; - gchar **accounts = malloc(sizeof(gchar *) * 4); + gchar** accounts = malloc(sizeof(gchar*) * 4); accounts[0] = strdup("account1"); accounts[1] = strdup("account2"); accounts[2] = strdup("account3"); @@ -65,9 +67,10 @@ void cmd_account_list_shows_accounts(void **state) assert_true(result); } -void cmd_account_show_shows_usage_when_no_arg(void **state) +void +cmd_account_show_shows_usage_when_no_arg(void** state) { - gchar *args[] = { "show", NULL }; + gchar* args[] = { "show", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -75,9 +78,10 @@ void cmd_account_show_shows_usage_when_no_arg(void **state) assert_true(result); } -void cmd_account_show_shows_message_when_account_does_not_exist(void **state) +void +cmd_account_show_shows_message_when_account_does_not_exist(void** state) { - gchar *args[] = { "show", "account_name", NULL }; + gchar* args[] = { "show", "account_name", NULL }; expect_any(accounts_get_account, name); will_return(accounts_get_account, NULL); @@ -89,11 +93,12 @@ void cmd_account_show_shows_message_when_account_does_not_exist(void **state) assert_true(result); } -void cmd_account_show_shows_account_when_exists(void **state) +void +cmd_account_show_shows_account_when_exists(void** state) { - gchar *args[] = { "show", "account_name", NULL }; - ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "show", "account_name", NULL }; + ProfAccount* account = account_new("jabber_org", "me@jabber.org", NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); expect_any(accounts_get_account, name); will_return(accounts_get_account, account); @@ -104,9 +109,10 @@ void cmd_account_show_shows_account_when_exists(void **state) assert_true(result); } -void cmd_account_add_shows_usage_when_no_arg(void **state) +void +cmd_account_add_shows_usage_when_no_arg(void** state) { - gchar *args[] = { "add", NULL }; + gchar* args[] = { "add", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -114,9 +120,10 @@ void cmd_account_add_shows_usage_when_no_arg(void **state) assert_true(result); } -void cmd_account_add_adds_account(void **state) +void +cmd_account_add_adds_account(void** state) { - gchar *args[] = { "add", "new_account", NULL }; + gchar* args[] = { "add", "new_account", NULL }; expect_string(accounts_add, jid, "new_account"); expect_value(accounts_add, altdomain, NULL); @@ -128,9 +135,10 @@ void cmd_account_add_adds_account(void **state) assert_true(result); } -void cmd_account_enable_shows_usage_when_no_arg(void **state) +void +cmd_account_enable_shows_usage_when_no_arg(void** state) { - gchar *args[] = { "enable", NULL }; + gchar* args[] = { "enable", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -138,9 +146,10 @@ void cmd_account_enable_shows_usage_when_no_arg(void **state) assert_true(result); } -void cmd_account_enable_enables_account(void **state) +void +cmd_account_enable_enables_account(void** state) { - gchar *args[] = { "enable", "account_name", NULL }; + gchar* args[] = { "enable", "account_name", NULL }; expect_string(accounts_enable, name, "account_name"); will_return(accounts_enable, TRUE); @@ -152,9 +161,10 @@ void cmd_account_enable_enables_account(void **state) assert_true(result); } -void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state) +void +cmd_account_enable_shows_message_when_account_doesnt_exist(void** state) { - gchar *args[] = { "enable", "account_name", NULL }; + gchar* args[] = { "enable", "account_name", NULL }; expect_any(accounts_enable, name); will_return(accounts_enable, FALSE); @@ -166,9 +176,10 @@ void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state) assert_true(result); } -void cmd_account_disable_shows_usage_when_no_arg(void **state) +void +cmd_account_disable_shows_usage_when_no_arg(void** state) { - gchar *args[] = { "disable", NULL }; + gchar* args[] = { "disable", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -176,9 +187,10 @@ void cmd_account_disable_shows_usage_when_no_arg(void **state) assert_true(result); } -void cmd_account_disable_disables_account(void **state) +void +cmd_account_disable_disables_account(void** state) { - gchar *args[] = { "disable", "account_name", NULL }; + gchar* args[] = { "disable", "account_name", NULL }; expect_string(accounts_disable, name, "account_name"); will_return(accounts_disable, TRUE); @@ -190,9 +202,10 @@ void cmd_account_disable_disables_account(void **state) assert_true(result); } -void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state) +void +cmd_account_disable_shows_message_when_account_doesnt_exist(void** state) { - gchar *args[] = { "disable", "account_name", NULL }; + gchar* args[] = { "disable", "account_name", NULL }; expect_any(accounts_disable, name); will_return(accounts_disable, FALSE); @@ -204,9 +217,10 @@ void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state) assert_true(result); } -void cmd_account_rename_shows_usage_when_no_args(void **state) +void +cmd_account_rename_shows_usage_when_no_args(void** state) { - gchar *args[] = { "rename", NULL }; + gchar* args[] = { "rename", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -214,9 +228,10 @@ void cmd_account_rename_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_account_rename_shows_usage_when_one_arg(void **state) +void +cmd_account_rename_shows_usage_when_one_arg(void** state) { - gchar *args[] = { "rename", "original_name", NULL }; + gchar* args[] = { "rename", "original_name", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -224,9 +239,10 @@ void cmd_account_rename_shows_usage_when_one_arg(void **state) assert_true(result); } -void cmd_account_rename_renames_account(void **state) +void +cmd_account_rename_renames_account(void** state) { - gchar *args[] = { "rename", "original_name", "new_name", NULL }; + gchar* args[] = { "rename", "original_name", "new_name", NULL }; expect_string(accounts_rename, account_name, "original_name"); expect_string(accounts_rename, new_name, "new_name"); @@ -239,9 +255,10 @@ void cmd_account_rename_renames_account(void **state) assert_true(result); } -void cmd_account_rename_shows_message_when_not_renamed(void **state) +void +cmd_account_rename_shows_message_when_not_renamed(void** state) { - gchar *args[] = { "rename", "original_name", "new_name", NULL }; + gchar* args[] = { "rename", "original_name", "new_name", NULL }; expect_any(accounts_rename, account_name); expect_any(accounts_rename, new_name); @@ -254,9 +271,10 @@ void cmd_account_rename_shows_message_when_not_renamed(void **state) assert_true(result); } -void cmd_account_set_shows_usage_when_no_args(void **state) +void +cmd_account_set_shows_usage_when_no_args(void** state) { - gchar *args[] = { "set", NULL }; + gchar* args[] = { "set", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -264,9 +282,10 @@ void cmd_account_set_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_account_set_shows_usage_when_one_arg(void **state) +void +cmd_account_set_shows_usage_when_one_arg(void** state) { - gchar *args[] = { "set", "a_account", NULL }; + gchar* args[] = { "set", "a_account", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -274,9 +293,10 @@ void cmd_account_set_shows_usage_when_one_arg(void **state) assert_true(result); } -void cmd_account_set_shows_usage_when_two_args(void **state) +void +cmd_account_set_shows_usage_when_two_args(void** state) { - gchar *args[] = { "set", "a_account", "a_property", NULL }; + gchar* args[] = { "set", "a_account", "a_property", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -284,9 +304,10 @@ void cmd_account_set_shows_usage_when_two_args(void **state) assert_true(result); } -void cmd_account_set_shows_message_when_account_doesnt_exist(void **state) +void +cmd_account_set_shows_message_when_account_doesnt_exist(void** state) { - gchar *args[] = { "set", "a_account", "a_property", "a_value", NULL }; + gchar* args[] = { "set", "a_account", "a_property", "a_value", NULL }; expect_string(accounts_account_exists, account_name, "a_account"); will_return(accounts_account_exists, FALSE); @@ -298,9 +319,10 @@ void cmd_account_set_shows_message_when_account_doesnt_exist(void **state) assert_true(result); } -void cmd_account_set_jid_shows_message_for_malformed_jid(void **state) +void +cmd_account_set_jid_shows_message_for_malformed_jid(void** state) { - gchar *args[] = { "set", "a_account", "jid", "@malformed", NULL }; + gchar* args[] = { "set", "a_account", "jid", "@malformed", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -311,9 +333,10 @@ void cmd_account_set_jid_shows_message_for_malformed_jid(void **state) assert_true(result); } -void cmd_account_set_jid_sets_barejid(void **state) +void +cmd_account_set_jid_sets_barejid(void** state) { - gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL }; + gchar* args[] = { "set", "a_account", "jid", "a_local@a_domain", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -328,9 +351,10 @@ void cmd_account_set_jid_sets_barejid(void **state) assert_true(result); } -void cmd_account_set_jid_sets_resource(void **state) +void +cmd_account_set_jid_sets_resource(void** state) { - gchar *args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL }; + gchar* args[] = { "set", "a_account", "jid", "a_local@a_domain/a_resource", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -350,9 +374,10 @@ void cmd_account_set_jid_sets_resource(void **state) assert_true(result); } -void cmd_account_set_server_sets_server(void **state) +void +cmd_account_set_server_sets_server(void** state) { - gchar *args[] = { "set", "a_account", "server", "a_server", NULL }; + gchar* args[] = { "set", "a_account", "server", "a_server", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -367,9 +392,10 @@ void cmd_account_set_server_sets_server(void **state) assert_true(result); } -void cmd_account_set_resource_sets_resource(void **state) +void +cmd_account_set_resource_sets_resource(void** state) { - gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL }; + gchar* args[] = { "set", "a_account", "resource", "a_resource", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -386,9 +412,10 @@ void cmd_account_set_resource_sets_resource(void **state) assert_true(result); } -void cmd_account_set_resource_sets_resource_with_online_message(void **state) +void +cmd_account_set_resource_sets_resource_with_online_message(void** state) { - gchar *args[] = { "set", "a_account", "resource", "a_resource", NULL }; + gchar* args[] = { "set", "a_account", "resource", "a_resource", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -405,12 +432,12 @@ void cmd_account_set_resource_sets_resource_with_online_message(void **state) assert_true(result); } -void cmd_account_set_password_sets_password(void **state) +void +cmd_account_set_password_sets_password(void** state) { - gchar *args[] = { "set", "a_account", "password", "a_password", NULL }; - ProfAccount *account = account_new("a_account", NULL, NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - + gchar* args[] = { "set", "a_account", "password", "a_password", NULL }; + ProfAccount* account = account_new("a_account", NULL, NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -428,11 +455,12 @@ void cmd_account_set_password_sets_password(void **state) assert_true(result); } -void cmd_account_set_eval_password_sets_eval_password(void **state) +void +cmd_account_set_eval_password_sets_eval_password(void** state) { - gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL }; - ProfAccount *account = account_new("a_account", NULL, NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL }; + ProfAccount* account = account_new("a_account", NULL, NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -450,10 +478,12 @@ void cmd_account_set_eval_password_sets_eval_password(void **state) assert_true(result); } -void cmd_account_set_password_when_eval_password_set(void **state) { - gchar *args[] = { "set", "a_account", "password", "a_password", NULL }; - ProfAccount *account = account_new("a_account", NULL, NULL, "a_password", - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +void +cmd_account_set_password_when_eval_password_set(void** state) +{ + gchar* args[] = { "set", "a_account", "password", "a_password", NULL }; + ProfAccount* account = account_new("a_account", NULL, NULL, "a_password", + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -467,10 +497,12 @@ void cmd_account_set_password_when_eval_password_set(void **state) { assert_true(result); } -void cmd_account_set_eval_password_when_password_set(void **state) { - gchar *args[] = { "set", "a_account", "eval_password", "a_password", NULL }; - ProfAccount *account = account_new("a_account", NULL, "a_password", NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); +void +cmd_account_set_eval_password_when_password_set(void** state) +{ + gchar* args[] = { "set", "a_account", "eval_password", "a_password", NULL }; + ProfAccount* account = account_new("a_account", NULL, "a_password", NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -484,9 +516,10 @@ void cmd_account_set_eval_password_when_password_set(void **state) { assert_true(result); } -void cmd_account_set_muc_sets_muc(void **state) +void +cmd_account_set_muc_sets_muc(void** state) { - gchar *args[] = { "set", "a_account", "muc", "a_muc", NULL }; + gchar* args[] = { "set", "a_account", "muc", "a_muc", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -501,9 +534,10 @@ void cmd_account_set_muc_sets_muc(void **state) assert_true(result); } -void cmd_account_set_nick_sets_nick(void **state) +void +cmd_account_set_nick_sets_nick(void** state) { - gchar *args[] = { "set", "a_account", "nick", "a_nick", NULL }; + gchar* args[] = { "set", "a_account", "nick", "a_nick", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -518,9 +552,10 @@ void cmd_account_set_nick_sets_nick(void **state) assert_true(result); } -void cmd_account_show_message_for_missing_otr_policy(void **state) +void +cmd_account_show_message_for_missing_otr_policy(void** state) { - gchar *args[] = { "set", "a_account", "otr", NULL }; + gchar* args[] = { "set", "a_account", "otr", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -528,9 +563,10 @@ void cmd_account_show_message_for_missing_otr_policy(void **state) assert_true(result); } -void cmd_account_show_message_for_invalid_otr_policy(void **state) +void +cmd_account_show_message_for_invalid_otr_policy(void** state) { - gchar *args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL }; + gchar* args[] = { "set", "a_account", "otr", "bad_otr_policy", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -541,9 +577,10 @@ void cmd_account_show_message_for_invalid_otr_policy(void **state) assert_true(result); } -void cmd_account_set_otr_sets_otr(void **state) +void +cmd_account_set_otr_sets_otr(void** state) { - gchar *args[] = { "set", "a_account", "otr", "opportunistic", NULL }; + gchar* args[] = { "set", "a_account", "otr", "opportunistic", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -558,9 +595,10 @@ void cmd_account_set_otr_sets_otr(void **state) assert_true(result); } -void cmd_account_set_status_shows_message_when_invalid_status(void **state) +void +cmd_account_set_status_shows_message_when_invalid_status(void** state) { - gchar *args[] = { "set", "a_account", "status", "bad_status", NULL }; + gchar* args[] = { "set", "a_account", "status", "bad_status", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -572,9 +610,10 @@ void cmd_account_set_status_shows_message_when_invalid_status(void **state) assert_true(result); } -void cmd_account_set_status_sets_status_when_valid(void **state) +void +cmd_account_set_status_sets_status_when_valid(void** state) { - gchar *args[] = { "set", "a_account", "status", "away", NULL }; + gchar* args[] = { "set", "a_account", "status", "away", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -589,9 +628,10 @@ void cmd_account_set_status_sets_status_when_valid(void **state) assert_true(result); } -void cmd_account_set_status_sets_status_when_last(void **state) +void +cmd_account_set_status_sets_status_when_last(void** state) { - gchar *args[] = { "set", "a_account", "status", "last", NULL }; + gchar* args[] = { "set", "a_account", "status", "last", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -606,9 +646,10 @@ void cmd_account_set_status_sets_status_when_last(void **state) assert_true(result); } -void cmd_account_set_invalid_presence_string_priority_shows_message(void **state) +void +cmd_account_set_invalid_presence_string_priority_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "blah", "10", NULL }; + gchar* args[] = { "set", "a_account", "blah", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -620,9 +661,10 @@ void cmd_account_set_invalid_presence_string_priority_shows_message(void **state assert_true(result); } -void cmd_account_set_last_priority_shows_message(void **state) +void +cmd_account_set_last_priority_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "last", "10", NULL }; + gchar* args[] = { "set", "a_account", "last", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -634,9 +676,10 @@ void cmd_account_set_last_priority_shows_message(void **state) assert_true(result); } -void cmd_account_set_online_priority_sets_preference(void **state) +void +cmd_account_set_online_priority_sets_preference(void** state) { - gchar *args[] = { "set", "a_account", "online", "10", NULL }; + gchar* args[] = { "set", "a_account", "online", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -653,9 +696,10 @@ void cmd_account_set_online_priority_sets_preference(void **state) assert_true(result); } -void cmd_account_set_chat_priority_sets_preference(void **state) +void +cmd_account_set_chat_priority_sets_preference(void** state) { - gchar *args[] = { "set", "a_account", "chat", "10", NULL }; + gchar* args[] = { "set", "a_account", "chat", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -672,9 +716,10 @@ void cmd_account_set_chat_priority_sets_preference(void **state) assert_true(result); } -void cmd_account_set_away_priority_sets_preference(void **state) +void +cmd_account_set_away_priority_sets_preference(void** state) { - gchar *args[] = { "set", "a_account", "away", "10", NULL }; + gchar* args[] = { "set", "a_account", "away", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -691,9 +736,10 @@ void cmd_account_set_away_priority_sets_preference(void **state) assert_true(result); } -void cmd_account_set_xa_priority_sets_preference(void **state) +void +cmd_account_set_xa_priority_sets_preference(void** state) { - gchar *args[] = { "set", "a_account", "xa", "10", NULL }; + gchar* args[] = { "set", "a_account", "xa", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -710,9 +756,10 @@ void cmd_account_set_xa_priority_sets_preference(void **state) assert_true(result); } -void cmd_account_set_dnd_priority_sets_preference(void **state) +void +cmd_account_set_dnd_priority_sets_preference(void** state) { - gchar *args[] = { "set", "a_account", "dnd", "10", NULL }; + gchar* args[] = { "set", "a_account", "dnd", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -729,9 +776,10 @@ void cmd_account_set_dnd_priority_sets_preference(void **state) assert_true(result); } -void cmd_account_set_priority_too_low_shows_message(void **state) +void +cmd_account_set_priority_too_low_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "online", "-150", NULL }; + gchar* args[] = { "set", "a_account", "online", "-150", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -742,9 +790,10 @@ void cmd_account_set_priority_too_low_shows_message(void **state) assert_true(result); } -void cmd_account_set_priority_too_high_shows_message(void **state) +void +cmd_account_set_priority_too_high_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "online", "150", NULL }; + gchar* args[] = { "set", "a_account", "online", "150", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -755,9 +804,10 @@ void cmd_account_set_priority_too_high_shows_message(void **state) assert_true(result); } -void cmd_account_set_priority_when_not_number_shows_message(void **state) +void +cmd_account_set_priority_when_not_number_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "online", "abc", NULL }; + gchar* args[] = { "set", "a_account", "online", "abc", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -768,9 +818,10 @@ void cmd_account_set_priority_when_not_number_shows_message(void **state) assert_true(result); } -void cmd_account_set_priority_when_empty_shows_message(void **state) +void +cmd_account_set_priority_when_empty_shows_message(void** state) { - gchar *args[] = { "set", "a_account", "online", "", NULL }; + gchar* args[] = { "set", "a_account", "online", "", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -781,9 +832,10 @@ void cmd_account_set_priority_when_empty_shows_message(void **state) assert_true(result); } -void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void **state) +void +cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void** state) { - gchar *args[] = { "set", "a_account", "online", "10", NULL }; + gchar* args[] = { "set", "a_account", "online", "10", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); @@ -799,8 +851,8 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese will_return(session_get_account_name, "a_account"); #ifdef HAVE_LIBGPGME - ProfAccount *account = account_new("a_account", "a_jid", NULL, NULL, TRUE, NULL, 5222, "a_resource", - NULL, NULL, 10, 10, 10, 10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ProfAccount* account = account_new("a_account", "a_jid", NULL, NULL, TRUE, NULL, 5222, "a_resource", + NULL, NULL, 10, 10, 10, 10, 10, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(session_get_account_name, "a_account"); expect_any(accounts_get_account, name); @@ -813,14 +865,14 @@ void cmd_account_set_priority_updates_presence_when_account_connected_with_prese expect_cons_show("Updated online priority for account a_account: 10"); expect_cons_show(""); - gboolean result = cmd_account_set(NULL, CMD_ACCOUNT, args); assert_true(result); } -void cmd_account_clear_shows_usage_when_no_args(void **state) +void +cmd_account_clear_shows_usage_when_no_args(void** state) { - gchar *args[] = { "clear", NULL }; + gchar* args[] = { "clear", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -828,9 +880,10 @@ void cmd_account_clear_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_account_clear_shows_usage_when_one_arg(void **state) +void +cmd_account_clear_shows_usage_when_one_arg(void** state) { - gchar *args[] = { "clear", "a_account", NULL }; + gchar* args[] = { "clear", "a_account", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ACCOUNT); @@ -838,9 +891,10 @@ void cmd_account_clear_shows_usage_when_one_arg(void **state) assert_true(result); } -void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state) +void +cmd_account_clear_shows_message_when_account_doesnt_exist(void** state) { - gchar *args[] = { "clear", "a_account", "a_property", NULL }; + gchar* args[] = { "clear", "a_account", "a_property", NULL }; expect_string(accounts_account_exists, account_name, "a_account"); will_return(accounts_account_exists, FALSE); @@ -852,9 +906,10 @@ void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state) assert_true(result); } -void cmd_account_clear_shows_message_when_invalid_property(void **state) +void +cmd_account_clear_shows_message_when_invalid_property(void** state) { - gchar *args[] = { "clear", "a_account", "badproperty", NULL }; + gchar* args[] = { "clear", "a_account", "badproperty", NULL }; expect_any(accounts_account_exists, account_name); will_return(accounts_account_exists, TRUE); diff --git a/tests/unittests/test_cmd_account.h b/tests/unittests/test_cmd_account.h index e8806c4f..7a8d1b42 100644 --- a/tests/unittests/test_cmd_account.h +++ b/tests/unittests/test_cmd_account.h @@ -1,56 +1,56 @@ -void cmd_account_shows_usage_when_not_connected_and_no_args(void **state); -void cmd_account_shows_account_when_connected_and_no_args(void **state); -void cmd_account_list_shows_accounts(void **state); -void cmd_account_show_shows_usage_when_no_arg(void **state); -void cmd_account_show_shows_message_when_account_does_not_exist(void **state); -void cmd_account_show_shows_account_when_exists(void **state); -void cmd_account_add_shows_usage_when_no_arg(void **state); -void cmd_account_add_adds_account(void **state); -void cmd_account_enable_shows_usage_when_no_arg(void **state); -void cmd_account_enable_enables_account(void **state); -void cmd_account_enable_shows_message_when_account_doesnt_exist(void **state); -void cmd_account_disable_shows_usage_when_no_arg(void **state); -void cmd_account_disable_disables_account(void **state); -void cmd_account_disable_shows_message_when_account_doesnt_exist(void **state); -void cmd_account_rename_shows_usage_when_no_args(void **state); -void cmd_account_rename_shows_usage_when_one_arg(void **state); -void cmd_account_rename_renames_account(void **state); -void cmd_account_rename_shows_message_when_not_renamed(void **state); -void cmd_account_set_shows_usage_when_no_args(void **state); -void cmd_account_set_shows_usage_when_one_arg(void **state); -void cmd_account_set_shows_usage_when_two_args(void **state); -void cmd_account_set_shows_message_when_account_doesnt_exist(void **state); -void cmd_account_set_jid_shows_message_for_malformed_jid(void **state); -void cmd_account_set_jid_sets_barejid(void **state); -void cmd_account_set_jid_sets_resource(void **state); -void cmd_account_set_server_sets_server(void **state); -void cmd_account_set_resource_sets_resource(void **state); -void cmd_account_set_resource_sets_resource_with_online_message(void **state); -void cmd_account_set_password_sets_password(void **state); -void cmd_account_set_eval_password_sets_eval_password(void **state); -void cmd_account_set_password_when_eval_password_set(void **state); -void cmd_account_set_eval_password_when_password_set(void **state); -void cmd_account_set_muc_sets_muc(void **state); -void cmd_account_set_nick_sets_nick(void **state); -void cmd_account_show_message_for_missing_otr_policy(void **state); -void cmd_account_show_message_for_invalid_otr_policy(void **state); -void cmd_account_set_otr_sets_otr(void **state); -void cmd_account_set_status_shows_message_when_invalid_status(void **state); -void cmd_account_set_status_sets_status_when_valid(void **state); -void cmd_account_set_status_sets_status_when_last(void **state); -void cmd_account_set_invalid_presence_string_priority_shows_message(void **state); -void cmd_account_set_last_priority_shows_message(void **state); -void cmd_account_set_online_priority_sets_preference(void **state); -void cmd_account_set_chat_priority_sets_preference(void **state); -void cmd_account_set_away_priority_sets_preference(void **state); -void cmd_account_set_xa_priority_sets_preference(void **state); -void cmd_account_set_dnd_priority_sets_preference(void **state); -void cmd_account_set_priority_too_low_shows_message(void **state); -void cmd_account_set_priority_too_high_shows_message(void **state); -void cmd_account_set_priority_when_not_number_shows_message(void **state); -void cmd_account_set_priority_when_empty_shows_message(void **state); -void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void **state); -void cmd_account_clear_shows_usage_when_no_args(void **state); -void cmd_account_clear_shows_usage_when_one_arg(void **state); -void cmd_account_clear_shows_message_when_account_doesnt_exist(void **state); -void cmd_account_clear_shows_message_when_invalid_property(void **state); +void cmd_account_shows_usage_when_not_connected_and_no_args(void** state); +void cmd_account_shows_account_when_connected_and_no_args(void** state); +void cmd_account_list_shows_accounts(void** state); +void cmd_account_show_shows_usage_when_no_arg(void** state); +void cmd_account_show_shows_message_when_account_does_not_exist(void** state); +void cmd_account_show_shows_account_when_exists(void** state); +void cmd_account_add_shows_usage_when_no_arg(void** state); +void cmd_account_add_adds_account(void** state); +void cmd_account_enable_shows_usage_when_no_arg(void** state); +void cmd_account_enable_enables_account(void** state); +void cmd_account_enable_shows_message_when_account_doesnt_exist(void** state); +void cmd_account_disable_shows_usage_when_no_arg(void** state); +void cmd_account_disable_disables_account(void** state); +void cmd_account_disable_shows_message_when_account_doesnt_exist(void** state); +void cmd_account_rename_shows_usage_when_no_args(void** state); +void cmd_account_rename_shows_usage_when_one_arg(void** state); +void cmd_account_rename_renames_account(void** state); +void cmd_account_rename_shows_message_when_not_renamed(void** state); +void cmd_account_set_shows_usage_when_no_args(void** state); +void cmd_account_set_shows_usage_when_one_arg(void** state); +void cmd_account_set_shows_usage_when_two_args(void** state); +void cmd_account_set_shows_message_when_account_doesnt_exist(void** state); +void cmd_account_set_jid_shows_message_for_malformed_jid(void** state); +void cmd_account_set_jid_sets_barejid(void** state); +void cmd_account_set_jid_sets_resource(void** state); +void cmd_account_set_server_sets_server(void** state); +void cmd_account_set_resource_sets_resource(void** state); +void cmd_account_set_resource_sets_resource_with_online_message(void** state); +void cmd_account_set_password_sets_password(void** state); +void cmd_account_set_eval_password_sets_eval_password(void** state); +void cmd_account_set_password_when_eval_password_set(void** state); +void cmd_account_set_eval_password_when_password_set(void** state); +void cmd_account_set_muc_sets_muc(void** state); +void cmd_account_set_nick_sets_nick(void** state); +void cmd_account_show_message_for_missing_otr_policy(void** state); +void cmd_account_show_message_for_invalid_otr_policy(void** state); +void cmd_account_set_otr_sets_otr(void** state); +void cmd_account_set_status_shows_message_when_invalid_status(void** state); +void cmd_account_set_status_sets_status_when_valid(void** state); +void cmd_account_set_status_sets_status_when_last(void** state); +void cmd_account_set_invalid_presence_string_priority_shows_message(void** state); +void cmd_account_set_last_priority_shows_message(void** state); +void cmd_account_set_online_priority_sets_preference(void** state); +void cmd_account_set_chat_priority_sets_preference(void** state); +void cmd_account_set_away_priority_sets_preference(void** state); +void cmd_account_set_xa_priority_sets_preference(void** state); +void cmd_account_set_dnd_priority_sets_preference(void** state); +void cmd_account_set_priority_too_low_shows_message(void** state); +void cmd_account_set_priority_too_high_shows_message(void** state); +void cmd_account_set_priority_when_not_number_shows_message(void** state); +void cmd_account_set_priority_when_empty_shows_message(void** state); +void cmd_account_set_priority_updates_presence_when_account_connected_with_presence(void** state); +void cmd_account_clear_shows_usage_when_no_args(void** state); +void cmd_account_clear_shows_usage_when_one_arg(void** state); +void cmd_account_clear_shows_message_when_account_doesnt_exist(void** state); +void cmd_account_clear_shows_message_when_invalid_property(void** state); diff --git a/tests/unittests/test_cmd_alias.c b/tests/unittests/test_cmd_alias.c index b7f27d3d..718bca2a 100644 --- a/tests/unittests/test_cmd_alias.c +++ b/tests/unittests/test_cmd_alias.c @@ -19,9 +19,10 @@ #define CMD_ALIAS "/alias" -void cmd_alias_add_shows_usage_when_no_args(void **state) +void +cmd_alias_add_shows_usage_when_no_args(void** state) { - gchar *args[] = { "add", NULL }; + gchar* args[] = { "add", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS); @@ -29,9 +30,10 @@ void cmd_alias_add_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_alias_add_shows_usage_when_no_value(void **state) +void +cmd_alias_add_shows_usage_when_no_value(void** state) { - gchar *args[] = { "add", "alias", NULL }; + gchar* args[] = { "add", "alias", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS); @@ -39,9 +41,10 @@ void cmd_alias_add_shows_usage_when_no_value(void **state) assert_true(result); } -void cmd_alias_remove_shows_usage_when_no_args(void **state) +void +cmd_alias_remove_shows_usage_when_no_args(void** state) { - gchar *args[] = { "remove", NULL }; + gchar* args[] = { "remove", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS); @@ -49,9 +52,10 @@ void cmd_alias_remove_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_alias_show_usage_when_invalid_subcmd(void **state) +void +cmd_alias_show_usage_when_invalid_subcmd(void** state) { - gchar *args[] = { "blah", NULL }; + gchar* args[] = { "blah", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_ALIAS); @@ -59,24 +63,26 @@ void cmd_alias_show_usage_when_invalid_subcmd(void **state) assert_true(result); } -void cmd_alias_add_adds_alias(void **state) +void +cmd_alias_add_adds_alias(void** state) { - gchar *args[] = { "add", "hc", "/help commands", NULL }; + gchar* args[] = { "add", "hc", "/help commands", NULL }; expect_cons_show("Command alias added /hc -> /help commands"); gboolean result = cmd_alias(NULL, CMD_ALIAS, args); assert_true(result); - char *returned_val = prefs_get_alias("hc"); + char* returned_val = prefs_get_alias("hc"); assert_string_equal("/help commands", returned_val); free(returned_val); } -void cmd_alias_add_shows_message_when_exists(void **state) +void +cmd_alias_add_shows_message_when_exists(void** state) { - gchar *args[] = { "add", "hc", "/help commands", NULL }; + gchar* args[] = { "add", "hc", "/help commands", NULL }; cmd_init(); prefs_add_alias("hc", "/help commands"); @@ -88,9 +94,10 @@ void cmd_alias_add_shows_message_when_exists(void **state) assert_true(result); } -void cmd_alias_remove_removes_alias(void **state) +void +cmd_alias_remove_removes_alias(void** state) { - gchar *args[] = { "remove", "hn", NULL }; + gchar* args[] = { "remove", "hn", NULL }; prefs_add_alias("hn", "/help navigation"); @@ -99,15 +106,16 @@ void cmd_alias_remove_removes_alias(void **state) gboolean result = cmd_alias(NULL, CMD_ALIAS, args); assert_true(result); - char *returned_val = prefs_get_alias("hn"); + char* returned_val = prefs_get_alias("hn"); assert_null(returned_val); - + free(returned_val); } -void cmd_alias_remove_shows_message_when_no_alias(void **state) +void +cmd_alias_remove_shows_message_when_no_alias(void** state) { - gchar *args[] = { "remove", "hn", NULL }; + gchar* args[] = { "remove", "hn", NULL }; expect_cons_show("No such command alias /hn"); @@ -115,9 +123,10 @@ void cmd_alias_remove_shows_message_when_no_alias(void **state) assert_true(result); } -void cmd_alias_list_shows_all_aliases(void **state) +void +cmd_alias_list_shows_all_aliases(void** state) { - gchar *args[] = { "list", NULL }; + gchar* args[] = { "list", NULL }; prefs_add_alias("vy", "/vercheck on"); prefs_add_alias("q", "/quit"); diff --git a/tests/unittests/test_cmd_alias.h b/tests/unittests/test_cmd_alias.h index bd93ef1a..b674d479 100644 --- a/tests/unittests/test_cmd_alias.h +++ b/tests/unittests/test_cmd_alias.h @@ -1,9 +1,9 @@ -void cmd_alias_add_shows_usage_when_no_args(void **state); -void cmd_alias_add_shows_usage_when_no_value(void **state); -void cmd_alias_remove_shows_usage_when_no_args(void **state); -void cmd_alias_show_usage_when_invalid_subcmd(void **state); -void cmd_alias_add_adds_alias(void **state); -void cmd_alias_add_shows_message_when_exists(void **state); -void cmd_alias_remove_removes_alias(void **state); -void cmd_alias_remove_shows_message_when_no_alias(void **state); -void cmd_alias_list_shows_all_aliases(void **state); +void cmd_alias_add_shows_usage_when_no_args(void** state); +void cmd_alias_add_shows_usage_when_no_value(void** state); +void cmd_alias_remove_shows_usage_when_no_args(void** state); +void cmd_alias_show_usage_when_invalid_subcmd(void** state); +void cmd_alias_add_adds_alias(void** state); +void cmd_alias_add_shows_message_when_exists(void** state); +void cmd_alias_remove_removes_alias(void** state); +void cmd_alias_remove_shows_message_when_no_alias(void** state); +void cmd_alias_list_shows_all_aliases(void** state); diff --git a/tests/unittests/test_cmd_bookmark.c b/tests/unittests/test_cmd_bookmark.c index 7b385706..58201ca6 100644 --- a/tests/unittests/test_cmd_bookmark.c +++ b/tests/unittests/test_cmd_bookmark.c @@ -22,7 +22,8 @@ #define CMD_BOOKMARK "/bookmark" -static void test_with_connection_status(jabber_conn_status_t status) +static void +test_with_connection_status(jabber_conn_status_t status) { ProfWin window; window.type = WIN_CONSOLE; @@ -33,24 +34,28 @@ static void test_with_connection_status(jabber_conn_status_t status) assert_true(result); } -void cmd_bookmark_shows_message_when_disconnected(void **state) +void +cmd_bookmark_shows_message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } -void cmd_bookmark_shows_message_when_disconnecting(void **state) +void +cmd_bookmark_shows_message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } -void cmd_bookmark_shows_message_when_connecting(void **state) +void +cmd_bookmark_shows_message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } -void cmd_bookmark_shows_usage_when_no_args(void **state) +void +cmd_bookmark_shows_usage_when_no_args(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -72,7 +77,7 @@ static void _free_bookmark(Bookmark *bookmark) */ static gboolean -_cmp_bookmark(Bookmark *bm1, Bookmark *bm2) +_cmp_bookmark(Bookmark* bm1, Bookmark* bm2) { if (strcmp(bm1->barejid, bm2->barejid) != 0) { return FALSE; @@ -87,30 +92,31 @@ _cmp_bookmark(Bookmark *bm1, Bookmark *bm2) return TRUE; } -void cmd_bookmark_list_shows_bookmarks(void **state) +void +cmd_bookmark_list_shows_bookmarks(void** state) { - gchar *args[] = { "list", NULL }; - GList *bookmarks = NULL; + gchar* args[] = { "list", NULL }; + GList* bookmarks = NULL; ProfWin window; window.type = WIN_CONSOLE; - Bookmark *bm1 = malloc(sizeof(Bookmark)); + Bookmark* bm1 = malloc(sizeof(Bookmark)); bm1->barejid = strdup("room1@conf.org"); bm1->nick = strdup("bob"); bm1->autojoin = FALSE; - Bookmark *bm2 = malloc(sizeof(Bookmark)); + Bookmark* bm2 = malloc(sizeof(Bookmark)); bm2->barejid = strdup("room2@conf.org"); bm2->nick = strdup("steve"); bm2->autojoin = TRUE; - Bookmark *bm3 = malloc(sizeof(Bookmark)); + Bookmark* bm3 = malloc(sizeof(Bookmark)); bm3->barejid = strdup("room3@conf.org"); bm3->nick = strdup("dave"); bm3->autojoin = TRUE; - Bookmark *bm4 = malloc(sizeof(Bookmark)); + Bookmark* bm4 = malloc(sizeof(Bookmark)); bm4->barejid = strdup("room4@conf.org"); bm4->nick = strdup("james"); bm4->autojoin = FALSE; - Bookmark *bm5 = malloc(sizeof(Bookmark)); + Bookmark* bm5 = malloc(sizeof(Bookmark)); bm5->barejid = strdup("room5@conf.org"); bm5->nick = strdup("mike"); bm5->autojoin = FALSE; @@ -148,10 +154,11 @@ void cmd_bookmark_list_shows_bookmarks(void **state) free(bm5); } -void cmd_bookmark_add_shows_message_when_invalid_jid(void **state) +void +cmd_bookmark_add_shows_message_when_invalid_jid(void** state) { - char *jid = "room"; - gchar *args[] = { "add", jid, NULL }; + char* jid = "room"; + gchar* args[] = { "add", jid, NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -164,10 +171,11 @@ void cmd_bookmark_add_shows_message_when_invalid_jid(void **state) assert_true(result); } -void cmd_bookmark_add_adds_bookmark_with_jid(void **state) +void +cmd_bookmark_add_adds_bookmark_with_jid(void** state) { - char *jid = "room@conf.server"; - gchar *args[] = { "add", jid, NULL }; + char* jid = "room@conf.server"; + gchar* args[] = { "add", jid, NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -185,11 +193,12 @@ void cmd_bookmark_add_adds_bookmark_with_jid(void **state) assert_true(result); } -void cmd_bookmark_uses_roomjid_in_room(void **state) +void +cmd_bookmark_uses_roomjid_in_room(void** state) { muc_init(); - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; ProfMucWin muc_win; muc_win.window.type = WIN_MUC; muc_win.memcheck = PROFMUCWIN_MEMCHECK; @@ -211,11 +220,12 @@ void cmd_bookmark_uses_roomjid_in_room(void **state) muc_close(); } -void cmd_bookmark_add_uses_roomjid_in_room(void **state) +void +cmd_bookmark_add_uses_roomjid_in_room(void** state) { muc_init(); - gchar *args[] = { "add", NULL }; + gchar* args[] = { "add", NULL }; ProfMucWin muc_win; muc_win.window.type = WIN_MUC; muc_win.memcheck = PROFMUCWIN_MEMCHECK; @@ -237,12 +247,13 @@ void cmd_bookmark_add_uses_roomjid_in_room(void **state) muc_close(); } -void cmd_bookmark_add_uses_supplied_jid_in_room(void **state) +void +cmd_bookmark_add_uses_supplied_jid_in_room(void** state) { muc_init(); - char *jid = "room1@conf.server"; - gchar *args[] = { "add", jid, NULL }; + char* jid = "room1@conf.server"; + gchar* args[] = { "add", jid, NULL }; ProfMucWin muc_win; muc_win.window.type = WIN_MUC; muc_win.memcheck = PROFMUCWIN_MEMCHECK; @@ -264,11 +275,12 @@ void cmd_bookmark_add_uses_supplied_jid_in_room(void **state) muc_close(); } -void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state) +void +cmd_bookmark_add_adds_bookmark_with_jid_nick(void** state) { - char *jid = "room@conf.server"; - char *nick = "bob"; - gchar *args[] = { "add", jid, "nick", nick, NULL }; + char* jid = "room@conf.server"; + char* nick = "bob"; + gchar* args[] = { "add", jid, "nick", nick, NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -286,10 +298,11 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state) assert_true(result); } -void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state) +void +cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void** state) { - char *jid = "room@conf.server"; - gchar *args[] = { "add", jid, "autojoin", "on", NULL }; + char* jid = "room@conf.server"; + gchar* args[] = { "add", jid, "autojoin", "on", NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -307,11 +320,12 @@ void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state) assert_true(result); } -void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state) +void +cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void** state) { - char *jid = "room@conf.server"; - char *nick = "bob"; - gchar *args[] = { "add", jid, "nick", nick, "autojoin", "on", NULL }; + char* jid = "room@conf.server"; + char* nick = "bob"; + gchar* args[] = { "add", jid, "nick", nick, "autojoin", "on", NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -329,10 +343,11 @@ void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state) assert_true(result); } -void cmd_bookmark_remove_removes_bookmark(void **state) +void +cmd_bookmark_remove_removes_bookmark(void** state) { - char *jid = "room@conf.server"; - gchar *args[] = { "remove", jid, NULL }; + char* jid = "room@conf.server"; + gchar* args[] = { "remove", jid, NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -347,10 +362,11 @@ void cmd_bookmark_remove_removes_bookmark(void **state) assert_true(result); } -void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state) +void +cmd_bookmark_remove_shows_message_when_no_bookmark(void** state) { - char *jid = "room@conf.server"; - gchar *args[] = { "remove", jid, NULL }; + char* jid = "room@conf.server"; + gchar* args[] = { "remove", jid, NULL }; ProfWin window; window.type = WIN_CONSOLE; @@ -365,11 +381,12 @@ void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state) assert_true(result); } -void cmd_bookmark_remove_uses_roomjid_in_room(void **state) +void +cmd_bookmark_remove_uses_roomjid_in_room(void** state) { muc_init(); - gchar *args[] = { "remove", NULL }; + gchar* args[] = { "remove", NULL }; ProfMucWin muc_win; muc_win.window.type = WIN_MUC; muc_win.memcheck = PROFMUCWIN_MEMCHECK; @@ -388,12 +405,13 @@ void cmd_bookmark_remove_uses_roomjid_in_room(void **state) muc_close(); } -void cmd_bookmark_remove_uses_supplied_jid_in_room(void **state) +void +cmd_bookmark_remove_uses_supplied_jid_in_room(void** state) { muc_init(); - char *jid = "room1@conf.server"; - gchar *args[] = { "remove", jid, NULL }; + char* jid = "room1@conf.server"; + gchar* args[] = { "remove", jid, NULL }; ProfMucWin muc_win; muc_win.window.type = WIN_MUC; muc_win.memcheck = PROFMUCWIN_MEMCHECK; diff --git a/tests/unittests/test_cmd_bookmark.h b/tests/unittests/test_cmd_bookmark.h index 195882b5..d8e598bb 100644 --- a/tests/unittests/test_cmd_bookmark.h +++ b/tests/unittests/test_cmd_bookmark.h @@ -1,18 +1,18 @@ -void cmd_bookmark_shows_message_when_disconnected(void **state); -void cmd_bookmark_shows_message_when_disconnecting(void **state); -void cmd_bookmark_shows_message_when_connecting(void **state); -void cmd_bookmark_shows_message_when_undefined(void **state); -void cmd_bookmark_shows_usage_when_no_args(void **state); -void cmd_bookmark_list_shows_bookmarks(void **state); -void cmd_bookmark_add_shows_message_when_invalid_jid(void **state); -void cmd_bookmark_add_adds_bookmark_with_jid(void **state); -void cmd_bookmark_uses_roomjid_in_room(void **state); -void cmd_bookmark_add_uses_roomjid_in_room(void **state); -void cmd_bookmark_add_uses_supplied_jid_in_room(void **state); -void cmd_bookmark_remove_uses_roomjid_in_room(void **state); -void cmd_bookmark_remove_uses_supplied_jid_in_room(void **state); -void cmd_bookmark_add_adds_bookmark_with_jid_nick(void **state); -void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void **state); -void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void **state); -void cmd_bookmark_remove_removes_bookmark(void **state); -void cmd_bookmark_remove_shows_message_when_no_bookmark(void **state); +void cmd_bookmark_shows_message_when_disconnected(void** state); +void cmd_bookmark_shows_message_when_disconnecting(void** state); +void cmd_bookmark_shows_message_when_connecting(void** state); +void cmd_bookmark_shows_message_when_undefined(void** state); +void cmd_bookmark_shows_usage_when_no_args(void** state); +void cmd_bookmark_list_shows_bookmarks(void** state); +void cmd_bookmark_add_shows_message_when_invalid_jid(void** state); +void cmd_bookmark_add_adds_bookmark_with_jid(void** state); +void cmd_bookmark_uses_roomjid_in_room(void** state); +void cmd_bookmark_add_uses_roomjid_in_room(void** state); +void cmd_bookmark_add_uses_supplied_jid_in_room(void** state); +void cmd_bookmark_remove_uses_roomjid_in_room(void** state); +void cmd_bookmark_remove_uses_supplied_jid_in_room(void** state); +void cmd_bookmark_add_adds_bookmark_with_jid_nick(void** state); +void cmd_bookmark_add_adds_bookmark_with_jid_autojoin(void** state); +void cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin(void** state); +void cmd_bookmark_remove_removes_bookmark(void** state); +void cmd_bookmark_remove_shows_message_when_no_bookmark(void** state); diff --git a/tests/unittests/test_cmd_connect.c b/tests/unittests/test_cmd_connect.c index 9d1fd157..63f08f6d 100644 --- a/tests/unittests/test_cmd_connect.c +++ b/tests/unittests/test_cmd_connect.c @@ -16,7 +16,8 @@ #define CMD_CONNECT "/connect" -static void test_with_connection_status(jabber_conn_status_t status) +static void +test_with_connection_status(jabber_conn_status_t status) { will_return(connection_get_status, status); @@ -26,24 +27,28 @@ static void test_with_connection_status(jabber_conn_status_t status) assert_true(result); } -void cmd_connect_shows_message_when_disconnecting(void **state) +void +cmd_connect_shows_message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } -void cmd_connect_shows_message_when_connecting(void **state) +void +cmd_connect_shows_message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } -void cmd_connect_shows_message_when_connected(void **state) +void +cmd_connect_shows_message_when_connected(void** state) { test_with_connection_status(JABBER_CONNECTED); } -void cmd_connect_when_no_account(void **state) +void +cmd_connect_when_no_account(void** state) { - gchar *args[] = { "user@server.org", NULL }; + gchar* args[] = { "user@server.org", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -64,9 +69,10 @@ void cmd_connect_when_no_account(void **state) assert_true(result); } -void cmd_connect_fail_message(void **state) +void +cmd_connect_fail_message(void** state) { - gchar *args[] = { "user@server.org", NULL }; + gchar* args[] = { "user@server.org", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -89,9 +95,10 @@ void cmd_connect_fail_message(void **state) assert_true(result); } -void cmd_connect_lowercases_argument_with_no_account(void **state) +void +cmd_connect_lowercases_argument_with_no_account(void** state) { - gchar *args[] = { "USER@server.ORG", NULL }; + gchar* args[] = { "USER@server.ORG", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -112,11 +119,12 @@ void cmd_connect_lowercases_argument_with_no_account(void **state) assert_true(result); } -void cmd_connect_lowercases_argument_with_account(void **state) +void +cmd_connect_lowercases_argument_with_account(void** state) { -gchar *args[] = { "Jabber_org", NULL }; - ProfAccount *account = account_new("Jabber_org", "me@jabber.org", "password", NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "Jabber_org", NULL }; + ProfAccount* account = account_new("Jabber_org", "me@jabber.org", "password", NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_DISCONNECTED); @@ -132,11 +140,12 @@ gchar *args[] = { "Jabber_org", NULL }; assert_true(result); } -void cmd_connect_asks_password_when_not_in_account(void **state) +void +cmd_connect_asks_password_when_not_in_account(void** state) { - gchar *args[] = { "jabber_org", NULL }; - ProfAccount *account = account_new("jabber_org", "me@jabber.org", NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "jabber_org", NULL }; + ProfAccount* account = account_new("jabber_org", "me@jabber.org", NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_DISCONNECTED); @@ -154,9 +163,10 @@ void cmd_connect_asks_password_when_not_in_account(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_no_server_value(void **state) +void +cmd_connect_shows_usage_when_no_server_value(void** state) { - gchar *args[] = { "user@server.org", "server", NULL }; + gchar* args[] = { "user@server.org", "server", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -167,9 +177,10 @@ void cmd_connect_shows_usage_when_no_server_value(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_server_no_port_value(void **state) +void +cmd_connect_shows_usage_when_server_no_port_value(void** state) { - gchar *args[] = { "user@server.org", "server", "aserver", "port", NULL }; + gchar* args[] = { "user@server.org", "server", "aserver", "port", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -180,9 +191,10 @@ void cmd_connect_shows_usage_when_server_no_port_value(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_no_port_value(void **state) +void +cmd_connect_shows_usage_when_no_port_value(void** state) { - gchar *args[] = { "user@server.org", "port", NULL }; + gchar* args[] = { "user@server.org", "port", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -193,9 +205,10 @@ void cmd_connect_shows_usage_when_no_port_value(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_port_no_server_value(void **state) +void +cmd_connect_shows_usage_when_port_no_server_value(void** state) { - gchar *args[] = { "user@server.org", "port", "5678", "server", NULL }; + gchar* args[] = { "user@server.org", "port", "5678", "server", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -206,9 +219,10 @@ void cmd_connect_shows_usage_when_port_no_server_value(void **state) assert_true(result); } -void cmd_connect_shows_message_when_port_0(void **state) +void +cmd_connect_shows_message_when_port_0(void** state) { - gchar *args[] = { "user@server.org", "port", "0", NULL }; + gchar* args[] = { "user@server.org", "port", "0", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -219,9 +233,10 @@ void cmd_connect_shows_message_when_port_0(void **state) assert_true(result); } -void cmd_connect_shows_message_when_port_minus1(void **state) +void +cmd_connect_shows_message_when_port_minus1(void** state) { - gchar *args[] = { "user@server.org", "port", "-1", NULL }; + gchar* args[] = { "user@server.org", "port", "-1", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -232,9 +247,10 @@ void cmd_connect_shows_message_when_port_minus1(void **state) assert_true(result); } -void cmd_connect_shows_message_when_port_65536(void **state) +void +cmd_connect_shows_message_when_port_65536(void** state) { - gchar *args[] = { "user@server.org", "port", "65536", NULL }; + gchar* args[] = { "user@server.org", "port", "65536", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -245,9 +261,10 @@ void cmd_connect_shows_message_when_port_65536(void **state) assert_true(result); } -void cmd_connect_shows_message_when_port_contains_chars(void **state) +void +cmd_connect_shows_message_when_port_contains_chars(void** state) { - gchar *args[] = { "user@server.org", "port", "52f66", NULL }; + gchar* args[] = { "user@server.org", "port", "52f66", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -258,9 +275,10 @@ void cmd_connect_shows_message_when_port_contains_chars(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_server_provided_twice(void **state) +void +cmd_connect_shows_usage_when_server_provided_twice(void** state) { - gchar *args[] = { "user@server.org", "server", "server1", "server", "server2", NULL }; + gchar* args[] = { "user@server.org", "server", "server1", "server", "server2", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -271,9 +289,10 @@ void cmd_connect_shows_usage_when_server_provided_twice(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_port_provided_twice(void **state) +void +cmd_connect_shows_usage_when_port_provided_twice(void** state) { - gchar *args[] = { "user@server.org", "port", "1111", "port", "1111", NULL }; + gchar* args[] = { "user@server.org", "port", "1111", "port", "1111", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -284,9 +303,10 @@ void cmd_connect_shows_usage_when_port_provided_twice(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_invalid_first_property(void **state) +void +cmd_connect_shows_usage_when_invalid_first_property(void** state) { - gchar *args[] = { "user@server.org", "wrong", "server", NULL }; + gchar* args[] = { "user@server.org", "wrong", "server", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -297,9 +317,10 @@ void cmd_connect_shows_usage_when_invalid_first_property(void **state) assert_true(result); } -void cmd_connect_shows_usage_when_invalid_second_property(void **state) +void +cmd_connect_shows_usage_when_invalid_second_property(void** state) { - gchar *args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL }; + gchar* args[] = { "user@server.org", "server", "aserver", "wrong", "1234", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -310,9 +331,10 @@ void cmd_connect_shows_usage_when_invalid_second_property(void **state) assert_true(result); } -void cmd_connect_with_server_when_provided(void **state) +void +cmd_connect_with_server_when_provided(void** state) { - gchar *args[] = { "user@server.org", "server", "aserver", NULL }; + gchar* args[] = { "user@server.org", "server", "aserver", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -333,9 +355,10 @@ void cmd_connect_with_server_when_provided(void **state) assert_true(result); } -void cmd_connect_with_port_when_provided(void **state) +void +cmd_connect_with_port_when_provided(void** state) { - gchar *args[] = { "user@server.org", "port", "5432", NULL }; + gchar* args[] = { "user@server.org", "port", "5432", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -356,9 +379,10 @@ void cmd_connect_with_port_when_provided(void **state) assert_true(result); } -void cmd_connect_with_server_and_port_when_provided(void **state) +void +cmd_connect_with_server_and_port_when_provided(void** state) { - gchar *args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL }; + gchar* args[] = { "user@server.org", "port", "5432", "server", "aserver", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -379,11 +403,12 @@ void cmd_connect_with_server_and_port_when_provided(void **state) assert_true(result); } -void cmd_connect_shows_message_when_connecting_with_account(void **state) +void +cmd_connect_shows_message_when_connecting_with_account(void** state) { - gchar *args[] = { "jabber_org", NULL }; - ProfAccount *account = account_new("jabber_org", "user@jabber.org", "password", NULL, - TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "jabber_org", NULL }; + ProfAccount* account = account_new("jabber_org", "user@jabber.org", "password", NULL, + TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_DISCONNECTED); @@ -399,11 +424,12 @@ void cmd_connect_shows_message_when_connecting_with_account(void **state) assert_true(result); } -void cmd_connect_connects_with_account(void **state) +void +cmd_connect_connects_with_account(void** state) { - gchar *args[] = { "jabber_org", NULL }; - ProfAccount *account = account_new("jabber_org", "me@jabber.org", "password", NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "jabber_org", NULL }; + ProfAccount* account = account_new("jabber_org", "me@jabber.org", "password", NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_DISCONNECTED); diff --git a/tests/unittests/test_cmd_connect.h b/tests/unittests/test_cmd_connect.h index c9c01c9a..14e7f7b2 100644 --- a/tests/unittests/test_cmd_connect.h +++ b/tests/unittests/test_cmd_connect.h @@ -1,27 +1,27 @@ -void cmd_connect_shows_message_when_disconnecting(void **state); -void cmd_connect_shows_message_when_connecting(void **state); -void cmd_connect_shows_message_when_connected(void **state); -void cmd_connect_shows_message_when_undefined(void **state); -void cmd_connect_when_no_account(void **state); -void cmd_connect_with_altdomain_when_provided(void **state); -void cmd_connect_fail_message(void **state); -void cmd_connect_lowercases_argument_with_no_account(void **state); -void cmd_connect_lowercases_argument_with_account(void **state); -void cmd_connect_asks_password_when_not_in_account(void **state); -void cmd_connect_shows_message_when_connecting_with_account(void **state); -void cmd_connect_connects_with_account(void **state); -void cmd_connect_shows_usage_when_no_server_value(void **state); -void cmd_connect_shows_usage_when_server_no_port_value(void **state); -void cmd_connect_shows_usage_when_no_port_value(void **state); -void cmd_connect_shows_usage_when_port_no_server_value(void **state); -void cmd_connect_shows_message_when_port_0(void **state); -void cmd_connect_shows_message_when_port_minus1(void **state); -void cmd_connect_shows_message_when_port_65536(void **state); -void cmd_connect_shows_message_when_port_contains_chars(void **state); -void cmd_connect_with_server_when_provided(void **state); -void cmd_connect_with_port_when_provided(void **state); -void cmd_connect_with_server_and_port_when_provided(void **state); -void cmd_connect_shows_usage_when_server_provided_twice(void **state); -void cmd_connect_shows_usage_when_port_provided_twice(void **state); -void cmd_connect_shows_usage_when_invalid_first_property(void **state); -void cmd_connect_shows_usage_when_invalid_second_property(void **state); +void cmd_connect_shows_message_when_disconnecting(void** state); +void cmd_connect_shows_message_when_connecting(void** state); +void cmd_connect_shows_message_when_connected(void** state); +void cmd_connect_shows_message_when_undefined(void** state); +void cmd_connect_when_no_account(void** state); +void cmd_connect_with_altdomain_when_provided(void** state); +void cmd_connect_fail_message(void** state); +void cmd_connect_lowercases_argument_with_no_account(void** state); +void cmd_connect_lowercases_argument_with_account(void** state); +void cmd_connect_asks_password_when_not_in_account(void** state); +void cmd_connect_shows_message_when_connecting_with_account(void** state); +void cmd_connect_connects_with_account(void** state); +void cmd_connect_shows_usage_when_no_server_value(void** state); +void cmd_connect_shows_usage_when_server_no_port_value(void** state); +void cmd_connect_shows_usage_when_no_port_value(void** state); +void cmd_connect_shows_usage_when_port_no_server_value(void** state); +void cmd_connect_shows_message_when_port_0(void** state); +void cmd_connect_shows_message_when_port_minus1(void** state); +void cmd_connect_shows_message_when_port_65536(void** state); +void cmd_connect_shows_message_when_port_contains_chars(void** state); +void cmd_connect_with_server_when_provided(void** state); +void cmd_connect_with_port_when_provided(void** state); +void cmd_connect_with_server_and_port_when_provided(void** state); +void cmd_connect_shows_usage_when_server_provided_twice(void** state); +void cmd_connect_shows_usage_when_port_provided_twice(void** state); +void cmd_connect_shows_usage_when_invalid_first_property(void** state); +void cmd_connect_shows_usage_when_invalid_second_property(void** state); diff --git a/tests/unittests/test_cmd_disconnect.c b/tests/unittests/test_cmd_disconnect.c index 0d46d532..ac3c36da 100644 --- a/tests/unittests/test_cmd_disconnect.c +++ b/tests/unittests/test_cmd_disconnect.c @@ -14,7 +14,8 @@ #define CMD_DISCONNECT "/disconnect" -void clears_chat_sessions(void **state) +void +clears_chat_sessions(void** state) { chat_sessions_init(); roster_create(); @@ -29,8 +30,8 @@ void clears_chat_sessions(void **state) assert_true(result); - ChatSession *session1 = chat_session_get("bob@server.org"); - ChatSession *session2 = chat_session_get("mike@server.org"); + ChatSession* session1 = chat_session_get("bob@server.org"); + ChatSession* session2 = chat_session_get("mike@server.org"); assert_null(session1); assert_null(session2); } diff --git a/tests/unittests/test_cmd_disconnect.h b/tests/unittests/test_cmd_disconnect.h index 856b501e..0988bd25 100644 --- a/tests/unittests/test_cmd_disconnect.h +++ b/tests/unittests/test_cmd_disconnect.h @@ -1 +1 @@ -void clears_chat_sessions(void **state); +void clears_chat_sessions(void** state); diff --git a/tests/unittests/test_cmd_join.c b/tests/unittests/test_cmd_join.c index ed14a935..c4af4040 100644 --- a/tests/unittests/test_cmd_join.c +++ b/tests/unittests/test_cmd_join.c @@ -18,7 +18,8 @@ #define CMD_JOIN "/join" -static void test_with_connection_status(jabber_conn_status_t status) +static void +test_with_connection_status(jabber_conn_status_t status) { will_return(connection_get_status, status); @@ -28,24 +29,28 @@ static void test_with_connection_status(jabber_conn_status_t status) assert_true(result); } -void cmd_join_shows_message_when_disconnecting(void **state) +void +cmd_join_shows_message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } -void cmd_join_shows_message_when_connecting(void **state) +void +cmd_join_shows_message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } -void cmd_join_shows_message_when_disconnected(void **state) +void +cmd_join_shows_message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } -void cmd_join_shows_error_message_when_invalid_room_jid(void **state) +void +cmd_join_shows_error_message_when_invalid_room_jid(void** state) { - gchar *args[] = { "//@@/", NULL }; + gchar* args[] = { "//@@/", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -56,16 +61,17 @@ void cmd_join_shows_error_message_when_invalid_room_jid(void **state) assert_true(result); } -void cmd_join_uses_account_mucservice_when_no_service_specified(void **state) +void +cmd_join_uses_account_mucservice_when_no_service_specified(void** state) { - char *account_name = "an_account"; - char *room = "room"; - char *nick = "bob"; - char *account_service = "conference.server.org"; - char *expected_room = "room@conference.server.org"; - gchar *args[] = { room, "nick", nick, NULL }; - ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, - TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + char* account_name = "an_account"; + char* room = "room"; + char* nick = "bob"; + char* account_service = "conference.server.org"; + char* expected_room = "room@conference.server.org"; + gchar* args[] = { room, "nick", nick, NULL }; + ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL, + TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); @@ -85,14 +91,15 @@ void cmd_join_uses_account_mucservice_when_no_service_specified(void **state) muc_close(); } -void cmd_join_uses_supplied_nick(void **state) +void +cmd_join_uses_supplied_nick(void** state) { - char *account_name = "an_account"; - char *room = "room@conf.server.org"; - char *nick = "bob"; - gchar *args[] = { room, "nick", nick, NULL }; - ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, - TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + char* account_name = "an_account"; + char* room = "room@conf.server.org"; + char* nick = "bob"; + gchar* args[] = { room, "nick", nick, NULL }; + ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL, + TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); @@ -112,14 +119,15 @@ void cmd_join_uses_supplied_nick(void **state) muc_close(); } -void cmd_join_uses_account_nick_when_not_supplied(void **state) +void +cmd_join_uses_account_nick_when_not_supplied(void** state) { - char *account_name = "an_account"; - char *room = "room2@conf.server.org"; - char *account_nick = "a_nick"; - gchar *args[] = { room, NULL }; - ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, - TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + char* account_name = "an_account"; + char* room = "room2@conf.server.org"; + char* account_nick = "a_nick"; + gchar* args[] = { room, NULL }; + ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL, + TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, NULL, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); @@ -139,17 +147,18 @@ void cmd_join_uses_account_nick_when_not_supplied(void **state) muc_close(); } -void cmd_join_uses_password_when_supplied(void **state) +void +cmd_join_uses_password_when_supplied(void** state) { - char *account_name = "an_account"; - char *room = "room"; - char *password = "a_password"; - char *account_nick = "a_nick"; - char *account_service = "a_service"; - char *expected_room = "room@a_service"; - gchar *args[] = { room, "password", password, NULL }; - ProfAccount *account = account_new(account_name, "user@server.org", NULL, NULL, - TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + char* account_name = "an_account"; + char* room = "room"; + char* password = "a_password"; + char* account_nick = "a_nick"; + char* account_service = "a_service"; + char* expected_room = "room@a_service"; + gchar* args[] = { room, "password", password, NULL }; + ProfAccount* account = account_new(account_name, "user@server.org", NULL, NULL, + TRUE, NULL, 0, "laptop", NULL, NULL, 0, 0, 0, 0, 0, account_service, account_nick, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); muc_init(); diff --git a/tests/unittests/test_cmd_join.h b/tests/unittests/test_cmd_join.h index a96fa435..c22d9847 100644 --- a/tests/unittests/test_cmd_join.h +++ b/tests/unittests/test_cmd_join.h @@ -1,9 +1,9 @@ -void cmd_join_shows_message_when_disconnecting(void **state); -void cmd_join_shows_message_when_connecting(void **state); -void cmd_join_shows_message_when_disconnected(void **state); -void cmd_join_shows_message_when_undefined(void **state); -void cmd_join_shows_error_message_when_invalid_room_jid(void **state); -void cmd_join_uses_account_mucservice_when_no_service_specified(void **state); -void cmd_join_uses_supplied_nick(void **state); -void cmd_join_uses_account_nick_when_not_supplied(void **state); -void cmd_join_uses_password_when_supplied(void **state); +void cmd_join_shows_message_when_disconnecting(void** state); +void cmd_join_shows_message_when_connecting(void** state); +void cmd_join_shows_message_when_disconnected(void** state); +void cmd_join_shows_message_when_undefined(void** state); +void cmd_join_shows_error_message_when_invalid_room_jid(void** state); +void cmd_join_uses_account_mucservice_when_no_service_specified(void** state); +void cmd_join_uses_supplied_nick(void** state); +void cmd_join_uses_account_nick_when_not_supplied(void** state); +void cmd_join_uses_password_when_supplied(void** state); diff --git a/tests/unittests/test_cmd_otr.c b/tests/unittests/test_cmd_otr.c index 4782d048..72141756 100644 --- a/tests/unittests/test_cmd_otr.c +++ b/tests/unittests/test_cmd_otr.c @@ -26,9 +26,10 @@ #define CMD_OTR "/otr" #ifdef HAVE_LIBOTR -void cmd_otr_log_shows_usage_when_no_args(void **state) +void +cmd_otr_log_shows_usage_when_no_args(void** state) { - gchar *args[] = { "log", NULL }; + gchar* args[] = { "log", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_OTR); @@ -36,9 +37,10 @@ void cmd_otr_log_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_otr_log_shows_usage_when_invalid_subcommand(void **state) +void +cmd_otr_log_shows_usage_when_invalid_subcommand(void** state) { - gchar *args[] = { "log", "wrong", NULL }; + gchar* args[] = { "log", "wrong", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_OTR); @@ -46,25 +48,27 @@ void cmd_otr_log_shows_usage_when_invalid_subcommand(void **state) assert_true(result); } -void cmd_otr_log_on_enables_logging(void **state) +void +cmd_otr_log_on_enables_logging(void** state) { - gchar *args[] = { "log", "on", NULL }; + gchar* args[] = { "log", "on", NULL }; prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_boolean(PREF_CHLOG, TRUE); expect_cons_show("OTR messages will be logged as plaintext."); gboolean result = cmd_otr_log(NULL, CMD_OTR, args); - char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); + char* pref_otr_log = prefs_get_string(PREF_OTR_LOG); assert_true(result); assert_string_equal("on", pref_otr_log); g_free(pref_otr_log); } -void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state) +void +cmd_otr_log_on_shows_warning_when_chlog_disabled(void** state) { - gchar *args[] = { "log", "on", NULL }; + gchar* args[] = { "log", "on", NULL }; prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_boolean(PREF_CHLOG, FALSE); @@ -75,41 +79,44 @@ void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state) assert_true(result); } -void cmd_otr_log_off_disables_logging(void **state) +void +cmd_otr_log_off_disables_logging(void** state) { - gchar *args[] = { "log", "off", NULL }; + gchar* args[] = { "log", "off", NULL }; prefs_set_string(PREF_OTR_LOG, "on"); prefs_set_boolean(PREF_CHLOG, TRUE); expect_cons_show("OTR message logging disabled."); gboolean result = cmd_otr_log(NULL, CMD_OTR, args); - char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); + char* pref_otr_log = prefs_get_string(PREF_OTR_LOG); assert_true(result); assert_string_equal("off", pref_otr_log); g_free(pref_otr_log); } -void cmd_otr_redact_redacts_logging(void **state) +void +cmd_otr_redact_redacts_logging(void** state) { - gchar *args[] = { "log", "redact", NULL }; + gchar* args[] = { "log", "redact", NULL }; prefs_set_string(PREF_OTR_LOG, "on"); prefs_set_boolean(PREF_CHLOG, TRUE); expect_cons_show("OTR messages will be logged as '[redacted]'."); gboolean result = cmd_otr_log(NULL, CMD_OTR, args); - char *pref_otr_log = prefs_get_string(PREF_OTR_LOG); + char* pref_otr_log = prefs_get_string(PREF_OTR_LOG); assert_true(result); assert_string_equal("redact", pref_otr_log); g_free(pref_otr_log); } -void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state) +void +cmd_otr_log_redact_shows_warning_when_chlog_disabled(void** state) { - gchar *args[] = { "log", "redact", NULL }; + gchar* args[] = { "log", "redact", NULL }; prefs_set_string(PREF_OTR_LOG, "off"); prefs_set_boolean(PREF_CHLOG, FALSE); @@ -120,11 +127,12 @@ void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state) assert_true(result); } -void cmd_otr_libver_shows_libotr_version(void **state) +void +cmd_otr_libver_shows_libotr_version(void** state) { - gchar *args[] = { "libver", NULL }; - char *version = "9.9.9"; - GString *message = g_string_new("Using libotr version "); + gchar* args[] = { "libver", NULL }; + char* version = "9.9.9"; + GString* message = g_string_new("Using libotr version "); g_string_append(message, version); will_return(otr_libotr_version, version); @@ -137,9 +145,10 @@ void cmd_otr_libver_shows_libotr_version(void **state) g_string_free(message, TRUE); } -void cmd_otr_gen_shows_message_when_not_connected(void **state) +void +cmd_otr_gen_shows_message_when_not_connected(void** state) { - gchar *args[] = { "gen", NULL }; + gchar* args[] = { "gen", NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -149,40 +158,45 @@ void cmd_otr_gen_shows_message_when_not_connected(void **state) assert_true(result); } -static void test_with_command_and_connection_status(char *command, void *cmd_func, jabber_conn_status_t status) +static void +test_with_command_and_connection_status(char* command, void* cmd_func, jabber_conn_status_t status) { - gchar *args[] = { command, NULL }; + gchar* args[] = { command, NULL }; will_return(connection_get_status, status); expect_cons_show("You must be connected with an account to load OTR information."); - gboolean (*func)(ProfWin *window, const char *const command, gchar **args) = cmd_func; + gboolean (*func)(ProfWin * window, const char* const command, gchar** args) = cmd_func; gboolean result = func(NULL, CMD_OTR, args); assert_true(result); } -void cmd_otr_gen_shows_message_when_disconnected(void **state) +void +cmd_otr_gen_shows_message_when_disconnected(void** state) { test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_DISCONNECTED); } -void cmd_otr_gen_shows_message_when_connecting(void **state) +void +cmd_otr_gen_shows_message_when_connecting(void** state) { test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_CONNECTING); } -void cmd_otr_gen_shows_message_when_disconnecting(void **state) +void +cmd_otr_gen_shows_message_when_disconnecting(void** state) { test_with_command_and_connection_status("gen", cmd_otr_gen, JABBER_DISCONNECTING); } -void cmd_otr_gen_generates_key_for_connected_account(void **state) +void +cmd_otr_gen_generates_key_for_connected_account(void** state) { - gchar *args[] = { "gen", NULL }; - char *account_name = "myaccount"; - ProfAccount *account = account_new(account_name, "me@jabber.org", NULL, NULL, - TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + gchar* args[] = { "gen", NULL }; + char* account_name = "myaccount"; + ProfAccount* account = account_new(account_name, "me@jabber.org", NULL, NULL, + TRUE, NULL, 0, NULL, NULL, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_CONNECTED); will_return(session_get_account_name, account_name); @@ -197,24 +211,28 @@ void cmd_otr_gen_generates_key_for_connected_account(void **state) assert_true(result); } -void cmd_otr_myfp_shows_message_when_disconnected(void **state) +void +cmd_otr_myfp_shows_message_when_disconnected(void** state) { test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_DISCONNECTED); } -void cmd_otr_myfp_shows_message_when_connecting(void **state) +void +cmd_otr_myfp_shows_message_when_connecting(void** state) { test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_CONNECTING); } -void cmd_otr_myfp_shows_message_when_disconnecting(void **state) +void +cmd_otr_myfp_shows_message_when_disconnecting(void** state) { test_with_command_and_connection_status("myfp", cmd_otr_myfp, JABBER_DISCONNECTING); } -void cmd_otr_myfp_shows_message_when_no_key(void **state) +void +cmd_otr_myfp_shows_message_when_no_key(void** state) { - gchar *args[] = { "myfp", NULL }; + gchar* args[] = { "myfp", NULL }; will_return(connection_get_status, JABBER_CONNECTED); will_return(otr_key_loaded, FALSE); @@ -225,11 +243,12 @@ void cmd_otr_myfp_shows_message_when_no_key(void **state) assert_true(result); } -void cmd_otr_myfp_shows_my_fingerprint(void **state) +void +cmd_otr_myfp_shows_my_fingerprint(void** state) { - char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; - gchar *args[] = { "myfp", NULL }; - GString *message = g_string_new("Your OTR fingerprint: "); + char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; + gchar* args[] = { "myfp", NULL }; + GString* message = g_string_new("Your OTR fingerprint: "); g_string_append(message, fingerprint); will_return(connection_get_status, JABBER_CONNECTED); @@ -247,7 +266,7 @@ void cmd_otr_myfp_shows_my_fingerprint(void **state) static void test_cmd_otr_theirfp_from_wintype(win_type_t wintype) { - gchar *args[] = { "theirfp", NULL }; + gchar* args[] = { "theirfp", NULL }; ProfWin window; window.type = wintype; window.layout = NULL; @@ -262,24 +281,28 @@ test_cmd_otr_theirfp_from_wintype(win_type_t wintype) assert_true(result); } -void cmd_otr_theirfp_shows_message_when_in_console(void **state) +void +cmd_otr_theirfp_shows_message_when_in_console(void** state) { test_cmd_otr_theirfp_from_wintype(WIN_CONSOLE); } -void cmd_otr_theirfp_shows_message_when_in_muc(void **state) +void +cmd_otr_theirfp_shows_message_when_in_muc(void** state) { test_cmd_otr_theirfp_from_wintype(WIN_MUC); } -void cmd_otr_theirfp_shows_message_when_in_private(void **state) +void +cmd_otr_theirfp_shows_message_when_in_private(void** state) { test_cmd_otr_theirfp_from_wintype(WIN_PRIVATE); } -void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state) +void +cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void** state) { - gchar *args[] = { "theirfp", NULL }; + gchar* args[] = { "theirfp", NULL }; ProfWin window; window.type = WIN_CHAT; @@ -300,12 +323,13 @@ void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state) assert_true(result); } -void cmd_otr_theirfp_shows_fingerprint(void **state) +void +cmd_otr_theirfp_shows_fingerprint(void** state) { - char *recipient = "someone@chat.com"; - char *fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; - gchar *args[] = { "theirfp", NULL }; - GString *message = g_string_new(recipient); + char* recipient = "someone@chat.com"; + char* fingerprint = "AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE"; + gchar* args[] = { "theirfp", NULL }; + GString* message = g_string_new(recipient); g_string_append(message, "'s OTR fingerprint: "); g_string_append(message, fingerprint); @@ -336,7 +360,7 @@ void cmd_otr_theirfp_shows_fingerprint(void **state) static void test_cmd_otr_start_from_wintype(win_type_t wintype) { - gchar *args[] = { "start", NULL }; + gchar* args[] = { "start", NULL }; ProfWin window; window.type = wintype; window.layout = NULL; @@ -350,25 +374,29 @@ test_cmd_otr_start_from_wintype(win_type_t wintype) assert_true(result); } -void cmd_otr_start_shows_message_when_in_console(void **state) +void +cmd_otr_start_shows_message_when_in_console(void** state) { test_cmd_otr_start_from_wintype(WIN_CONSOLE); } -void cmd_otr_start_shows_message_when_in_muc(void **state) +void +cmd_otr_start_shows_message_when_in_muc(void** state) { test_cmd_otr_start_from_wintype(WIN_MUC); } -void cmd_otr_start_shows_message_when_in_private(void **state) +void +cmd_otr_start_shows_message_when_in_private(void** state) { test_cmd_otr_start_from_wintype(WIN_PRIVATE); } -void cmd_otr_start_shows_message_when_already_started(void **state) +void +cmd_otr_start_shows_message_when_already_started(void** state) { - char *recipient = "someone@server.org"; - gchar *args[] = { "start", NULL }; + char* recipient = "someone@server.org"; + gchar* args[] = { "start", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -389,10 +417,11 @@ void cmd_otr_start_shows_message_when_already_started(void **state) assert_true(result); } -void cmd_otr_start_shows_message_when_no_key(void **state) +void +cmd_otr_start_shows_message_when_no_key(void** state) { - char *recipient = "someone@server.org"; - gchar *args[] = { "start", NULL }; + char* recipient = "someone@server.org"; + gchar* args[] = { "start", NULL }; will_return(connection_get_status, JABBER_CONNECTED); will_return(otr_key_loaded, FALSE); @@ -415,11 +444,11 @@ void cmd_otr_start_shows_message_when_no_key(void **state) } void -cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state) +cmd_otr_start_sends_otr_query_message_to_current_recipeint(void** state) { - char *recipient = "buddy@chat.com"; - char *query_message = "?OTR?"; - gchar *args[] = { "start", NULL }; + char* recipient = "buddy@chat.com"; + char* query_message = "?OTR?"; + gchar* args[] = { "start", NULL }; ProfWin window; window.type = WIN_CHAT; @@ -444,9 +473,10 @@ cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state) } #else -void cmd_otr_shows_message_when_otr_unsupported(void **state) +void +cmd_otr_shows_message_when_otr_unsupported(void** state) { - gchar *args[] = { "gen", NULL }; + gchar* args[] = { "gen", NULL }; expect_cons_show("This version of Profanity has not been built with OTR support enabled"); diff --git a/tests/unittests/test_cmd_otr.h b/tests/unittests/test_cmd_otr.h index 5343cc57..a9ffb1e1 100644 --- a/tests/unittests/test_cmd_otr.h +++ b/tests/unittests/test_cmd_otr.h @@ -1,37 +1,37 @@ #include "config.h" #ifdef HAVE_LIBOTR -void cmd_otr_log_shows_usage_when_no_args(void **state); -void cmd_otr_log_shows_usage_when_invalid_subcommand(void **state); -void cmd_otr_log_on_enables_logging(void **state); -void cmd_otr_log_off_disables_logging(void **state); -void cmd_otr_redact_redacts_logging(void **state); -void cmd_otr_log_on_shows_warning_when_chlog_disabled(void **state); -void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void **state); -void cmd_otr_libver_shows_libotr_version(void **state); -void cmd_otr_gen_shows_message_when_not_connected(void **state); -void cmd_otr_gen_generates_key_for_connected_account(void **state); -void cmd_otr_gen_shows_message_when_disconnected(void **state); -void cmd_otr_gen_shows_message_when_undefined(void **state); -void cmd_otr_gen_shows_message_when_connecting(void **state); -void cmd_otr_gen_shows_message_when_disconnecting(void **state); -void cmd_otr_myfp_shows_message_when_disconnected(void **state); -void cmd_otr_myfp_shows_message_when_undefined(void **state); -void cmd_otr_myfp_shows_message_when_connecting(void **state); -void cmd_otr_myfp_shows_message_when_disconnecting(void **state); -void cmd_otr_myfp_shows_message_when_no_key(void **state); -void cmd_otr_myfp_shows_my_fingerprint(void **state); -void cmd_otr_theirfp_shows_message_when_in_console(void **state); -void cmd_otr_theirfp_shows_message_when_in_muc(void **state); -void cmd_otr_theirfp_shows_message_when_in_private(void **state); -void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void **state); -void cmd_otr_theirfp_shows_fingerprint(void **state); -void cmd_otr_start_shows_message_when_in_console(void **state); -void cmd_otr_start_shows_message_when_in_muc(void **state); -void cmd_otr_start_shows_message_when_in_private(void **state); -void cmd_otr_start_shows_message_when_already_started(void **state); -void cmd_otr_start_shows_message_when_no_key(void **state); -void cmd_otr_start_sends_otr_query_message_to_current_recipeint(void **state); +void cmd_otr_log_shows_usage_when_no_args(void** state); +void cmd_otr_log_shows_usage_when_invalid_subcommand(void** state); +void cmd_otr_log_on_enables_logging(void** state); +void cmd_otr_log_off_disables_logging(void** state); +void cmd_otr_redact_redacts_logging(void** state); +void cmd_otr_log_on_shows_warning_when_chlog_disabled(void** state); +void cmd_otr_log_redact_shows_warning_when_chlog_disabled(void** state); +void cmd_otr_libver_shows_libotr_version(void** state); +void cmd_otr_gen_shows_message_when_not_connected(void** state); +void cmd_otr_gen_generates_key_for_connected_account(void** state); +void cmd_otr_gen_shows_message_when_disconnected(void** state); +void cmd_otr_gen_shows_message_when_undefined(void** state); +void cmd_otr_gen_shows_message_when_connecting(void** state); +void cmd_otr_gen_shows_message_when_disconnecting(void** state); +void cmd_otr_myfp_shows_message_when_disconnected(void** state); +void cmd_otr_myfp_shows_message_when_undefined(void** state); +void cmd_otr_myfp_shows_message_when_connecting(void** state); +void cmd_otr_myfp_shows_message_when_disconnecting(void** state); +void cmd_otr_myfp_shows_message_when_no_key(void** state); +void cmd_otr_myfp_shows_my_fingerprint(void** state); +void cmd_otr_theirfp_shows_message_when_in_console(void** state); +void cmd_otr_theirfp_shows_message_when_in_muc(void** state); +void cmd_otr_theirfp_shows_message_when_in_private(void** state); +void cmd_otr_theirfp_shows_message_when_non_otr_chat_window(void** state); +void cmd_otr_theirfp_shows_fingerprint(void** state); +void cmd_otr_start_shows_message_when_in_console(void** state); +void cmd_otr_start_shows_message_when_in_muc(void** state); +void cmd_otr_start_shows_message_when_in_private(void** state); +void cmd_otr_start_shows_message_when_already_started(void** state); +void cmd_otr_start_shows_message_when_no_key(void** state); +void cmd_otr_start_sends_otr_query_message_to_current_recipeint(void** state); #else -void cmd_otr_shows_message_when_otr_unsupported(void **state); +void cmd_otr_shows_message_when_otr_unsupported(void** state); #endif diff --git a/tests/unittests/test_cmd_pgp.c b/tests/unittests/test_cmd_pgp.c index 0754773a..55130dac 100644 --- a/tests/unittests/test_cmd_pgp.c +++ b/tests/unittests/test_cmd_pgp.c @@ -16,9 +16,10 @@ #define CMD_PGP "/pgp" #ifdef HAVE_LIBGPGME -void cmd_pgp_shows_usage_when_no_args(void **state) +void +cmd_pgp_shows_usage_when_no_args(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_PGP); @@ -26,9 +27,10 @@ void cmd_pgp_shows_usage_when_no_args(void **state) assert_true(result); } -void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status) +void +cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_status) { - gchar *args[] = { "start", NULL }; + gchar* args[] = { "start", NULL }; ProfWin window; window.type = WIN_CHAT; @@ -40,24 +42,28 @@ void cmd_pgp_start_shows_message_when_connection(jabber_conn_status_t conn_statu assert_true(result); } -void cmd_pgp_start_shows_message_when_disconnected(void **state) +void +cmd_pgp_start_shows_message_when_disconnected(void** state) { cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTED); } -void cmd_pgp_start_shows_message_when_disconnecting(void **state) +void +cmd_pgp_start_shows_message_when_disconnecting(void** state) { cmd_pgp_start_shows_message_when_connection(JABBER_DISCONNECTING); } -void cmd_pgp_start_shows_message_when_connecting(void **state) +void +cmd_pgp_start_shows_message_when_connecting(void** state) { cmd_pgp_start_shows_message_when_connection(JABBER_CONNECTING); } -void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype) +void +cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype) { - gchar *args[] = { "start", NULL }; + gchar* args[] = { "start", NULL }; ProfWin window; window.type = wintype; @@ -69,35 +75,41 @@ void cmd_pgp_start_shows_message_when_no_arg_in_wintype(win_type_t wintype) assert_true(result); } -void cmd_pgp_start_shows_message_when_no_arg_in_console(void **state) +void +cmd_pgp_start_shows_message_when_no_arg_in_console(void** state) { cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONSOLE); } -void cmd_pgp_start_shows_message_when_no_arg_in_muc(void **state) +void +cmd_pgp_start_shows_message_when_no_arg_in_muc(void** state) { cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_MUC); } -void cmd_pgp_start_shows_message_when_no_arg_in_conf(void **state) +void +cmd_pgp_start_shows_message_when_no_arg_in_conf(void** state) { cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_CONFIG); } -void cmd_pgp_start_shows_message_when_no_arg_in_private(void **state) +void +cmd_pgp_start_shows_message_when_no_arg_in_private(void** state) { cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_PRIVATE); } -void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void **state) +void +cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void** state) { cmd_pgp_start_shows_message_when_no_arg_in_wintype(WIN_XML); } #else -void cmd_pgp_shows_message_when_pgp_unsupported(void **state) +void +cmd_pgp_shows_message_when_pgp_unsupported(void** state) { - gchar *args[] = { "gen", NULL }; + gchar* args[] = { "gen", NULL }; expect_cons_show("This version of Profanity has not been built with PGP support enabled"); diff --git a/tests/unittests/test_cmd_pgp.h b/tests/unittests/test_cmd_pgp.h index d6082ecb..60110beb 100644 --- a/tests/unittests/test_cmd_pgp.h +++ b/tests/unittests/test_cmd_pgp.h @@ -1,16 +1,16 @@ #include "config.h" #ifdef HAVE_LIBGPGME -void cmd_pgp_shows_usage_when_no_args(void **state); -void cmd_pgp_start_shows_message_when_disconnected(void **state); -void cmd_pgp_start_shows_message_when_disconnecting(void **state); -void cmd_pgp_start_shows_message_when_connecting(void **state); -void cmd_pgp_start_shows_message_when_undefined(void **state); -void cmd_pgp_start_shows_message_when_no_arg_in_console(void **state); -void cmd_pgp_start_shows_message_when_no_arg_in_muc(void **state); -void cmd_pgp_start_shows_message_when_no_arg_in_conf(void **state); -void cmd_pgp_start_shows_message_when_no_arg_in_private(void **state); -void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void **state); +void cmd_pgp_shows_usage_when_no_args(void** state); +void cmd_pgp_start_shows_message_when_disconnected(void** state); +void cmd_pgp_start_shows_message_when_disconnecting(void** state); +void cmd_pgp_start_shows_message_when_connecting(void** state); +void cmd_pgp_start_shows_message_when_undefined(void** state); +void cmd_pgp_start_shows_message_when_no_arg_in_console(void** state); +void cmd_pgp_start_shows_message_when_no_arg_in_muc(void** state); +void cmd_pgp_start_shows_message_when_no_arg_in_conf(void** state); +void cmd_pgp_start_shows_message_when_no_arg_in_private(void** state); +void cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole(void** state); #else -void cmd_pgp_shows_message_when_pgp_unsupported(void **state); +void cmd_pgp_shows_message_when_pgp_unsupported(void** state); #endif diff --git a/tests/unittests/test_cmd_presence.c b/tests/unittests/test_cmd_presence.c index d4bc8904..0c4e1ffa 100644 --- a/tests/unittests/test_cmd_presence.c +++ b/tests/unittests/test_cmd_presence.c @@ -15,9 +15,10 @@ #define CMD_PRESENCE "/presence" -void cmd_presence_shows_usage_when_bad_subcmd(void **state) +void +cmd_presence_shows_usage_when_bad_subcmd(void** state) { - gchar *args[] = { "badcmd", NULL }; + gchar* args[] = { "badcmd", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); @@ -25,9 +26,10 @@ void cmd_presence_shows_usage_when_bad_subcmd(void **state) assert_true(result); } -void cmd_presence_shows_usage_when_bad_console_setting(void **state) +void +cmd_presence_shows_usage_when_bad_console_setting(void** state) { - gchar *args[] = { "console", "badsetting", NULL }; + gchar* args[] = { "console", "badsetting", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); @@ -35,9 +37,10 @@ void cmd_presence_shows_usage_when_bad_console_setting(void **state) assert_true(result); } -void cmd_presence_shows_usage_when_bad_chat_setting(void **state) +void +cmd_presence_shows_usage_when_bad_chat_setting(void** state) { - gchar *args[] = { "chat", "badsetting", NULL }; + gchar* args[] = { "chat", "badsetting", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); @@ -45,9 +48,10 @@ void cmd_presence_shows_usage_when_bad_chat_setting(void **state) assert_true(result); } -void cmd_presence_shows_usage_when_bad_muc_setting(void **state) +void +cmd_presence_shows_usage_when_bad_muc_setting(void** state) { - gchar *args[] = { "muc", "badsetting", NULL }; + gchar* args[] = { "muc", "badsetting", NULL }; expect_string(cons_bad_cmd_usage, cmd, CMD_PRESENCE); @@ -55,135 +59,144 @@ void cmd_presence_shows_usage_when_bad_muc_setting(void **state) assert_true(result); } -void cmd_presence_console_sets_all(void **state) +void +cmd_presence_console_sets_all(void** state) { - gchar *args[] = { "console", "all", NULL }; + gchar* args[] = { "console", "all", NULL }; expect_cons_show("All presence updates will appear in the console."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + char* setting = prefs_get_string(PREF_STATUSES_CONSOLE); assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); g_free(setting); } -void cmd_presence_console_sets_online(void **state) +void +cmd_presence_console_sets_online(void** state) { - gchar *args[] = { "console", "online", NULL }; + gchar* args[] = { "console", "online", NULL }; expect_cons_show("Only online/offline presence updates will appear in the console."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + char* setting = prefs_get_string(PREF_STATUSES_CONSOLE); assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); g_free(setting); } -void cmd_presence_console_sets_none(void **state) +void +cmd_presence_console_sets_none(void** state) { - gchar *args[] = { "console", "none", NULL }; + gchar* args[] = { "console", "none", NULL }; expect_cons_show("Presence updates will not appear in the console."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + char* setting = prefs_get_string(PREF_STATUSES_CONSOLE); assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); g_free(setting); } -void cmd_presence_chat_sets_all(void **state) +void +cmd_presence_chat_sets_all(void** state) { - gchar *args[] = { "chat", "all", NULL }; + gchar* args[] = { "chat", "all", NULL }; expect_cons_show("All presence updates will appear in chat windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CHAT); + char* setting = prefs_get_string(PREF_STATUSES_CHAT); assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); g_free(setting); } -void cmd_presence_chat_sets_online(void **state) +void +cmd_presence_chat_sets_online(void** state) { - gchar *args[] = { "chat", "online", NULL }; + gchar* args[] = { "chat", "online", NULL }; expect_cons_show("Only online/offline presence updates will appear in chat windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CHAT); + char* setting = prefs_get_string(PREF_STATUSES_CHAT); assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); g_free(setting); } -void cmd_presence_chat_sets_none(void **state) +void +cmd_presence_chat_sets_none(void** state) { - gchar *args[] = { "chat", "none", NULL }; + gchar* args[] = { "chat", "none", NULL }; expect_cons_show("Presence updates will not appear in chat windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_CHAT); + char* setting = prefs_get_string(PREF_STATUSES_CHAT); assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); g_free(setting); } -void cmd_presence_room_sets_all(void **state) +void +cmd_presence_room_sets_all(void** state) { - gchar *args[] = { "room", "all", NULL }; + gchar* args[] = { "room", "all", NULL }; expect_cons_show("All presence updates will appear in chat room windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_MUC); + char* setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("all", setting); assert_true(result); g_free(setting); } -void cmd_presence_room_sets_online(void **state) +void +cmd_presence_room_sets_online(void** state) { - gchar *args[] = { "room", "online", NULL }; + gchar* args[] = { "room", "online", NULL }; expect_cons_show("Only join/leave presence updates will appear in chat room windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_MUC); + char* setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("online", setting); assert_true(result); g_free(setting); } -void cmd_presence_room_sets_none(void **state) +void +cmd_presence_room_sets_none(void** state) { - gchar *args[] = { "room", "none", NULL }; + gchar* args[] = { "room", "none", NULL }; expect_cons_show("Presence updates will not appear in chat room windows."); gboolean result = cmd_presence(NULL, CMD_PRESENCE, args); - char *setting = prefs_get_string(PREF_STATUSES_MUC); + char* setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("none", setting); assert_true(result); diff --git a/tests/unittests/test_cmd_presence.h b/tests/unittests/test_cmd_presence.h index 620921ae..96668db2 100644 --- a/tests/unittests/test_cmd_presence.h +++ b/tests/unittests/test_cmd_presence.h @@ -1,13 +1,13 @@ -void cmd_presence_shows_usage_when_bad_subcmd(void **state); -void cmd_presence_shows_usage_when_bad_console_setting(void **state); -void cmd_presence_shows_usage_when_bad_chat_setting(void **state); -void cmd_presence_shows_usage_when_bad_muc_setting(void **state); -void cmd_presence_console_sets_all(void **state); -void cmd_presence_console_sets_online(void **state); -void cmd_presence_console_sets_none(void **state); -void cmd_presence_chat_sets_all(void **state); -void cmd_presence_chat_sets_online(void **state); -void cmd_presence_chat_sets_none(void **state); -void cmd_presence_room_sets_all(void **state); -void cmd_presence_room_sets_online(void **state); -void cmd_presence_room_sets_none(void **state); +void cmd_presence_shows_usage_when_bad_subcmd(void** state); +void cmd_presence_shows_usage_when_bad_console_setting(void** state); +void cmd_presence_shows_usage_when_bad_chat_setting(void** state); +void cmd_presence_shows_usage_when_bad_muc_setting(void** state); +void cmd_presence_console_sets_all(void** state); +void cmd_presence_console_sets_online(void** state); +void cmd_presence_console_sets_none(void** state); +void cmd_presence_chat_sets_all(void** state); +void cmd_presence_chat_sets_online(void** state); +void cmd_presence_chat_sets_none(void** state); +void cmd_presence_room_sets_all(void** state); +void cmd_presence_room_sets_online(void** state); +void cmd_presence_room_sets_none(void** state); diff --git a/tests/unittests/test_cmd_rooms.c b/tests/unittests/test_cmd_rooms.c index 96e29602..8cdc27b2 100644 --- a/tests/unittests/test_cmd_rooms.c +++ b/tests/unittests/test_cmd_rooms.c @@ -16,7 +16,8 @@ #define CMD_ROOMS "/rooms" -static void test_with_connection_status(jabber_conn_status_t status) +static void +test_with_connection_status(jabber_conn_status_t status) { will_return(connection_get_status, status); @@ -26,27 +27,31 @@ static void test_with_connection_status(jabber_conn_status_t status) assert_true(result); } -void cmd_rooms_shows_message_when_disconnected(void **state) +void +cmd_rooms_shows_message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } -void cmd_rooms_shows_message_when_disconnecting(void **state) +void +cmd_rooms_shows_message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } -void cmd_rooms_shows_message_when_connecting(void **state) +void +cmd_rooms_shows_message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } -void cmd_rooms_uses_account_default_when_no_arg(void **state) +void +cmd_rooms_uses_account_default_when_no_arg(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; - ProfAccount *account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, - 0, 0, 0, 0, 0, "default_conf_server", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ProfAccount* account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, + 0, 0, 0, 0, 0, "default_conf_server", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_CONNECTED); will_return(session_get_account_name, "account_name"); @@ -63,9 +68,10 @@ void cmd_rooms_uses_account_default_when_no_arg(void **state) assert_true(result); } -void cmd_rooms_service_arg_used_when_passed(void **state) +void +cmd_rooms_service_arg_used_when_passed(void** state) { - gchar *args[] = { "service", "conf_server_arg", NULL }; + gchar* args[] = { "service", "conf_server_arg", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -79,13 +85,13 @@ void cmd_rooms_service_arg_used_when_passed(void **state) assert_true(result); } -void cmd_rooms_filter_arg_used_when_passed(void **state) +void +cmd_rooms_filter_arg_used_when_passed(void** state) { - gchar *args[] = { "filter", "text", NULL }; + gchar* args[] = { "filter", "text", NULL }; - - ProfAccount *account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, - 0, 0, 0, 0, 0, "default_conf_server", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ProfAccount* account = account_new("testaccount", NULL, NULL, NULL, TRUE, NULL, 0, NULL, NULL, NULL, + 0, 0, 0, 0, 0, "default_conf_server", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); will_return(connection_get_status, JABBER_CONNECTED); will_return(session_get_account_name, "account_name"); diff --git a/tests/unittests/test_cmd_rooms.h b/tests/unittests/test_cmd_rooms.h index 4d656948..d1107d78 100644 --- a/tests/unittests/test_cmd_rooms.h +++ b/tests/unittests/test_cmd_rooms.h @@ -1,7 +1,7 @@ -void cmd_rooms_shows_message_when_disconnected(void **state); -void cmd_rooms_shows_message_when_disconnecting(void **state); -void cmd_rooms_shows_message_when_connecting(void **state); -void cmd_rooms_shows_message_when_undefined(void **state); -void cmd_rooms_uses_account_default_when_no_arg(void **state); -void cmd_rooms_service_arg_used_when_passed(void **state); -void cmd_rooms_filter_arg_used_when_passed(void **state); +void cmd_rooms_shows_message_when_disconnected(void** state); +void cmd_rooms_shows_message_when_disconnecting(void** state); +void cmd_rooms_shows_message_when_connecting(void** state); +void cmd_rooms_shows_message_when_undefined(void** state); +void cmd_rooms_uses_account_default_when_no_arg(void** state); +void cmd_rooms_service_arg_used_when_passed(void** state); +void cmd_rooms_filter_arg_used_when_passed(void** state); diff --git a/tests/unittests/test_cmd_roster.c b/tests/unittests/test_cmd_roster.c index 845fa67f..3908ba58 100644 --- a/tests/unittests/test_cmd_roster.c +++ b/tests/unittests/test_cmd_roster.c @@ -15,9 +15,10 @@ #define CMD_ROSTER "/roster" -static void test_with_connection_status(jabber_conn_status_t status) +static void +test_with_connection_status(jabber_conn_status_t status) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; will_return(connection_get_status, status); @@ -27,30 +28,34 @@ static void test_with_connection_status(jabber_conn_status_t status) assert_true(result); } -void cmd_roster_shows_message_when_disconnecting(void **state) +void +cmd_roster_shows_message_when_disconnecting(void** state) { test_with_connection_status(JABBER_DISCONNECTING); } -void cmd_roster_shows_message_when_connecting(void **state) +void +cmd_roster_shows_message_when_connecting(void** state) { test_with_connection_status(JABBER_CONNECTING); } -void cmd_roster_shows_message_when_disconnected(void **state) +void +cmd_roster_shows_message_when_disconnected(void** state) { test_with_connection_status(JABBER_DISCONNECTED); } -void cmd_roster_shows_roster_when_no_args(void **state) +void +cmd_roster_shows_roster_when_no_args(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; will_return(connection_get_status, JABBER_CONNECTED); roster_create(); roster_add("bob@server.org", "bob", NULL, "both", FALSE); - GSList *roster = roster_get_contacts(ROSTER_ORD_NAME); + GSList* roster = roster_get_contacts(ROSTER_ORD_NAME); expect_memory(cons_show_roster, list, roster, sizeof(roster)); @@ -61,9 +66,10 @@ void cmd_roster_shows_roster_when_no_args(void **state) roster_destroy(); } -void cmd_roster_add_shows_message_when_no_jid(void **state) +void +cmd_roster_add_shows_message_when_no_jid(void** state) { - gchar *args[] = { "add", NULL }; + gchar* args[] = { "add", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -73,11 +79,12 @@ void cmd_roster_add_shows_message_when_no_jid(void **state) assert_true(result); } -void cmd_roster_add_sends_roster_add_request(void **state) +void +cmd_roster_add_sends_roster_add_request(void** state) { - char *jid = "bob@server.org"; - char *nick = "bob"; - gchar *args[] = { "add", jid, nick, NULL }; + char* jid = "bob@server.org"; + char* nick = "bob"; + gchar* args[] = { "add", jid, nick, NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -88,9 +95,10 @@ void cmd_roster_add_sends_roster_add_request(void **state) assert_true(result); } -void cmd_roster_remove_shows_message_when_no_jid(void **state) +void +cmd_roster_remove_shows_message_when_no_jid(void** state) { - gchar *args[] = { "remove", NULL }; + gchar* args[] = { "remove", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -100,10 +108,11 @@ void cmd_roster_remove_shows_message_when_no_jid(void **state) assert_true(result); } -void cmd_roster_remove_sends_roster_remove_request(void **state) +void +cmd_roster_remove_sends_roster_remove_request(void** state) { - char *jid = "bob@server.org"; - gchar *args[] = { "remove", jid, NULL }; + char* jid = "bob@server.org"; + gchar* args[] = { "remove", jid, NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -113,9 +122,10 @@ void cmd_roster_remove_sends_roster_remove_request(void **state) assert_true(result); } -void cmd_roster_nick_shows_message_when_no_jid(void **state) +void +cmd_roster_nick_shows_message_when_no_jid(void** state) { - gchar *args[] = { "nick", NULL }; + gchar* args[] = { "nick", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -125,9 +135,10 @@ void cmd_roster_nick_shows_message_when_no_jid(void **state) assert_true(result); } -void cmd_roster_nick_shows_message_when_no_nick(void **state) +void +cmd_roster_nick_shows_message_when_no_nick(void** state) { - gchar *args[] = { "nick", "bob@server.org", NULL }; + gchar* args[] = { "nick", "bob@server.org", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -137,9 +148,10 @@ void cmd_roster_nick_shows_message_when_no_nick(void **state) assert_true(result); } -void cmd_roster_nick_shows_message_when_no_contact_exists(void **state) +void +cmd_roster_nick_shows_message_when_no_contact_exists(void** state) { - gchar *args[] = { "nick", "bob@server.org", "bobster", NULL }; + gchar* args[] = { "nick", "bob@server.org", "bobster", NULL }; roster_create(); @@ -153,14 +165,15 @@ void cmd_roster_nick_shows_message_when_no_contact_exists(void **state) roster_destroy(); } -void cmd_roster_nick_sends_name_change_request(void **state) +void +cmd_roster_nick_sends_name_change_request(void** state) { - char *jid = "bob@server.org"; - char *nick = "bobster"; - gchar *args[] = { "nick", jid, nick, NULL }; + char* jid = "bob@server.org"; + char* nick = "bobster"; + gchar* args[] = { "nick", jid, nick, NULL }; roster_create(); - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("group1")); roster_add(jid, "bob", groups, "both", FALSE); @@ -181,9 +194,10 @@ void cmd_roster_nick_sends_name_change_request(void **state) roster_destroy(); } -void cmd_roster_clearnick_shows_message_when_no_jid(void **state) +void +cmd_roster_clearnick_shows_message_when_no_jid(void** state) { - gchar *args[] = { "clearnick", NULL }; + gchar* args[] = { "clearnick", NULL }; will_return(connection_get_status, JABBER_CONNECTED); @@ -193,9 +207,10 @@ void cmd_roster_clearnick_shows_message_when_no_jid(void **state) assert_true(result); } -void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state) +void +cmd_roster_clearnick_shows_message_when_no_contact_exists(void** state) { - gchar *args[] = { "clearnick", "bob@server.org", NULL }; + gchar* args[] = { "clearnick", "bob@server.org", NULL }; roster_create(); @@ -209,13 +224,14 @@ void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state) roster_destroy(); } -void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state) +void +cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void** state) { - char *jid = "bob@server.org"; - gchar *args[] = { "clearnick", jid, NULL }; + char* jid = "bob@server.org"; + gchar* args[] = { "clearnick", jid, NULL }; roster_create(); - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("group1")); roster_add(jid, "bob", groups, "both", FALSE); diff --git a/tests/unittests/test_cmd_roster.h b/tests/unittests/test_cmd_roster.h index 79f69ec8..49bd8db3 100644 --- a/tests/unittests/test_cmd_roster.h +++ b/tests/unittests/test_cmd_roster.h @@ -1,16 +1,16 @@ -void cmd_roster_shows_message_when_disconnecting(void **state); -void cmd_roster_shows_message_when_connecting(void **state); -void cmd_roster_shows_message_when_disconnected(void **state); -void cmd_roster_shows_message_when_undefined(void **state); -void cmd_roster_shows_roster_when_no_args(void **state); -void cmd_roster_add_shows_message_when_no_jid(void **state); -void cmd_roster_add_sends_roster_add_request(void **state); -void cmd_roster_remove_shows_message_when_no_jid(void **state); -void cmd_roster_remove_sends_roster_remove_request(void **state); -void cmd_roster_nick_shows_message_when_no_jid(void **state); -void cmd_roster_nick_shows_message_when_no_nick(void **state); -void cmd_roster_nick_shows_message_when_no_contact_exists(void **state); -void cmd_roster_nick_sends_name_change_request(void **state); -void cmd_roster_clearnick_shows_message_when_no_jid(void **state); -void cmd_roster_clearnick_shows_message_when_no_contact_exists(void **state); -void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void **state); +void cmd_roster_shows_message_when_disconnecting(void** state); +void cmd_roster_shows_message_when_connecting(void** state); +void cmd_roster_shows_message_when_disconnected(void** state); +void cmd_roster_shows_message_when_undefined(void** state); +void cmd_roster_shows_roster_when_no_args(void** state); +void cmd_roster_add_shows_message_when_no_jid(void** state); +void cmd_roster_add_sends_roster_add_request(void** state); +void cmd_roster_remove_shows_message_when_no_jid(void** state); +void cmd_roster_remove_sends_roster_remove_request(void** state); +void cmd_roster_nick_shows_message_when_no_jid(void** state); +void cmd_roster_nick_shows_message_when_no_nick(void** state); +void cmd_roster_nick_shows_message_when_no_contact_exists(void** state); +void cmd_roster_nick_sends_name_change_request(void** state); +void cmd_roster_clearnick_shows_message_when_no_jid(void** state); +void cmd_roster_clearnick_shows_message_when_no_contact_exists(void** state); +void cmd_roster_clearnick_sends_name_change_request_with_empty_nick(void** state); diff --git a/tests/unittests/test_cmd_sub.c b/tests/unittests/test_cmd_sub.c index 4afe8752..d03f6b5c 100644 --- a/tests/unittests/test_cmd_sub.c +++ b/tests/unittests/test_cmd_sub.c @@ -15,9 +15,10 @@ #define CMD_SUB "/sub" -void cmd_sub_shows_message_when_not_connected(void **state) +void +cmd_sub_shows_message_when_not_connected(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; will_return(connection_get_status, JABBER_DISCONNECTED); @@ -27,9 +28,10 @@ void cmd_sub_shows_message_when_not_connected(void **state) assert_true(result); } -void cmd_sub_shows_usage_when_no_arg(void **state) +void +cmd_sub_shows_usage_when_no_arg(void** state) { - gchar *args[] = { NULL }; + gchar* args[] = { NULL }; will_return(connection_get_status, JABBER_CONNECTED); diff --git a/tests/unittests/test_cmd_sub.h b/tests/unittests/test_cmd_sub.h index 6e8addd3..6cebf649 100644 --- a/tests/unittests/test_cmd_sub.h +++ b/tests/unittests/test_cmd_sub.h @@ -1,2 +1,2 @@ -void cmd_sub_shows_message_when_not_connected(void **state); -void cmd_sub_shows_usage_when_no_arg(void **state); +void cmd_sub_shows_message_when_not_connected(void** state); +void cmd_sub_shows_usage_when_no_arg(void** state); diff --git a/tests/unittests/test_common.c b/tests/unittests/test_common.c index b6ae4bb9..b8958dda 100644 --- a/tests/unittests/test_common.c +++ b/tests/unittests/test_common.c @@ -6,293 +6,324 @@ #include <cmocka.h> #include <stdlib.h> -void replace_one_substr(void **state) +void +replace_one_substr(void** state) { - char *string = "it is a string"; - char *sub = "is"; - char *new = "was"; + char* string = "it is a string"; + char* sub = "is"; + char* new = "was"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("it was a string", result); free(result); } -void replace_one_substr_beginning(void **state) +void +replace_one_substr_beginning(void** state) { - char *string = "it is a string"; - char *sub = "it"; - char *new = "that"; + char* string = "it is a string"; + char* sub = "it"; + char* new = "that"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("that is a string", result); free(result); } -void replace_one_substr_end(void **state) +void +replace_one_substr_end(void** state) { - char *string = "it is a string"; - char *sub = "string"; - char *new = "thing"; + char* string = "it is a string"; + char* sub = "string"; + char* new = "thing"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("it is a thing", result); free(result); } -void replace_two_substr(void **state) +void +replace_two_substr(void** state) { - char *string = "it is a is string"; - char *sub = "is"; - char *new = "was"; + char* string = "it is a is string"; + char* sub = "is"; + char* new = "was"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("it was a was string", result); free(result); } -void replace_char(void **state) +void +replace_char(void** state) { - char *string = "some & a thing & something else"; - char *sub = "&"; - char *new = "&"; + char* string = "some & a thing & something else"; + char* sub = "&"; + char* new = "&"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("some & a thing & something else", result); free(result); } -void replace_when_none(void **state) +void +replace_when_none(void** state) { - char *string = "its another string"; - char *sub = "haha"; - char *new = "replaced"; + char* string = "its another string"; + char* sub = "haha"; + char* new = "replaced"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("its another string", result); free(result); } -void replace_when_match(void **state) +void +replace_when_match(void** state) { - char *string = "hello"; - char *sub = "hello"; - char *new = "goodbye"; + char* string = "hello"; + char* sub = "hello"; + char* new = "goodbye"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("goodbye", result); free(result); } -void replace_when_string_empty(void **state) +void +replace_when_string_empty(void** state) { - char *string = ""; - char *sub = "hello"; - char *new = "goodbye"; + char* string = ""; + char* sub = "hello"; + char* new = "goodbye"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("", result); free(result); } -void replace_when_string_null(void **state) +void +replace_when_string_null(void** state) { - char *string = NULL; - char *sub = "hello"; - char *new = "goodbye"; + char* string = NULL; + char* sub = "hello"; + char* new = "goodbye"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_null(result); } -void replace_when_sub_empty(void **state) +void +replace_when_sub_empty(void** state) { - char *string = "hello"; - char *sub = ""; - char *new = "goodbye"; + char* string = "hello"; + char* sub = ""; + char* new = "goodbye"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("hello", result); free(result); } -void replace_when_sub_null(void **state) +void +replace_when_sub_null(void** state) { - char *string = "hello"; - char *sub = NULL; - char *new = "goodbye"; + char* string = "hello"; + char* sub = NULL; + char* new = "goodbye"; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("hello", result); free(result); } -void replace_when_new_empty(void **state) +void +replace_when_new_empty(void** state) { - char *string = "hello"; - char *sub = "hello"; - char *new = ""; + char* string = "hello"; + char* sub = "hello"; + char* new = ""; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("", result); free(result); } -void replace_when_new_null(void **state) +void +replace_when_new_null(void** state) { - char *string = "hello"; - char *sub = "hello"; - char *new = NULL; + char* string = "hello"; + char* sub = "hello"; + char* new = NULL; - char *result = str_replace(string, sub, new); + char* result = str_replace(string, sub, new); assert_string_equal("hello", result); free(result); } -void test_online_is_valid_resource_presence_string(void **state) +void +test_online_is_valid_resource_presence_string(void** state) { assert_true(valid_resource_presence_string("online")); } -void test_chat_is_valid_resource_presence_string(void **state) +void +test_chat_is_valid_resource_presence_string(void** state) { assert_true(valid_resource_presence_string("chat")); } -void test_away_is_valid_resource_presence_string(void **state) +void +test_away_is_valid_resource_presence_string(void** state) { assert_true(valid_resource_presence_string("away")); } -void test_xa_is_valid_resource_presence_string(void **state) +void +test_xa_is_valid_resource_presence_string(void** state) { assert_true(valid_resource_presence_string("xa")); } -void test_dnd_is_valid_resource_presence_string(void **state) +void +test_dnd_is_valid_resource_presence_string(void** state) { assert_true(valid_resource_presence_string("dnd")); } -void test_available_is_not_valid_resource_presence_string(void **state) +void +test_available_is_not_valid_resource_presence_string(void** state) { assert_false(valid_resource_presence_string("available")); } -void test_unavailable_is_not_valid_resource_presence_string(void **state) +void +test_unavailable_is_not_valid_resource_presence_string(void** state) { assert_false(valid_resource_presence_string("unavailable")); } -void test_blah_is_not_valid_resource_presence_string(void **state) +void +test_blah_is_not_valid_resource_presence_string(void** state) { assert_false(valid_resource_presence_string("blah")); } -void utf8_display_len_null_str(void **state) +void +utf8_display_len_null_str(void** state) { int result = utf8_display_len(NULL); assert_int_equal(0, result); } -void utf8_display_len_1_non_wide(void **state) +void +utf8_display_len_1_non_wide(void** state) { int result = utf8_display_len("1"); assert_int_equal(1, result); } -void utf8_display_len_1_wide(void **state) +void +utf8_display_len_1_wide(void** state) { int result = utf8_display_len("四"); assert_int_equal(2, result); } -void utf8_display_len_non_wide(void **state) +void +utf8_display_len_non_wide(void** state) { int result = utf8_display_len("123456789abcdef"); assert_int_equal(15, result); } -void utf8_display_len_wide(void **state) +void +utf8_display_len_wide(void** state) { int result = utf8_display_len("12三四56"); assert_int_equal(8, result); } -void utf8_display_len_all_wide(void **state) +void +utf8_display_len_all_wide(void** state) { int result = utf8_display_len("ひらがな"); assert_int_equal(8, result); } -void strip_quotes_does_nothing_when_no_quoted(void **state) +void +strip_quotes_does_nothing_when_no_quoted(void** state) { - char *input = "/cmd test string"; + char* input = "/cmd test string"; - char *result = strip_arg_quotes(input); + char* result = strip_arg_quotes(input); assert_string_equal("/cmd test string", result); free(result); } -void strip_quotes_strips_first(void **state) +void +strip_quotes_strips_first(void** state) { - char *input = "/cmd \"test string"; + char* input = "/cmd \"test string"; - char *result = strip_arg_quotes(input); + char* result = strip_arg_quotes(input); assert_string_equal("/cmd test string", result); free(result); } -void strip_quotes_strips_last(void **state) +void +strip_quotes_strips_last(void** state) { - char *input = "/cmd test string\""; + char* input = "/cmd test string\""; - char *result = strip_arg_quotes(input); + char* result = strip_arg_quotes(input); assert_string_equal("/cmd test string", result); free(result); } -void strip_quotes_strips_both(void **state) +void +strip_quotes_strips_both(void** state) { - char *input = "/cmd \"test string\""; + char* input = "/cmd \"test string\""; - char *result = strip_arg_quotes(input); + char* result = strip_arg_quotes(input); assert_string_equal("/cmd test string", result); @@ -300,14 +331,14 @@ void strip_quotes_strips_both(void **state) } gboolean -_lists_equal(GSList *a, GSList *b) +_lists_equal(GSList* a, GSList* b) { if (g_slist_length(a) != g_slist_length(b)) { return FALSE; } - GSList *curra = a; - GSList *currb = b; + GSList* curra = a; + GSList* currb = b; while (curra) { int aval = GPOINTER_TO_INT(curra->data); @@ -324,145 +355,297 @@ _lists_equal(GSList *a, GSList *b) return TRUE; } -void prof_partial_occurrences_tests(void **state) +void +prof_partial_occurrences_tests(void** state) { - GSList *actual = NULL; - GSList *expected = NULL; + GSList* actual = NULL; + GSList* expected = NULL; assert_true(_lists_equal(prof_occurrences(NULL, NULL, 0, FALSE, &actual), expected)); - g_slist_free(actual); actual = NULL; - - assert_true(_lists_equal(prof_occurrences(NULL, "some string", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", NULL, 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences(NULL, NULL, 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "Boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("Boothj5", "boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; + g_slist_free(actual); + actual = NULL; + + assert_true(_lists_equal(prof_occurrences(NULL, "some string", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", NULL, 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences(NULL, NULL, 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "Boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("Boothj5", "boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5hello", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hello", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5hello", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hello", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(5)); - assert_true(_lists_equal(prof_occurrences("boothj5", "helloboothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "helloboothj5hello", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "helloboothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "helloboothj5hello", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 hello", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 hello", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(7)); - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(12)); - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5helloboothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5helloboothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); expected = g_slist_append(expected, GINT_TO_POINTER(14)); - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hello boothj5", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hello boothj5", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(2)); expected = g_slist_append(expected, GINT_TO_POINTER(16)); expected = g_slist_append(expected, GINT_TO_POINTER(29)); - assert_true(_lists_equal(prof_occurrences("boothj5", "hiboothj5 hello boothj5there boothj5s", 0, FALSE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hiboothj5 hello boothj5there boothj5s", 0, FALSE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; } -void prof_whole_occurrences_tests(void **state) +void +prof_whole_occurrences_tests(void** state) { - GSList *actual = NULL; - GSList *expected = NULL; + GSList* actual = NULL; + GSList* expected = NULL; assert_true(_lists_equal(prof_occurrences(NULL, NULL, 0, FALSE, &actual), expected)); - g_slist_free(actual); actual = NULL; + g_slist_free(actual); + actual = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5: hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5, hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5 hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5: hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5, hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而 hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而: hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而, hi", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而 hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而: hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而, hi", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyy @boothj5, there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 there", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyy @boothj5, there", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "heyy @我能吞下玻璃而, there", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 there", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "heyy @我能吞下玻璃而, there", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); expected = g_slist_append(expected, GINT_TO_POINTER(26)); - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 some more a boothj5 stuff", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 there ands #boothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyy @boothj5, there hows boothj5?", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 some more a boothj5 stuff", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hello boothj5 there ands #boothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyy @boothj5, there hows boothj5?", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); expected = g_slist_append(expected, GINT_TO_POINTER(26)); - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 some more a 我能吞下玻璃而 stuff", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 there ands #我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "heyy @我能吞下玻璃而, there hows 我能吞下玻璃而?", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 some more a 我能吞下玻璃而 stuff", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hello 我能吞下玻璃而 there ands #我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "heyy @我能吞下玻璃而, there hows 我能吞下玻璃而?", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(6)); - assert_true(_lists_equal(prof_occurrences("p", "ppppp p", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("p", "ppppp p", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(0)); - assert_true(_lists_equal(prof_occurrences("p", "p ppppp", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("p", "p ppppp", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = g_slist_append(expected, GINT_TO_POINTER(4)); - assert_true(_lists_equal(prof_occurrences("p", "ppp p ppp", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("p", "ppp p ppp", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5hello", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "hey boothj5hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "hey @boothj5hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5 hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5, hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5boothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5fillboothj5", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "dont know", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kick", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kick kick", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kick kickk", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kic", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "ick", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kk", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("k", "kkkkkkk", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5hello", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hey boothj5hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "hey @boothj5hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5 hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "heyboothj5, hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5boothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("boothj5", "boothj5fillboothj5", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "dont know", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kick", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kick kick", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kick kickk", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kic", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "ick", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kk", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("k", "kkkkkkk", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; expected = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而hello", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey 我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey @我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而 hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而, hithere", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而fill我能吞下玻璃而", 0, TRUE, &actual), expected)); g_slist_free(actual); actual = NULL; - g_slist_free(expected); expected = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而hello", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey 我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey @我能吞下玻璃而hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而 hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "hey我能吞下玻璃而, hithere", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + assert_true(_lists_equal(prof_occurrences("我能吞下玻璃而", "我能吞下玻璃而fill我能吞下玻璃而", 0, TRUE, &actual), expected)); + g_slist_free(actual); + actual = NULL; + g_slist_free(expected); + expected = NULL; } diff --git a/tests/unittests/test_common.h b/tests/unittests/test_common.h index bcef3367..75e6a8c4 100644 --- a/tests/unittests/test_common.h +++ b/tests/unittests/test_common.h @@ -1,41 +1,41 @@ -void replace_one_substr(void **state); -void replace_one_substr_beginning(void **state); -void replace_one_substr_end(void **state); -void replace_two_substr(void **state); -void replace_char(void **state); -void replace_when_none(void **state); -void replace_when_match(void **state); -void replace_when_string_empty(void **state); -void replace_when_string_null(void **state); -void replace_when_sub_empty(void **state); -void replace_when_sub_null(void **state); -void replace_when_new_empty(void **state); -void replace_when_new_null(void **state); -void test_online_is_valid_resource_presence_string(void **state); -void test_chat_is_valid_resource_presence_string(void **state); -void test_away_is_valid_resource_presence_string(void **state); -void test_xa_is_valid_resource_presence_string(void **state); -void test_dnd_is_valid_resource_presence_string(void **state); -void test_available_is_not_valid_resource_presence_string(void **state); -void test_unavailable_is_not_valid_resource_presence_string(void **state); -void test_blah_is_not_valid_resource_presence_string(void **state); -void utf8_display_len_null_str(void **state); -void utf8_display_len_1_non_wide(void **state); -void utf8_display_len_1_wide(void **state); -void utf8_display_len_non_wide(void **state); -void utf8_display_len_wide(void **state); -void utf8_display_len_all_wide(void **state); -void strip_quotes_does_nothing_when_no_quoted(void **state); -void strip_quotes_strips_first(void **state); -void strip_quotes_strips_last(void **state); -void strip_quotes_strips_both(void **state); -void str_not_contains_str(void **state); -void str_contains_str_at_start(void **state); -void str_contains_str_at_end(void **state); -void str_contains_str_in_middle(void **state); -void str_contains_str_whole(void **state); -void str_empty_not_contains_str(void **state); -void str_not_contains_str_empty(void **state); -void str_empty_not_contains_str_empty(void **state); -void prof_partial_occurrences_tests(void **state); -void prof_whole_occurrences_tests(void **state); +void replace_one_substr(void** state); +void replace_one_substr_beginning(void** state); +void replace_one_substr_end(void** state); +void replace_two_substr(void** state); +void replace_char(void** state); +void replace_when_none(void** state); +void replace_when_match(void** state); +void replace_when_string_empty(void** state); +void replace_when_string_null(void** state); +void replace_when_sub_empty(void** state); +void replace_when_sub_null(void** state); +void replace_when_new_empty(void** state); +void replace_when_new_null(void** state); +void test_online_is_valid_resource_presence_string(void** state); +void test_chat_is_valid_resource_presence_string(void** state); +void test_away_is_valid_resource_presence_string(void** state); +void test_xa_is_valid_resource_presence_string(void** state); +void test_dnd_is_valid_resource_presence_string(void** state); +void test_available_is_not_valid_resource_presence_string(void** state); +void test_unavailable_is_not_valid_resource_presence_string(void** state); +void test_blah_is_not_valid_resource_presence_string(void** state); +void utf8_display_len_null_str(void** state); +void utf8_display_len_1_non_wide(void** state); +void utf8_display_len_1_wide(void** state); +void utf8_display_len_non_wide(void** state); +void utf8_display_len_wide(void** state); +void utf8_display_len_all_wide(void** state); +void strip_quotes_does_nothing_when_no_quoted(void** state); +void strip_quotes_strips_first(void** state); +void strip_quotes_strips_last(void** state); +void strip_quotes_strips_both(void** state); +void str_not_contains_str(void** state); +void str_contains_str_at_start(void** state); +void str_contains_str_at_end(void** state); +void str_contains_str_in_middle(void** state); +void str_contains_str_whole(void** state); +void str_empty_not_contains_str(void** state); +void str_not_contains_str_empty(void** state); +void str_empty_not_contains_str_empty(void** state); +void prof_partial_occurrences_tests(void** state); +void prof_whole_occurrences_tests(void** state); diff --git a/tests/unittests/test_contact.c b/tests/unittests/test_contact.c index 127ca5cf..849c9bc0 100644 --- a/tests/unittests/test_contact.c +++ b/tests/unittests/test_contact.c @@ -8,66 +8,71 @@ #include "xmpp/contact.h" -void contact_in_group(void **state) +void +contact_in_group(void** state) { - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("somegroup")); PContact contact = p_contact_new("bob@server.com", "bob", groups, "both", - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_in_group(contact, "somegroup"); assert_true(result); p_contact_free(contact); -// g_slist_free(groups); + // g_slist_free(groups); } -void contact_not_in_group(void **state) +void +contact_not_in_group(void** state) { - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("somegroup")); PContact contact = p_contact_new("bob@server.com", "bob", groups, "both", - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_in_group(contact, "othergroup"); assert_false(result); p_contact_free(contact); -// g_slist_free(groups); + // g_slist_free(groups); } -void contact_name_when_name_exists(void **state) +void +contact_name_when_name_exists(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - const char *name = p_contact_name_or_jid(contact); + const char* name = p_contact_name_or_jid(contact); assert_string_equal("bob", name); p_contact_free(contact); } -void contact_jid_when_name_not_exists(void **state) +void +contact_jid_when_name_not_exists(void** state) { PContact contact = p_contact_new("bob@server.com", NULL, NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - const char *jid = p_contact_name_or_jid(contact); + const char* jid = p_contact_name_or_jid(contact); assert_string_equal("bob@server.com", jid); p_contact_free(contact); } -void contact_string_when_name_exists(void **state) +void +contact_string_when_name_exists(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - char *str = p_contact_create_display_string(contact, "laptop"); + char* str = p_contact_create_display_string(contact, "laptop"); assert_string_equal("bob (laptop)", str); @@ -75,12 +80,13 @@ void contact_string_when_name_exists(void **state) free(str); } -void contact_string_when_name_not_exists(void **state) +void +contact_string_when_name_not_exists(void** state) { PContact contact = p_contact_new("bob@server.com", NULL, NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - char *str = p_contact_create_display_string(contact, "laptop"); + char* str = p_contact_create_display_string(contact, "laptop"); assert_string_equal("bob@server.com (laptop)", str); @@ -88,12 +94,13 @@ void contact_string_when_name_not_exists(void **state) free(str); } -void contact_string_when_default_resource(void **state) +void +contact_string_when_default_resource(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - char *str = p_contact_create_display_string(contact, "__prof_default"); + char* str = p_contact_create_display_string(contact, "__prof_default"); assert_string_equal("bob", str); @@ -101,140 +108,148 @@ void contact_string_when_default_resource(void **state) free(str); } -void contact_presence_offline(void **state) +void +contact_presence_offline(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("offline", presence); p_contact_free(contact); } -void contact_presence_uses_highest_priority(void **state) +void +contact_presence_uses_highest_priority(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource10 = resource_new("resource10", RESOURCE_ONLINE, NULL, 10); - Resource *resource20 = resource_new("resource20", RESOURCE_CHAT, NULL, 20); - Resource *resource30 = resource_new("resource30", RESOURCE_AWAY, NULL, 30); - Resource *resource1 = resource_new("resource1", RESOURCE_XA, NULL, 1); - Resource *resource2 = resource_new("resource2", RESOURCE_DND, NULL, 2); + Resource* resource10 = resource_new("resource10", RESOURCE_ONLINE, NULL, 10); + Resource* resource20 = resource_new("resource20", RESOURCE_CHAT, NULL, 20); + Resource* resource30 = resource_new("resource30", RESOURCE_AWAY, NULL, 30); + Resource* resource1 = resource_new("resource1", RESOURCE_XA, NULL, 1); + Resource* resource2 = resource_new("resource2", RESOURCE_DND, NULL, 2); p_contact_set_presence(contact, resource10); p_contact_set_presence(contact, resource20); p_contact_set_presence(contact, resource30); p_contact_set_presence(contact, resource1); p_contact_set_presence(contact, resource2); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("away", presence); p_contact_free(contact); } -void contact_presence_chat_when_same_prioroty(void **state) +void +contact_presence_chat_when_same_prioroty(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); p_contact_set_presence(contact, resource_xa); p_contact_set_presence(contact, resource_dnd); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("chat", presence); p_contact_free(contact); } -void contact_presence_online_when_same_prioroty(void **state) +void +contact_presence_online_when_same_prioroty(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_away); p_contact_set_presence(contact, resource_xa); p_contact_set_presence(contact, resource_dnd); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("online", presence); p_contact_free(contact); } -void contact_presence_away_when_same_prioroty(void **state) +void +contact_presence_away_when_same_prioroty(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_away); p_contact_set_presence(contact, resource_xa); p_contact_set_presence(contact, resource_dnd); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("away", presence); p_contact_free(contact); } -void contact_presence_xa_when_same_prioroty(void **state) +void +contact_presence_xa_when_same_prioroty(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_xa); p_contact_set_presence(contact, resource_dnd); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("xa", presence); p_contact_free(contact); } -void contact_presence_dnd(void **state) +void +contact_presence_dnd(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_dnd); - const char *presence = p_contact_presence(contact); + const char* presence = p_contact_presence(contact); assert_string_equal("dnd", presence); p_contact_free(contact); } -void contact_subscribed_when_to(void **state) +void +contact_subscribed_when_to(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "to", - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_subscribed(contact); @@ -243,10 +258,11 @@ void contact_subscribed_when_to(void **state) p_contact_free(contact); } -void contact_subscribed_when_both(void **state) +void +contact_subscribed_when_both(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "both", - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_subscribed(contact); @@ -255,10 +271,11 @@ void contact_subscribed_when_both(void **state) p_contact_free(contact); } -void contact_not_subscribed_when_from(void **state) +void +contact_not_subscribed_when_from(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, "from", - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_subscribed(contact); @@ -267,10 +284,11 @@ void contact_not_subscribed_when_from(void **state) p_contact_free(contact); } -void contact_not_subscribed_when_no_subscription_value(void **state) +void +contact_not_subscribed_when_no_subscription_value(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_subscribed(contact); @@ -279,10 +297,11 @@ void contact_not_subscribed_when_no_subscription_value(void **state) p_contact_free(contact); } -void contact_not_available(void **state) +void +contact_not_available(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); gboolean result = p_contact_is_available(contact); @@ -291,16 +310,17 @@ void contact_not_available(void **state) p_contact_free(contact); } -void contact_not_available_when_highest_priority_away(void **state) +void +contact_not_available_when_highest_priority_away(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 20); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 20); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); @@ -314,16 +334,17 @@ void contact_not_available_when_highest_priority_away(void **state) p_contact_free(contact); } -void contact_not_available_when_highest_priority_xa(void **state) +void +contact_not_available_when_highest_priority_xa(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 20); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 20); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); @@ -337,16 +358,17 @@ void contact_not_available_when_highest_priority_xa(void **state) p_contact_free(contact); } -void contact_not_available_when_highest_priority_dnd(void **state) +void +contact_not_available_when_highest_priority_dnd(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 20); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 20); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); @@ -360,16 +382,17 @@ void contact_not_available_when_highest_priority_dnd(void **state) p_contact_free(contact); } -void contact_available_when_highest_priority_online(void **state) +void +contact_available_when_highest_priority_online(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 20); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 20); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 10); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); @@ -383,16 +406,17 @@ void contact_available_when_highest_priority_online(void **state) p_contact_free(contact); } -void contact_available_when_highest_priority_chat(void **state) +void +contact_available_when_highest_priority_chat(void** state) { PContact contact = p_contact_new("bob@server.com", "bob", NULL, NULL, - "is offline", FALSE); + "is offline", FALSE); - Resource *resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); - Resource *resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 20); - Resource *resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); - Resource *resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); - Resource *resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); + Resource* resource_online = resource_new("resource_online", RESOURCE_ONLINE, NULL, 10); + Resource* resource_chat = resource_new("resource_chat", RESOURCE_CHAT, NULL, 20); + Resource* resource_away = resource_new("resource_away", RESOURCE_AWAY, NULL, 10); + Resource* resource_xa = resource_new("resource_xa", RESOURCE_XA, NULL, 10); + Resource* resource_dnd = resource_new("resource_dnd", RESOURCE_DND, NULL, 10); p_contact_set_presence(contact, resource_online); p_contact_set_presence(contact, resource_chat); p_contact_set_presence(contact, resource_away); diff --git a/tests/unittests/test_contact.h b/tests/unittests/test_contact.h index c9d8c1fd..605573ea 100644 --- a/tests/unittests/test_contact.h +++ b/tests/unittests/test_contact.h @@ -1,24 +1,24 @@ -void contact_in_group(void **state); -void contact_not_in_group(void **state); -void contact_name_when_name_exists(void **state); -void contact_jid_when_name_not_exists(void **state); -void contact_string_when_name_exists(void **state); -void contact_string_when_name_not_exists(void **state); -void contact_string_when_default_resource(void **state); -void contact_presence_offline(void **state); -void contact_presence_uses_highest_priority(void **state); -void contact_presence_chat_when_same_prioroty(void **state); -void contact_presence_online_when_same_prioroty(void **state); -void contact_presence_away_when_same_prioroty(void **state); -void contact_presence_xa_when_same_prioroty(void **state); -void contact_presence_dnd(void **state); -void contact_subscribed_when_to(void **state); -void contact_subscribed_when_both(void **state); -void contact_not_subscribed_when_from(void **state); -void contact_not_subscribed_when_no_subscription_value(void **state); -void contact_not_available(void **state); -void contact_not_available_when_highest_priority_away(void **state); -void contact_not_available_when_highest_priority_xa(void **state); -void contact_not_available_when_highest_priority_dnd(void **state); -void contact_available_when_highest_priority_online(void **state); -void contact_available_when_highest_priority_chat(void **state); +void contact_in_group(void** state); +void contact_not_in_group(void** state); +void contact_name_when_name_exists(void** state); +void contact_jid_when_name_not_exists(void** state); +void contact_string_when_name_exists(void** state); +void contact_string_when_name_not_exists(void** state); +void contact_string_when_default_resource(void** state); +void contact_presence_offline(void** state); +void contact_presence_uses_highest_priority(void** state); +void contact_presence_chat_when_same_prioroty(void** state); +void contact_presence_online_when_same_prioroty(void** state); +void contact_presence_away_when_same_prioroty(void** state); +void contact_presence_xa_when_same_prioroty(void** state); +void contact_presence_dnd(void** state); +void contact_subscribed_when_to(void** state); +void contact_subscribed_when_both(void** state); +void contact_not_subscribed_when_from(void** state); +void contact_not_subscribed_when_no_subscription_value(void** state); +void contact_not_available(void** state); +void contact_not_available_when_highest_priority_away(void** state); +void contact_not_available_when_highest_priority_xa(void** state); +void contact_not_available_when_highest_priority_dnd(void** state); +void contact_available_when_highest_priority_online(void** state); +void contact_available_when_highest_priority_chat(void** state); diff --git a/tests/unittests/test_form.c b/tests/unittests/test_form.c index b3158a83..88bf9d55 100644 --- a/tests/unittests/test_form.c +++ b/tests/unittests/test_form.c @@ -7,7 +7,8 @@ #include "xmpp/form.h" -xmpp_ctx_t* connection_get_ctx(void) +xmpp_ctx_t* +connection_get_ctx(void) { return NULL; } @@ -15,7 +16,7 @@ xmpp_ctx_t* connection_get_ctx(void) static DataForm* _new_form(void) { - DataForm *form = malloc(sizeof(DataForm)); + DataForm* form = malloc(sizeof(DataForm)); form->type = NULL; form->title = NULL; form->instructions = NULL; @@ -30,7 +31,7 @@ _new_form(void) static FormField* _new_field(void) { - FormField *field = malloc(sizeof(FormField)); + FormField* field = malloc(sizeof(FormField)); field->label = NULL; field->type = NULL; field->description = NULL; @@ -41,64 +42,67 @@ _new_field(void) field->value_ac = NULL; return field; - } -void get_form_type_field_returns_null_no_fields(void **state) +void +get_form_type_field_returns_null_no_fields(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); - char *result = form_get_form_type_field(form); + char* result = form_get_form_type_field(form); assert_null(result); form_destroy(form); } -void get_form_type_field_returns_null_when_not_present(void **state) +void +get_form_type_field_returns_null_when_not_present(void** state) { - DataForm *form = _new_form(); - FormField *field = _new_field(); + DataForm* form = _new_form(); + FormField* field = _new_field(); field->var = strdup("var1"); field->values = g_slist_append(field->values, strdup("value1")); form->fields = g_slist_append(form->fields, field); - char *result = form_get_form_type_field(form); + char* result = form_get_form_type_field(form); assert_null(result); form_destroy(form); } -void get_form_type_field_returns_value_when_present(void **state) +void +get_form_type_field_returns_value_when_present(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->values = g_slist_append(field1->values, strdup("value1")); form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("FORM_TYPE"); field2->values = g_slist_append(field2->values, strdup("value2")); form->fields = g_slist_append(form->fields, field2); - FormField *field3 = _new_field(); + FormField* field3 = _new_field(); field3->var = strdup("var3"); field3->values = g_slist_append(field3->values, strdup("value3")); form->fields = g_slist_append(form->fields, field3); - char *result = form_get_form_type_field(form); + char* result = form_get_form_type_field(form); assert_string_equal(result, "value2"); form_destroy(form); } -void get_field_type_returns_unknown_when_no_fields(void **state) +void +get_field_type_returns_unknown_when_no_fields(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); form_field_type_t result = form_get_field_type(form, "tag"); @@ -107,19 +111,20 @@ void get_field_type_returns_unknown_when_no_fields(void **state) form_destroy(form); } -void get_field_type_returns_correct_type(void **state) +void +get_field_type_returns_correct_type(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_TEXT_SINGLE; field1->values = g_slist_append(field1->values, strdup("value1")); form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_TEXT_MULTI; field2->values = g_slist_append(field2->values, strdup("value2")); @@ -132,19 +137,20 @@ void get_field_type_returns_correct_type(void **state) form_destroy(form); } -void set_value_adds_when_none(void **state) +void +set_value_adds_when_none(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_TEXT_SINGLE; field1->values = g_slist_append(field1->values, strdup("value1")); form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_LIST_SINGLE; form->fields = g_slist_append(form->fields, field2); @@ -152,10 +158,10 @@ void set_value_adds_when_none(void **state) form_set_value(form, "tag2", "a new value"); int length = 0; - char *value = NULL; - GSList *curr_field = form->fields; + char* value = NULL; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var2") == 0) { length = g_slist_length(field->values); value = field->values->data; @@ -170,18 +176,19 @@ void set_value_adds_when_none(void **state) form_destroy(form); } -void set_value_updates_when_one(void **state) +void +set_value_updates_when_one(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_TEXT_SINGLE; form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_LIST_SINGLE; field2->values = g_slist_append(field2->values, strdup("value2")); @@ -190,10 +197,10 @@ void set_value_updates_when_one(void **state) form_set_value(form, "tag2", "a new value"); int length = 0; - char *value = NULL; - GSList *curr_field = form->fields; + char* value = NULL; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var2") == 0) { length = g_slist_length(field->values); value = field->values->data; @@ -208,18 +215,19 @@ void set_value_updates_when_one(void **state) form_destroy(form); } -void add_unique_value_adds_when_none(void **state) +void +add_unique_value_adds_when_none(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_JID_MULTI; form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_LIST_SINGLE; field2->values = g_slist_append(field2->values, strdup("value2")); @@ -228,10 +236,10 @@ void add_unique_value_adds_when_none(void **state) gboolean ret = form_add_unique_value(form, "tag1", "me@server.com"); int length = 0; - char *value = NULL; - GSList *curr_field = form->fields; + char* value = NULL; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); value = field->values->data; @@ -247,19 +255,20 @@ void add_unique_value_adds_when_none(void **state) form_destroy(form); } -void add_unique_value_does_nothing_when_exists(void **state) +void +add_unique_value_does_nothing_when_exists(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_JID_MULTI; field1->values = g_slist_append(field1->values, strdup("me@server.com")); form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_LIST_SINGLE; field2->values = g_slist_append(field2->values, strdup("value2")); @@ -268,10 +277,10 @@ void add_unique_value_does_nothing_when_exists(void **state) gboolean ret = form_add_unique_value(form, "tag1", "me@server.com"); int length = 0; - char *value = NULL; - GSList *curr_field = form->fields; + char* value = NULL; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); value = field->values->data; @@ -287,13 +296,14 @@ void add_unique_value_does_nothing_when_exists(void **state) form_destroy(form); } -void add_unique_value_adds_when_doesnt_exist(void **state) +void +add_unique_value_adds_when_doesnt_exist(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); g_hash_table_insert(form->tag_to_var, strdup("tag2"), strdup("var2")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_JID_MULTI; field1->values = g_slist_append(field1->values, strdup("dolan@server.com")); @@ -301,7 +311,7 @@ void add_unique_value_adds_when_doesnt_exist(void **state) field1->values = g_slist_append(field1->values, strdup("chi@server.com")); form->fields = g_slist_append(form->fields, field1); - FormField *field2 = _new_field(); + FormField* field2 = _new_field(); field2->var = strdup("var2"); field2->type_t = FIELD_LIST_SINGLE; field2->values = g_slist_append(field2->values, strdup("value2")); @@ -311,12 +321,12 @@ void add_unique_value_adds_when_doesnt_exist(void **state) int length = 0; int count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { if (g_strcmp0(curr_value->data, "me@server.com") == 0) { count++; @@ -335,12 +345,13 @@ void add_unique_value_adds_when_doesnt_exist(void **state) form_destroy(form); } -void add_value_adds_when_none(void **state) +void +add_value_adds_when_none(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; form->fields = g_slist_append(form->fields, field1); @@ -348,10 +359,10 @@ void add_value_adds_when_none(void **state) form_add_value(form, "tag1", "somevalue"); int length = 0; - char *value = NULL; - GSList *curr_field = form->fields; + char* value = NULL; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); value = field->values->data; @@ -366,12 +377,13 @@ void add_value_adds_when_none(void **state) form_destroy(form); } -void add_value_adds_when_some(void **state) +void +add_value_adds_when_some(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("some text")); @@ -383,11 +395,11 @@ void add_value_adds_when_some(void **state) int num_values = 0; int new_value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { num_values++; if (g_strcmp0(curr_value->data, "new value") == 0) { @@ -406,12 +418,13 @@ void add_value_adds_when_some(void **state) form_destroy(form); } -void add_value_adds_when_exists(void **state) +void +add_value_adds_when_exists(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("some text")); @@ -424,11 +437,11 @@ void add_value_adds_when_exists(void **state) int num_values = 0; int new_value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { num_values++; if (g_strcmp0(curr_value->data, "new value") == 0) { @@ -447,12 +460,13 @@ void add_value_adds_when_exists(void **state) form_destroy(form); } -void remove_value_does_nothing_when_none(void **state) +void +remove_value_does_nothing_when_none(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; form->fields = g_slist_append(form->fields, field1); @@ -460,9 +474,9 @@ void remove_value_does_nothing_when_none(void **state) gboolean res = form_remove_value(form, "tag1", "some value"); int length = -1; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); } @@ -475,12 +489,13 @@ void remove_value_does_nothing_when_none(void **state) form_destroy(form); } -void remove_value_does_nothing_when_doesnt_exist(void **state) +void +remove_value_does_nothing_when_doesnt_exist(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value1")); @@ -493,12 +508,12 @@ void remove_value_does_nothing_when_doesnt_exist(void **state) int length = -1; int value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { if (g_strcmp0(curr_value->data, "value5") == 0) { value_count++; @@ -516,12 +531,13 @@ void remove_value_does_nothing_when_doesnt_exist(void **state) form_destroy(form); } -void remove_value_removes_when_one(void **state) +void +remove_value_removes_when_one(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value4")); @@ -530,9 +546,9 @@ void remove_value_removes_when_one(void **state) gboolean res = form_remove_value(form, "tag1", "value4"); int length = -1; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); } @@ -545,12 +561,13 @@ void remove_value_removes_when_one(void **state) form_destroy(form); } -void remove_value_removes_when_many(void **state) +void +remove_value_removes_when_many(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value1")); @@ -563,12 +580,12 @@ void remove_value_removes_when_many(void **state) int length = -1; int value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { if (g_strcmp0(curr_value->data, "value2") == 0) { value_count++; @@ -586,12 +603,13 @@ void remove_value_removes_when_many(void **state) form_destroy(form); } -void remove_text_multi_value_does_nothing_when_none(void **state) +void +remove_text_multi_value_does_nothing_when_none(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; form->fields = g_slist_append(form->fields, field1); @@ -599,9 +617,9 @@ void remove_text_multi_value_does_nothing_when_none(void **state) gboolean res = form_remove_text_multi_value(form, "tag1", 3); int length = -1; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); } @@ -614,12 +632,13 @@ void remove_text_multi_value_does_nothing_when_none(void **state) form_destroy(form); } -void remove_text_multi_value_does_nothing_when_doesnt_exist(void **state) +void +remove_text_multi_value_does_nothing_when_doesnt_exist(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value1")); @@ -632,12 +651,12 @@ void remove_text_multi_value_does_nothing_when_doesnt_exist(void **state) int length = -1; int value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { if (g_strcmp0(curr_value->data, "value5") == 0) { value_count++; @@ -655,12 +674,13 @@ void remove_text_multi_value_does_nothing_when_doesnt_exist(void **state) form_destroy(form); } -void remove_text_multi_value_removes_when_one(void **state) +void +remove_text_multi_value_removes_when_one(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value4")); @@ -669,9 +689,9 @@ void remove_text_multi_value_removes_when_one(void **state) gboolean res = form_remove_text_multi_value(form, "tag1", 1); int length = -1; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); } @@ -684,12 +704,13 @@ void remove_text_multi_value_removes_when_one(void **state) form_destroy(form); } -void remove_text_multi_value_removes_when_many(void **state) +void +remove_text_multi_value_removes_when_many(void** state) { - DataForm *form = _new_form(); + DataForm* form = _new_form(); g_hash_table_insert(form->tag_to_var, strdup("tag1"), strdup("var1")); - FormField *field1 = _new_field(); + FormField* field1 = _new_field(); field1->var = strdup("var1"); field1->type_t = FIELD_LIST_MULTI; field1->values = g_slist_append(field1->values, strdup("value1")); @@ -702,12 +723,12 @@ void remove_text_multi_value_removes_when_many(void **state) int length = -1; int value_count = 0; - GSList *curr_field = form->fields; + GSList* curr_field = form->fields; while (curr_field != NULL) { - FormField *field = curr_field->data; + FormField* field = curr_field->data; if (g_strcmp0(field->var, "var1") == 0) { length = g_slist_length(field->values); - GSList *curr_value = field->values; + GSList* curr_value = field->values; while (curr_value != NULL) { if (g_strcmp0(curr_value->data, "value2") == 0) { value_count++; @@ -724,4 +745,3 @@ void remove_text_multi_value_removes_when_many(void **state) form_destroy(form); } - diff --git a/tests/unittests/test_form.h b/tests/unittests/test_form.h index 65911d0a..a7ae04c5 100644 --- a/tests/unittests/test_form.h +++ b/tests/unittests/test_form.h @@ -1,21 +1,21 @@ -void get_form_type_field_returns_null_no_fields(void **state); -void get_form_type_field_returns_null_when_not_present(void **state); -void get_form_type_field_returns_value_when_present(void **state); -void get_field_type_returns_unknown_when_no_fields(void **state); -void get_field_type_returns_correct_type(void **state); -void set_value_adds_when_none(void **state); -void set_value_updates_when_one(void **state); -void add_unique_value_adds_when_none(void **state); -void add_unique_value_does_nothing_when_exists(void **state); -void add_unique_value_adds_when_doesnt_exist(void **state); -void add_value_adds_when_none(void **state); -void add_value_adds_when_some(void **state); -void add_value_adds_when_exists(void **state); -void remove_value_does_nothing_when_none(void **state); -void remove_value_does_nothing_when_doesnt_exist(void **state); -void remove_value_removes_when_one(void **state); -void remove_value_removes_when_many(void **state); -void remove_text_multi_value_does_nothing_when_none(void **state); -void remove_text_multi_value_does_nothing_when_doesnt_exist(void **state); -void remove_text_multi_value_removes_when_one(void **state); -void remove_text_multi_value_removes_when_many(void **state); +void get_form_type_field_returns_null_no_fields(void** state); +void get_form_type_field_returns_null_when_not_present(void** state); +void get_form_type_field_returns_value_when_present(void** state); +void get_field_type_returns_unknown_when_no_fields(void** state); +void get_field_type_returns_correct_type(void** state); +void set_value_adds_when_none(void** state); +void set_value_updates_when_one(void** state); +void add_unique_value_adds_when_none(void** state); +void add_unique_value_does_nothing_when_exists(void** state); +void add_unique_value_adds_when_doesnt_exist(void** state); +void add_value_adds_when_none(void** state); +void add_value_adds_when_some(void** state); +void add_value_adds_when_exists(void** state); +void remove_value_does_nothing_when_none(void** state); +void remove_value_does_nothing_when_doesnt_exist(void** state); +void remove_value_removes_when_one(void** state); +void remove_value_removes_when_many(void** state); +void remove_text_multi_value_does_nothing_when_none(void** state); +void remove_text_multi_value_does_nothing_when_doesnt_exist(void** state); +void remove_text_multi_value_removes_when_one(void** state); +void remove_text_multi_value_removes_when_many(void** state); diff --git a/tests/unittests/test_jid.c b/tests/unittests/test_jid.c index f1fb0f7b..2650d5da 100644 --- a/tests/unittests/test_jid.c +++ b/tests/unittests/test_jid.c @@ -6,142 +6,162 @@ #include "xmpp/jid.h" -void create_jid_from_null_returns_null(void **state) +void +create_jid_from_null_returns_null(void** state) { - Jid *result = jid_create(NULL); + Jid* result = jid_create(NULL); assert_null(result); } -void create_jid_from_empty_string_returns_null(void **state) +void +create_jid_from_empty_string_returns_null(void** state) { - Jid *result = jid_create(""); + Jid* result = jid_create(""); assert_null(result); } -void create_jid_from_full_returns_full(void **state) +void +create_jid_from_full_returns_full(void** state) { - Jid *result = jid_create("myuser@mydomain/laptop"); + Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("myuser@mydomain/laptop", result->fulljid); jid_destroy(result); } -void create_jid_from_full_returns_bare(void **state) +void +create_jid_from_full_returns_bare(void** state) { - Jid *result = jid_create("myuser@mydomain/laptop"); + Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("myuser@mydomain", result->barejid); jid_destroy(result); } -void create_jid_from_full_returns_resourcepart(void **state) +void +create_jid_from_full_returns_resourcepart(void** state) { - Jid *result = jid_create("myuser@mydomain/laptop"); + Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("laptop", result->resourcepart); jid_destroy(result); } -void create_jid_from_full_returns_localpart(void **state) +void +create_jid_from_full_returns_localpart(void** state) { - Jid *result = jid_create("myuser@mydomain/laptop"); + Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("myuser", result->localpart); jid_destroy(result); } -void create_jid_from_full_returns_domainpart(void **state) +void +create_jid_from_full_returns_domainpart(void** state) { - Jid *result = jid_create("myuser@mydomain/laptop"); + Jid* result = jid_create("myuser@mydomain/laptop"); assert_string_equal("mydomain", result->domainpart); jid_destroy(result); } -void create_jid_from_full_nolocal_returns_full(void **state) +void +create_jid_from_full_nolocal_returns_full(void** state) { - Jid *result = jid_create("mydomain/laptop"); + Jid* result = jid_create("mydomain/laptop"); assert_string_equal("mydomain/laptop", result->fulljid); jid_destroy(result); } -void create_jid_from_full_nolocal_returns_bare(void **state) +void +create_jid_from_full_nolocal_returns_bare(void** state) { - Jid *result = jid_create("mydomain/laptop"); + Jid* result = jid_create("mydomain/laptop"); assert_string_equal("mydomain", result->barejid); jid_destroy(result); } -void create_jid_from_full_nolocal_returns_resourcepart(void **state) +void +create_jid_from_full_nolocal_returns_resourcepart(void** state) { - Jid *result = jid_create("mydomain/laptop"); + Jid* result = jid_create("mydomain/laptop"); assert_string_equal("laptop", result->resourcepart); jid_destroy(result); } -void create_jid_from_full_nolocal_returns_domainpart(void **state) +void +create_jid_from_full_nolocal_returns_domainpart(void** state) { - Jid *result = jid_create("mydomain/laptop"); + Jid* result = jid_create("mydomain/laptop"); assert_string_equal("mydomain", result->domainpart); jid_destroy(result); } -void create_jid_from_full_nolocal_returns_null_localpart(void **state) +void +create_jid_from_full_nolocal_returns_null_localpart(void** state) { - Jid *result = jid_create("mydomain/laptop"); + Jid* result = jid_create("mydomain/laptop"); assert_null(result->localpart); jid_destroy(result); } -void create_jid_from_bare_returns_null_full(void **state) +void +create_jid_from_bare_returns_null_full(void** state) { - Jid *result = jid_create("myuser@mydomain"); + Jid* result = jid_create("myuser@mydomain"); assert_null(result->fulljid); jid_destroy(result); } -void create_jid_from_bare_returns_null_resource(void **state) +void +create_jid_from_bare_returns_null_resource(void** state) { - Jid *result = jid_create("myuser@mydomain"); + Jid* result = jid_create("myuser@mydomain"); assert_null(result->resourcepart); jid_destroy(result); } -void create_jid_from_bare_returns_bare(void **state) +void +create_jid_from_bare_returns_bare(void** state) { - Jid *result = jid_create("myuser@mydomain"); + Jid* result = jid_create("myuser@mydomain"); assert_string_equal("myuser@mydomain", result->barejid); jid_destroy(result); } -void create_jid_from_bare_returns_localpart(void **state) +void +create_jid_from_bare_returns_localpart(void** state) { - Jid *result = jid_create("myuser@mydomain"); + Jid* result = jid_create("myuser@mydomain"); assert_string_equal("myuser", result->localpart); jid_destroy(result); } -void create_jid_from_bare_returns_domainpart(void **state) +void +create_jid_from_bare_returns_domainpart(void** state) { - Jid *result = jid_create("myuser@mydomain"); + Jid* result = jid_create("myuser@mydomain"); assert_string_equal("mydomain", result->domainpart); jid_destroy(result); } -void create_room_jid_returns_room(void **state) +void +create_room_jid_returns_room(void** state) { - Jid *result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); + Jid* result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); assert_string_equal("room@conference.domain.org", result->barejid); jid_destroy(result); } -void create_room_jid_returns_nick(void **state) +void +create_room_jid_returns_nick(void** state) { - Jid *result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); + Jid* result = jid_create_from_bare_and_resource("room@conference.domain.org", "myname"); assert_string_equal("myname", result->resourcepart); jid_destroy(result); } -void create_with_slash_in_resource(void **state) +void +create_with_slash_in_resource(void** state) { - Jid *result = jid_create("room@conference.domain.org/my/nick"); + Jid* result = jid_create("room@conference.domain.org/my/nick"); assert_string_equal("room", result->localpart); assert_string_equal("conference.domain.org", result->domainpart); @@ -152,9 +172,10 @@ void create_with_slash_in_resource(void **state) jid_destroy(result); } -void create_with_at_in_resource(void **state) +void +create_with_at_in_resource(void** state) { - Jid *result = jid_create("room@conference.domain.org/my@nick"); + Jid* result = jid_create("room@conference.domain.org/my@nick"); assert_string_equal("room", result->localpart); assert_string_equal("conference.domain.org", result->domainpart); @@ -165,9 +186,10 @@ void create_with_at_in_resource(void **state) jid_destroy(result); } -void create_with_at_and_slash_in_resource(void **state) +void +create_with_at_and_slash_in_resource(void** state) { - Jid *result = jid_create("room@conference.domain.org/my@nick/something"); + Jid* result = jid_create("room@conference.domain.org/my@nick/something"); assert_string_equal("room", result->localpart); assert_string_equal("conference.domain.org", result->domainpart); @@ -178,9 +200,10 @@ void create_with_at_and_slash_in_resource(void **state) jid_destroy(result); } -void create_full_with_trailing_slash(void **state) +void +create_full_with_trailing_slash(void** state) { - Jid *result = jid_create("room@conference.domain.org/nick/"); + Jid* result = jid_create("room@conference.domain.org/nick/"); assert_string_equal("room", result->localpart); assert_string_equal("conference.domain.org", result->domainpart); @@ -191,22 +214,24 @@ void create_full_with_trailing_slash(void **state) jid_destroy(result); } -void returns_fulljid_when_exists(void **state) +void +returns_fulljid_when_exists(void** state) { - Jid *jid = jid_create("localpart@domainpart/resourcepart"); + Jid* jid = jid_create("localpart@domainpart/resourcepart"); - char *result = jid_fulljid_or_barejid(jid); + char* result = jid_fulljid_or_barejid(jid); assert_string_equal("localpart@domainpart/resourcepart", result); jid_destroy(jid); } -void returns_barejid_when_fulljid_not_exists(void **state) +void +returns_barejid_when_fulljid_not_exists(void** state) { - Jid *jid = jid_create("localpart@domainpart"); + Jid* jid = jid_create("localpart@domainpart"); - char *result = jid_fulljid_or_barejid(jid); + char* result = jid_fulljid_or_barejid(jid); assert_string_equal("localpart@domainpart", result); diff --git a/tests/unittests/test_jid.h b/tests/unittests/test_jid.h index 9b96d0b8..000b820a 100644 --- a/tests/unittests/test_jid.h +++ b/tests/unittests/test_jid.h @@ -1,25 +1,25 @@ -void create_jid_from_null_returns_null(void **state); -void create_jid_from_empty_string_returns_null(void **state); -void create_jid_from_full_returns_full(void **state); -void create_jid_from_full_returns_bare(void **state); -void create_jid_from_full_returns_resourcepart(void **state); -void create_jid_from_full_returns_localpart(void **state); -void create_jid_from_full_returns_domainpart(void **state); -void create_jid_from_full_nolocal_returns_full(void **state); -void create_jid_from_full_nolocal_returns_bare(void **state); -void create_jid_from_full_nolocal_returns_resourcepart(void **state); -void create_jid_from_full_nolocal_returns_domainpart(void **state); -void create_jid_from_full_nolocal_returns_null_localpart(void **state); -void create_jid_from_bare_returns_null_full(void **state); -void create_jid_from_bare_returns_null_resource(void **state); -void create_jid_from_bare_returns_bare(void **state); -void create_jid_from_bare_returns_localpart(void **state); -void create_jid_from_bare_returns_domainpart(void **state); -void create_room_jid_returns_room(void **state); -void create_room_jid_returns_nick(void **state); -void create_with_slash_in_resource(void **state); -void create_with_at_in_resource(void **state); -void create_with_at_and_slash_in_resource(void **state); -void create_full_with_trailing_slash(void **state); -void returns_fulljid_when_exists(void **state); -void returns_barejid_when_fulljid_not_exists(void **state); +void create_jid_from_null_returns_null(void** state); +void create_jid_from_empty_string_returns_null(void** state); +void create_jid_from_full_returns_full(void** state); +void create_jid_from_full_returns_bare(void** state); +void create_jid_from_full_returns_resourcepart(void** state); +void create_jid_from_full_returns_localpart(void** state); +void create_jid_from_full_returns_domainpart(void** state); +void create_jid_from_full_nolocal_returns_full(void** state); +void create_jid_from_full_nolocal_returns_bare(void** state); +void create_jid_from_full_nolocal_returns_resourcepart(void** state); +void create_jid_from_full_nolocal_returns_domainpart(void** state); +void create_jid_from_full_nolocal_returns_null_localpart(void** state); +void create_jid_from_bare_returns_null_full(void** state); +void create_jid_from_bare_returns_null_resource(void** state); +void create_jid_from_bare_returns_bare(void** state); +void create_jid_from_bare_returns_localpart(void** state); +void create_jid_from_bare_returns_domainpart(void** state); +void create_room_jid_returns_room(void** state); +void create_room_jid_returns_nick(void** state); +void create_with_slash_in_resource(void** state); +void create_with_at_in_resource(void** state); +void create_with_at_and_slash_in_resource(void** state); +void create_full_with_trailing_slash(void** state); +void returns_fulljid_when_exists(void** state); +void returns_barejid_when_fulljid_not_exists(void** state); diff --git a/tests/unittests/test_muc.c b/tests/unittests/test_muc.c index 888ce039..80d6fbcf 100644 --- a/tests/unittests/test_muc.c +++ b/tests/unittests/test_muc.c @@ -6,19 +6,22 @@ #include "xmpp/muc.h" -void muc_before_test(void **state) +void +muc_before_test(void** state) { muc_init(); } -void muc_after_test(void **state) +void +muc_after_test(void** state) { muc_close(); } -void test_muc_invites_add(void **state) +void +test_muc_invites_add(void** state) { - char *room = "room@conf.server"; + char* room = "room@conf.server"; muc_invites_add(room, NULL); gboolean invite_exists = muc_invites_contain(room); @@ -26,9 +29,10 @@ void test_muc_invites_add(void **state) assert_true(invite_exists); } -void test_muc_remove_invite(void **state) +void +test_muc_remove_invite(void** state) { - char *room = "room@conf.server"; + char* room = "room@conf.server"; muc_invites_add(room, NULL); muc_invites_remove(room); @@ -37,14 +41,16 @@ void test_muc_remove_invite(void **state) assert_false(invite_exists); } -void test_muc_invites_count_0(void **state) +void +test_muc_invites_count_0(void** state) { int invite_count = muc_invites_count(); assert_true(invite_count == 0); } -void test_muc_invites_count_5(void **state) +void +test_muc_invites_count_5(void** state) { muc_invites_add("room1@conf.server", NULL); muc_invites_add("room2@conf.server", NULL); @@ -57,19 +63,21 @@ void test_muc_invites_count_5(void **state) assert_true(invite_count == 5); } -void test_muc_room_is_not_active(void **state) +void +test_muc_room_is_not_active(void** state) { - char *room = "room@server.org"; + char* room = "room@server.org"; gboolean room_is_active = muc_active(room); assert_false(room_is_active); } -void test_muc_active(void **state) +void +test_muc_active(void** state) { - char *room = "room@server.org"; - char *nick = "bob"; + char* room = "room@server.org"; + char* nick = "bob"; muc_join(room, nick, NULL, FALSE); gboolean room_is_active = muc_active(room); diff --git a/tests/unittests/test_muc.h b/tests/unittests/test_muc.h index 8df54a5d..2140d520 100644 --- a/tests/unittests/test_muc.h +++ b/tests/unittests/test_muc.h @@ -1,9 +1,9 @@ -void muc_before_test(void **state); -void muc_after_test(void **state); +void muc_before_test(void** state); +void muc_after_test(void** state); -void test_muc_invites_add(void **state); -void test_muc_remove_invite(void **state); -void test_muc_invites_count_0(void **state); -void test_muc_invites_count_5(void **state); -void test_muc_room_is_not_active(void **state); -void test_muc_active(void **state); +void test_muc_invites_add(void** state); +void test_muc_remove_invite(void** state); +void test_muc_invites_count_0(void** state); +void test_muc_invites_count_5(void** state); +void test_muc_room_is_not_active(void** state); +void test_muc_active(void** state); diff --git a/tests/unittests/test_parser.c b/tests/unittests/test_parser.c index e64438a4..96143294 100644 --- a/tests/unittests/test_parser.c +++ b/tests/unittests/test_parser.c @@ -7,11 +7,11 @@ #include "tools/parser.h" void -parse_null_returns_null(void **state) +parse_null_returns_null(void** state) { - char *inp = NULL; + char* inp = NULL; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_false(result); assert_null(args); @@ -19,11 +19,11 @@ parse_null_returns_null(void **state) } void -parse_empty_returns_null(void **state) +parse_empty_returns_null(void** state) { - char *inp = ""; + char* inp = ""; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_false(result); assert_null(args); @@ -31,11 +31,11 @@ parse_empty_returns_null(void **state) } void -parse_space_returns_null(void **state) +parse_space_returns_null(void** state) { - char *inp = " "; + char* inp = " "; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_false(result); assert_null(args); @@ -43,11 +43,11 @@ parse_space_returns_null(void **state) } void -parse_cmd_no_args_returns_null(void **state) +parse_cmd_no_args_returns_null(void** state) { - char *inp = "/cmd"; + char* inp = "/cmd"; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_false(result); assert_null(args); @@ -55,11 +55,11 @@ parse_cmd_no_args_returns_null(void **state) } void -parse_cmd_with_space_returns_null(void **state) +parse_cmd_with_space_returns_null(void** state) { - char *inp = "/cmd "; + char* inp = "/cmd "; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_false(result); assert_null(args); @@ -67,11 +67,11 @@ parse_cmd_with_space_returns_null(void **state) } void -parse_cmd_with_too_few_returns_null(void **state) +parse_cmd_with_too_few_returns_null(void** state) { - char *inp = "/cmd arg1"; + char* inp = "/cmd arg1"; gboolean result = TRUE; - gchar **args = parse_args(inp, 2, 3, &result); + gchar** args = parse_args(inp, 2, 3, &result); assert_false(result); assert_null(args); @@ -79,11 +79,11 @@ parse_cmd_with_too_few_returns_null(void **state) } void -parse_cmd_with_too_many_returns_null(void **state) +parse_cmd_with_too_many_returns_null(void** state) { - char *inp = "/cmd arg1 arg2 arg3 arg4"; + char* inp = "/cmd arg1 arg2 arg3 arg4"; gboolean result = TRUE; - gchar **args = parse_args(inp, 1, 3, &result); + gchar** args = parse_args(inp, 1, 3, &result); assert_false(result); assert_null(args); @@ -91,11 +91,11 @@ parse_cmd_with_too_many_returns_null(void **state) } void -parse_cmd_one_arg(void **state) +parse_cmd_one_arg(void** state) { - char *inp = "/cmd arg1"; + char* inp = "/cmd arg1"; gboolean result = FALSE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_true(result); assert_int_equal(1, g_strv_length(args)); @@ -104,11 +104,11 @@ parse_cmd_one_arg(void **state) } void -parse_cmd_two_args(void **state) +parse_cmd_two_args(void** state) { - char *inp = "/cmd arg1 arg2"; + char* inp = "/cmd arg1 arg2"; gboolean result = FALSE; - gchar **args = parse_args(inp, 1, 2, &result); + gchar** args = parse_args(inp, 1, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -118,11 +118,11 @@ parse_cmd_two_args(void **state) } void -parse_cmd_three_args(void **state) +parse_cmd_three_args(void** state) { - char *inp = "/cmd arg1 arg2 arg3"; + char* inp = "/cmd arg1 arg2 arg3"; gboolean result = FALSE; - gchar **args = parse_args(inp, 3, 3, &result); + gchar** args = parse_args(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -133,11 +133,11 @@ parse_cmd_three_args(void **state) } void -parse_cmd_three_args_with_spaces(void **state) +parse_cmd_three_args_with_spaces(void** state) { - char *inp = " /cmd arg1 arg2 arg3 "; + char* inp = " /cmd arg1 arg2 arg3 "; gboolean result = FALSE; - gchar **args = parse_args(inp, 3, 3, &result); + gchar** args = parse_args(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -148,11 +148,11 @@ parse_cmd_three_args_with_spaces(void **state) } void -parse_cmd_with_freetext(void **state) +parse_cmd_with_freetext(void** state) { - char *inp = "/cmd this is some free text"; + char* inp = "/cmd this is some free text"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 1, 1, &result); + gchar** args = parse_args_with_freetext(inp, 1, 1, &result); assert_true(result); assert_int_equal(1, g_strv_length(args)); @@ -161,11 +161,11 @@ parse_cmd_with_freetext(void **state) } void -parse_cmd_one_arg_with_freetext(void **state) +parse_cmd_one_arg_with_freetext(void** state) { - char *inp = "/cmd arg1 this is some free text"; + char* inp = "/cmd arg1 this is some free text"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 1, 2, &result); + gchar** args = parse_args_with_freetext(inp, 1, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -175,11 +175,11 @@ parse_cmd_one_arg_with_freetext(void **state) } void -parse_cmd_two_args_with_freetext(void **state) +parse_cmd_two_args_with_freetext(void** state) { - char *inp = "/cmd arg1 arg2 this is some free text"; + char* inp = "/cmd arg1 arg2 this is some free text"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 1, 3, &result); + gchar** args = parse_args_with_freetext(inp, 1, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -190,11 +190,11 @@ parse_cmd_two_args_with_freetext(void **state) } void -parse_cmd_min_zero(void **state) +parse_cmd_min_zero(void** state) { - char *inp = "/cmd"; + char* inp = "/cmd"; gboolean result = FALSE; - gchar **args = parse_args(inp, 0, 2, &result); + gchar** args = parse_args(inp, 0, 2, &result); assert_true(result); assert_int_equal(0, g_strv_length(args)); @@ -203,11 +203,11 @@ parse_cmd_min_zero(void **state) } void -parse_cmd_min_zero_with_freetext(void **state) +parse_cmd_min_zero_with_freetext(void** state) { - char *inp = "/cmd"; + char* inp = "/cmd"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 0, 2, &result); + gchar** args = parse_args_with_freetext(inp, 0, 2, &result); assert_true(result); assert_int_equal(0, g_strv_length(args)); @@ -216,11 +216,11 @@ parse_cmd_min_zero_with_freetext(void **state) } void -parse_cmd_with_quoted(void **state) +parse_cmd_with_quoted(void** state) { - char *inp = "/cmd \"arg1\" arg2"; + char* inp = "/cmd \"arg1\" arg2"; gboolean result = FALSE; - gchar **args = parse_args(inp, 2, 2, &result); + gchar** args = parse_args(inp, 2, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -230,11 +230,11 @@ parse_cmd_with_quoted(void **state) } void -parse_cmd_with_quoted_and_space(void **state) +parse_cmd_with_quoted_and_space(void** state) { - char *inp = "/cmd \"the arg1\" arg2"; + char* inp = "/cmd \"the arg1\" arg2"; gboolean result = FALSE; - gchar **args = parse_args(inp, 2, 2, &result); + gchar** args = parse_args(inp, 2, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -244,11 +244,11 @@ parse_cmd_with_quoted_and_space(void **state) } void -parse_cmd_with_quoted_and_many_spaces(void **state) +parse_cmd_with_quoted_and_many_spaces(void** state) { - char *inp = "/cmd \"the arg1 is here\" arg2"; + char* inp = "/cmd \"the arg1 is here\" arg2"; gboolean result = FALSE; - gchar **args = parse_args(inp, 2, 2, &result); + gchar** args = parse_args(inp, 2, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -258,11 +258,11 @@ parse_cmd_with_quoted_and_many_spaces(void **state) } void -parse_cmd_with_many_quoted_and_many_spaces(void **state) +parse_cmd_with_many_quoted_and_many_spaces(void** state) { - char *inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\""; + char* inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\""; gboolean result = FALSE; - gchar **args = parse_args(inp, 2, 2, &result); + gchar** args = parse_args(inp, 2, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -272,11 +272,11 @@ parse_cmd_with_many_quoted_and_many_spaces(void **state) } void -parse_cmd_freetext_with_quoted(void **state) +parse_cmd_freetext_with_quoted(void** state) { - char *inp = "/cmd \"arg1\" arg2 hello there whats up"; + char* inp = "/cmd \"arg1\" arg2 hello there whats up"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 3, 3, &result); + gchar** args = parse_args_with_freetext(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -287,11 +287,11 @@ parse_cmd_freetext_with_quoted(void **state) } void -parse_cmd_freetext_with_quoted_and_space(void **state) +parse_cmd_freetext_with_quoted_and_space(void** state) { - char *inp = "/cmd \"the arg1\" arg2 another bit of freetext"; + char* inp = "/cmd \"the arg1\" arg2 another bit of freetext"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 3, 3, &result); + gchar** args = parse_args_with_freetext(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -302,11 +302,11 @@ parse_cmd_freetext_with_quoted_and_space(void **state) } void -parse_cmd_freetext_with_quoted_and_many_spaces(void **state) +parse_cmd_freetext_with_quoted_and_many_spaces(void** state) { - char *inp = "/cmd \"the arg1 is here\" arg2 some more freetext"; + char* inp = "/cmd \"the arg1 is here\" arg2 some more freetext"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 3, 3, &result); + gchar** args = parse_args_with_freetext(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -317,11 +317,11 @@ parse_cmd_freetext_with_quoted_and_many_spaces(void **state) } void -parse_cmd_freetext_with_many_quoted_and_many_spaces(void **state) +parse_cmd_freetext_with_many_quoted_and_many_spaces(void** state) { - char *inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\" and heres the free text"; + char* inp = "/cmd \"the arg1 is here\" \"and arg2 is right here\" and heres the free text"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 3, 3, &result); + gchar** args = parse_args_with_freetext(inp, 3, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -332,11 +332,11 @@ parse_cmd_freetext_with_many_quoted_and_many_spaces(void **state) } void -parse_cmd_with_quoted_freetext(void **state) +parse_cmd_with_quoted_freetext(void** state) { - char *inp = "/cmd arg1 here is \"some\" quoted freetext"; + char* inp = "/cmd arg1 here is \"some\" quoted freetext"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 1, 2, &result); + gchar** args = parse_args_with_freetext(inp, 1, 2, &result); assert_true(result); assert_int_equal(2, g_strv_length(args)); @@ -346,11 +346,11 @@ parse_cmd_with_quoted_freetext(void **state) } void -parse_cmd_with_third_arg_quoted_0_min_3_max(void **state) +parse_cmd_with_third_arg_quoted_0_min_3_max(void** state) { - char *inp = "/group add friends \"The User\""; + char* inp = "/group add friends \"The User\""; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 0, 3, &result); + gchar** args = parse_args_with_freetext(inp, 0, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -362,11 +362,11 @@ parse_cmd_with_third_arg_quoted_0_min_3_max(void **state) } void -parse_cmd_with_second_arg_quoted_0_min_3_max(void **state) +parse_cmd_with_second_arg_quoted_0_min_3_max(void** state) { - char *inp = "/group add \"The Group\" friend"; + char* inp = "/group add \"The Group\" friend"; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 0, 3, &result); + gchar** args = parse_args_with_freetext(inp, 0, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -378,11 +378,11 @@ parse_cmd_with_second_arg_quoted_0_min_3_max(void **state) } void -parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void **state) +parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void** state) { - char *inp = "/group add \"The Group\" \"The User\""; + char* inp = "/group add \"The Group\" \"The User\""; gboolean result = FALSE; - gchar **args = parse_args_with_freetext(inp, 0, 3, &result); + gchar** args = parse_args_with_freetext(inp, 0, 3, &result); assert_true(result); assert_int_equal(3, g_strv_length(args)); @@ -394,137 +394,137 @@ parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void **state) } void -count_one_token(void **state) +count_one_token(void** state) { - char *inp = "one"; + char* inp = "one"; int result = count_tokens(inp); assert_int_equal(1, result); } void -count_one_token_quoted_no_whitespace(void **state) +count_one_token_quoted_no_whitespace(void** state) { - char *inp = "\"one\""; + char* inp = "\"one\""; int result = count_tokens(inp); assert_int_equal(1, result); } void -count_one_token_quoted_with_whitespace(void **state) +count_one_token_quoted_with_whitespace(void** state) { - char *inp = "\"one two\""; + char* inp = "\"one two\""; int result = count_tokens(inp); assert_int_equal(1, result); } void -count_two_tokens(void **state) +count_two_tokens(void** state) { - char *inp = "one two"; + char* inp = "one two"; int result = count_tokens(inp); assert_int_equal(2, result); } void -count_two_tokens_first_quoted(void **state) +count_two_tokens_first_quoted(void** state) { - char *inp = "\"one and\" two"; + char* inp = "\"one and\" two"; int result = count_tokens(inp); assert_int_equal(2, result); } void -count_two_tokens_second_quoted(void **state) +count_two_tokens_second_quoted(void** state) { - char *inp = "one \"two and\""; + char* inp = "one \"two and\""; int result = count_tokens(inp); assert_int_equal(2, result); } void -count_two_tokens_both_quoted(void **state) +count_two_tokens_both_quoted(void** state) { - char *inp = "\"one and then\" \"two and\""; + char* inp = "\"one and then\" \"two and\""; int result = count_tokens(inp); assert_int_equal(2, result); } void -get_first_of_one(void **state) +get_first_of_one(void** state) { - char *inp = "one"; - char *result = get_start(inp, 2); + char* inp = "one"; + char* result = get_start(inp, 2); assert_string_equal("one", result); free(result); } void -get_first_of_two(void **state) +get_first_of_two(void** state) { - char *inp = "one two"; - char *result = get_start(inp, 2); + char* inp = "one two"; + char* result = get_start(inp, 2); assert_string_equal("one ", result); free(result); } void -get_first_two_of_three(void **state) +get_first_two_of_three(void** state) { - char *inp = "one two three"; - char *result = get_start(inp, 3); + char* inp = "one two three"; + char* result = get_start(inp, 3); assert_string_equal("one two ", result); free(result); } void -get_first_two_of_three_first_quoted(void **state) +get_first_two_of_three_first_quoted(void** state) { - char *inp = "\"one\" two three"; - char *result = get_start(inp, 3); + char* inp = "\"one\" two three"; + char* result = get_start(inp, 3); assert_string_equal("\"one\" two ", result); free(result); } void -get_first_two_of_three_second_quoted(void **state) +get_first_two_of_three_second_quoted(void** state) { - char *inp = "one \"two\" three"; - char *result = get_start(inp, 3); + char* inp = "one \"two\" three"; + char* result = get_start(inp, 3); assert_string_equal("one \"two\" ", result); free(result); } void -get_first_two_of_three_first_and_second_quoted(void **state) +get_first_two_of_three_first_and_second_quoted(void** state) { - char *inp = "\"one\" \"two\" three"; - char *result = get_start(inp, 3); + char* inp = "\"one\" \"two\" three"; + char* result = get_start(inp, 3); assert_string_equal("\"one\" \"two\" ", result); free(result); } void -parse_options_when_none_returns_empty_hasmap(void **state) +parse_options_when_none_returns_empty_hasmap(void** state) { - gchar *args[] = { "cmd1", "cmd2", NULL }; - gchar *keys[] = { "opt1", NULL }; + gchar* args[] = { "cmd1", "cmd2", NULL }; + gchar* keys[] = { "opt1", NULL }; gboolean res = FALSE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_true(options != NULL); assert_int_equal(0, g_hash_table_size(options)); @@ -534,14 +534,14 @@ parse_options_when_none_returns_empty_hasmap(void **state) } void -parse_options_when_opt1_no_val_sets_error(void **state) +parse_options_when_opt1_no_val_sets_error(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", NULL }; - gchar *keys[] = { "opt1", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", NULL }; + gchar* keys[] = { "opt1", NULL }; gboolean res = TRUE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_null(options); assert_false(res); @@ -550,14 +550,14 @@ parse_options_when_opt1_no_val_sets_error(void **state) } void -parse_options_when_one_returns_map(void **state) +parse_options_when_one_returns_map(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", NULL }; - gchar *keys[] = { "opt1", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", NULL }; + gchar* keys[] = { "opt1", NULL }; gboolean res = FALSE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_int_equal(1, g_hash_table_size(options)); assert_true(g_hash_table_contains(options, "opt1")); @@ -568,14 +568,14 @@ parse_options_when_one_returns_map(void **state) } void -parse_options_when_opt2_no_val_sets_error(void **state) +parse_options_when_opt2_no_val_sets_error(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", NULL }; - gchar *keys[] = { "opt1", "opt2", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", NULL }; + gchar* keys[] = { "opt1", "opt2", NULL }; gboolean res = TRUE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_null(options); assert_false(res); @@ -584,14 +584,14 @@ parse_options_when_opt2_no_val_sets_error(void **state) } void -parse_options_when_two_returns_map(void **state) +parse_options_when_two_returns_map(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", NULL }; - gchar *keys[] = { "opt1", "opt2", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", NULL }; + gchar* keys[] = { "opt1", "opt2", NULL }; gboolean res = FALSE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_int_equal(2, g_hash_table_size(options)); assert_true(g_hash_table_contains(options, "opt1")); @@ -604,14 +604,14 @@ parse_options_when_two_returns_map(void **state) } void -parse_options_when_opt3_no_val_sets_error(void **state) +parse_options_when_opt3_no_val_sets_error(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", NULL }; - gchar *keys[] = { "opt1", "opt2", "opt3", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", NULL }; + gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gboolean res = TRUE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_null(options); assert_false(res); @@ -620,14 +620,14 @@ parse_options_when_opt3_no_val_sets_error(void **state) } void -parse_options_when_three_returns_map(void **state) +parse_options_when_three_returns_map(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", "val3", NULL }; - gchar *keys[] = { "opt1", "opt2", "opt3", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt3", "val3", NULL }; + gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gboolean res = FALSE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_int_equal(3, g_hash_table_size(options)); assert_true(g_hash_table_contains(options, "opt1")); @@ -642,14 +642,14 @@ parse_options_when_three_returns_map(void **state) } void -parse_options_when_unknown_opt_sets_error(void **state) +parse_options_when_unknown_opt_sets_error(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "oops", "val2", "opt3", "val3", NULL }; - gchar *keys[] = { "opt1", "opt2", "opt3", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "oops", "val2", "opt3", "val3", NULL }; + gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gboolean res = TRUE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_null(options); assert_false(res); @@ -658,14 +658,14 @@ parse_options_when_unknown_opt_sets_error(void **state) } void -parse_options_with_duplicated_option_sets_error(void **state) +parse_options_with_duplicated_option_sets_error(void** state) { - gchar *args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt1", "val3", NULL }; - gchar *keys[] = { "opt1", "opt2", "opt3", NULL }; + gchar* args[] = { "cmd1", "cmd2", "opt1", "val1", "opt2", "val2", "opt1", "val3", NULL }; + gchar* keys[] = { "opt1", "opt2", "opt3", NULL }; gboolean res = TRUE; - GHashTable *options = parse_options(&args[2], keys, &res); + GHashTable* options = parse_options(&args[2], keys, &res); assert_null(options); assert_false(res); diff --git a/tests/unittests/test_parser.h b/tests/unittests/test_parser.h index 51d768fe..7babb0be 100644 --- a/tests/unittests/test_parser.h +++ b/tests/unittests/test_parser.h @@ -1,50 +1,50 @@ -void parse_null_returns_null(void **state); -void parse_empty_returns_null(void **state); -void parse_space_returns_null(void **state); -void parse_cmd_no_args_returns_null(void **state); -void parse_cmd_with_space_returns_null(void **state); -void parse_cmd_with_too_few_returns_null(void **state); -void parse_cmd_with_too_many_returns_null(void **state); -void parse_cmd_one_arg(void **state); -void parse_cmd_two_args(void **state); -void parse_cmd_three_args(void **state); -void parse_cmd_three_args_with_spaces(void **state); -void parse_cmd_with_freetext(void **state); -void parse_cmd_one_arg_with_freetext(void **state); -void parse_cmd_two_args_with_freetext(void **state); -void parse_cmd_min_zero(void **state); -void parse_cmd_min_zero_with_freetext(void **state); -void parse_cmd_with_quoted(void **state); -void parse_cmd_with_quoted_and_space(void **state); -void parse_cmd_with_quoted_and_many_spaces(void **state); -void parse_cmd_with_many_quoted_and_many_spaces(void **state); -void parse_cmd_freetext_with_quoted(void **state); -void parse_cmd_freetext_with_quoted_and_space(void **state); -void parse_cmd_freetext_with_quoted_and_many_spaces(void **state); -void parse_cmd_freetext_with_many_quoted_and_many_spaces(void **state); -void parse_cmd_with_quoted_freetext(void **state); -void parse_cmd_with_third_arg_quoted_0_min_3_max(void **state); -void parse_cmd_with_second_arg_quoted_0_min_3_max(void **state); -void parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void **state); -void count_one_token(void **state); -void count_one_token_quoted_no_whitespace(void **state); -void count_one_token_quoted_with_whitespace(void **state); -void count_two_tokens(void **state); -void count_two_tokens_first_quoted(void **state); -void count_two_tokens_second_quoted(void **state); -void count_two_tokens_both_quoted(void **state); -void get_first_of_one(void **state); -void get_first_of_two(void **state); -void get_first_two_of_three(void **state); -void get_first_two_of_three_first_quoted(void **state); -void get_first_two_of_three_second_quoted(void **state); -void get_first_two_of_three_first_and_second_quoted(void **state); -void parse_options_when_none_returns_empty_hasmap(void **state); -void parse_options_when_opt1_no_val_sets_error(void **state); -void parse_options_when_one_returns_map(void **state); -void parse_options_when_opt2_no_val_sets_error(void **state); -void parse_options_when_two_returns_map(void **state); -void parse_options_when_opt3_no_val_sets_error(void **state); -void parse_options_when_three_returns_map(void **state); -void parse_options_when_unknown_opt_sets_error(void **state); -void parse_options_with_duplicated_option_sets_error(void **state); +void parse_null_returns_null(void** state); +void parse_empty_returns_null(void** state); +void parse_space_returns_null(void** state); +void parse_cmd_no_args_returns_null(void** state); +void parse_cmd_with_space_returns_null(void** state); +void parse_cmd_with_too_few_returns_null(void** state); +void parse_cmd_with_too_many_returns_null(void** state); +void parse_cmd_one_arg(void** state); +void parse_cmd_two_args(void** state); +void parse_cmd_three_args(void** state); +void parse_cmd_three_args_with_spaces(void** state); +void parse_cmd_with_freetext(void** state); +void parse_cmd_one_arg_with_freetext(void** state); +void parse_cmd_two_args_with_freetext(void** state); +void parse_cmd_min_zero(void** state); +void parse_cmd_min_zero_with_freetext(void** state); +void parse_cmd_with_quoted(void** state); +void parse_cmd_with_quoted_and_space(void** state); +void parse_cmd_with_quoted_and_many_spaces(void** state); +void parse_cmd_with_many_quoted_and_many_spaces(void** state); +void parse_cmd_freetext_with_quoted(void** state); +void parse_cmd_freetext_with_quoted_and_space(void** state); +void parse_cmd_freetext_with_quoted_and_many_spaces(void** state); +void parse_cmd_freetext_with_many_quoted_and_many_spaces(void** state); +void parse_cmd_with_quoted_freetext(void** state); +void parse_cmd_with_third_arg_quoted_0_min_3_max(void** state); +void parse_cmd_with_second_arg_quoted_0_min_3_max(void** state); +void parse_cmd_with_second_and_third_arg_quoted_0_min_3_max(void** state); +void count_one_token(void** state); +void count_one_token_quoted_no_whitespace(void** state); +void count_one_token_quoted_with_whitespace(void** state); +void count_two_tokens(void** state); +void count_two_tokens_first_quoted(void** state); +void count_two_tokens_second_quoted(void** state); +void count_two_tokens_both_quoted(void** state); +void get_first_of_one(void** state); +void get_first_of_two(void** state); +void get_first_two_of_three(void** state); +void get_first_two_of_three_first_quoted(void** state); +void get_first_two_of_three_second_quoted(void** state); +void get_first_two_of_three_first_and_second_quoted(void** state); +void parse_options_when_none_returns_empty_hasmap(void** state); +void parse_options_when_opt1_no_val_sets_error(void** state); +void parse_options_when_one_returns_map(void** state); +void parse_options_when_opt2_no_val_sets_error(void** state); +void parse_options_when_two_returns_map(void** state); +void parse_options_when_opt3_no_val_sets_error(void** state); +void parse_options_when_three_returns_map(void** state); +void parse_options_when_unknown_opt_sets_error(void** state); +void parse_options_with_duplicated_option_sets_error(void** state); diff --git a/tests/unittests/test_plugins_disco.c b/tests/unittests/test_plugins_disco.c index f152d935..880a09b1 100644 --- a/tests/unittests/test_plugins_disco.c +++ b/tests/unittests/test_plugins_disco.c @@ -7,10 +7,10 @@ #include "plugins/disco.h" void -returns_empty_list_when_none(void **state) +returns_empty_list_when_none(void** state) { disco_close(); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 0); @@ -19,14 +19,14 @@ returns_empty_list_when_none(void **state) } void -returns_added_feature(void **state) +returns_added_feature(void** state) { disco_close(); disco_add_feature("my_plugin", "some:feature:example"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 1); - char *feature = features->data; + char* feature = features->data; assert_string_equal(feature, "some:feature:example"); g_list_free(features); @@ -34,12 +34,12 @@ returns_added_feature(void **state) } void -resets_features_on_close(void **state) +resets_features_on_close(void** state) { disco_close(); disco_add_feature("my_plugin", "some:feature:example"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 1); g_list_free(features); @@ -52,7 +52,7 @@ resets_features_on_close(void **state) } void -returns_all_added_features(void **state) +returns_all_added_features(void** state) { disco_close(); disco_add_feature("first_plugin", "first:feature"); @@ -61,7 +61,7 @@ returns_all_added_features(void **state) disco_add_feature("third_plugin", "fourth:feature"); disco_add_feature("third_plugin", "fifth:feature"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 5); assert_true(g_list_find_custom(features, "first:feature", (GCompareFunc)g_strcmp0)); @@ -75,13 +75,13 @@ returns_all_added_features(void **state) } void -does_not_add_duplicate_feature(void **state) +does_not_add_duplicate_feature(void** state) { disco_close(); disco_add_feature("my_plugin", "my:feature"); disco_add_feature("some_other_plugin", "my:feature"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 1); g_list_free(features); @@ -89,14 +89,14 @@ does_not_add_duplicate_feature(void **state) } void -removes_plugin_features(void **state) +removes_plugin_features(void** state) { disco_close(); disco_add_feature("plugin1", "plugin1:feature1"); disco_add_feature("plugin1", "plugin1:feature2"); disco_add_feature("plugin2", "plugin2:feature1"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 3); g_list_free(features); @@ -110,14 +110,14 @@ removes_plugin_features(void **state) } void -does_not_remove_feature_when_more_than_one_reference(void **state) +does_not_remove_feature_when_more_than_one_reference(void** state) { disco_close(); disco_add_feature("plugin1", "feature1"); disco_add_feature("plugin1", "feature2"); disco_add_feature("plugin2", "feature1"); - GList *features = disco_get_features(); + GList* features = disco_get_features(); assert_int_equal(g_list_length(features), 2); g_list_free(features); diff --git a/tests/unittests/test_plugins_disco.h b/tests/unittests/test_plugins_disco.h index 937cbfe1..4377e28e 100644 --- a/tests/unittests/test_plugins_disco.h +++ b/tests/unittests/test_plugins_disco.h @@ -1,7 +1,7 @@ -void returns_empty_list_when_none(void **state); -void returns_added_feature(void **state); -void resets_features_on_close(void **state); -void returns_all_added_features(void **state); -void does_not_add_duplicate_feature(void **state); -void removes_plugin_features(void **state); -void does_not_remove_feature_when_more_than_one_reference(void **state); +void returns_empty_list_when_none(void** state); +void returns_added_feature(void** state); +void resets_features_on_close(void** state); +void returns_all_added_features(void** state); +void does_not_add_duplicate_feature(void** state); +void removes_plugin_features(void** state); +void does_not_remove_feature_when_more_than_one_reference(void** state); diff --git a/tests/unittests/test_preferences.c b/tests/unittests/test_preferences.c index 5aeb266d..f3fe8e3e 100644 --- a/tests/unittests/test_preferences.c +++ b/tests/unittests/test_preferences.c @@ -8,27 +8,30 @@ #include "config/preferences.h" -void statuses_console_defaults_to_all(void **state) +void +statuses_console_defaults_to_all(void** state) { - char *setting = prefs_get_string(PREF_STATUSES_CONSOLE); + char* setting = prefs_get_string(PREF_STATUSES_CONSOLE); assert_non_null(setting); assert_string_equal("all", setting); g_free(setting); } -void statuses_chat_defaults_to_all(void **state) +void +statuses_chat_defaults_to_all(void** state) { - char *setting = prefs_get_string(PREF_STATUSES_CHAT); + char* setting = prefs_get_string(PREF_STATUSES_CHAT); assert_non_null(setting); assert_string_equal("all", setting); g_free(setting); } -void statuses_muc_defaults_to_all(void **state) +void +statuses_muc_defaults_to_all(void** state) { - char *setting = prefs_get_string(PREF_STATUSES_MUC); + char* setting = prefs_get_string(PREF_STATUSES_MUC); assert_non_null(setting); assert_string_equal("all", setting); diff --git a/tests/unittests/test_preferences.h b/tests/unittests/test_preferences.h index 5bf79a6a..84438e95 100644 --- a/tests/unittests/test_preferences.h +++ b/tests/unittests/test_preferences.h @@ -1,3 +1,3 @@ -void statuses_console_defaults_to_all(void **state); -void statuses_chat_defaults_to_all(void **state); -void statuses_muc_defaults_to_all(void **state); +void statuses_console_defaults_to_all(void** state); +void statuses_chat_defaults_to_all(void** state); +void statuses_muc_defaults_to_all(void** state); diff --git a/tests/unittests/test_roster_list.c b/tests/unittests/test_roster_list.c index c8af855a..b46e7b57 100644 --- a/tests/unittests/test_roster_list.c +++ b/tests/unittests/test_roster_list.c @@ -9,32 +9,35 @@ #include "xmpp/contact.h" #include "xmpp/roster_list.h" -void empty_list_when_none_added(void **state) +void +empty_list_when_none_added(void** state) { roster_create(); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); assert_null(list); g_slist_free(list); roster_destroy(); } -void contains_one_element(void **state) +void +contains_one_element(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); assert_int_equal(1, g_slist_length(list)); g_slist_free(list); roster_destroy(); } -void first_element_correct(void **state) +void +first_element_correct(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact james = list->data; assert_string_equal("James", p_contact_barejid(james)); @@ -43,12 +46,13 @@ void first_element_correct(void **state) roster_destroy(); } -void contains_two_elements(void **state) +void +contains_two_elements(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); assert_int_equal(2, g_slist_length(list)); @@ -56,12 +60,13 @@ void contains_two_elements(void **state) roster_destroy(); } -void first_and_second_elements_correct(void **state) +void +first_and_second_elements_correct(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact first = list->data; PContact second = (g_slist_next(list))->data; @@ -73,13 +78,14 @@ void first_and_second_elements_correct(void **state) roster_destroy(); } -void contains_three_elements(void **state) +void +contains_three_elements(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); assert_int_equal(3, g_slist_length(list)); @@ -87,13 +93,14 @@ void contains_three_elements(void **state) roster_destroy(); } -void first_three_elements_correct(void **state) +void +first_three_elements_correct(void** state) { roster_create(); roster_add("Bob", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact bob = list->data; PContact dave = (g_slist_next(list))->data; PContact james = (g_slist_next(g_slist_next(list)))->data; @@ -106,14 +113,15 @@ void first_three_elements_correct(void **state) roster_destroy(); } -void add_twice_at_beginning_adds_once(void **state) +void +add_twice_at_beginning_adds_once(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact first = list->data; PContact second = (g_slist_next(list))->data; PContact third = (g_slist_next(g_slist_next(list)))->data; @@ -127,14 +135,15 @@ void add_twice_at_beginning_adds_once(void **state) roster_destroy(); } -void add_twice_in_middle_adds_once(void **state) +void +add_twice_in_middle_adds_once(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact first = list->data; PContact second = (g_slist_next(list))->data; PContact third = (g_slist_next(g_slist_next(list)))->data; @@ -148,14 +157,15 @@ void add_twice_in_middle_adds_once(void **state) roster_destroy(); } -void add_twice_at_end_adds_once(void **state) +void +add_twice_at_end_adds_once(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); roster_add("James", NULL, NULL, NULL, FALSE); - GSList *list = roster_get_contacts(ROSTER_ORD_NAME); + GSList* list = roster_get_contacts(ROSTER_ORD_NAME); PContact first = list->data; PContact second = (g_slist_next(list))->data; PContact third = (g_slist_next(g_slist_next(list)))->data; @@ -169,84 +179,91 @@ void add_twice_at_end_adds_once(void **state) roster_destroy(); } -void find_first_exists(void **state) +void +find_first_exists(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *search = strdup("B"); + char* search = strdup("B"); - char *result = roster_contact_autocomplete(search, FALSE, NULL); + char* result = roster_contact_autocomplete(search, FALSE, NULL); assert_string_equal("Bob", result); free(result); free(search); roster_destroy(); } -void find_second_exists(void **state) +void +find_second_exists(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result = roster_contact_autocomplete("Dav", FALSE, NULL); + char* result = roster_contact_autocomplete("Dav", FALSE, NULL); assert_string_equal("Dave", result); free(result); roster_destroy(); } -void find_third_exists(void **state) +void +find_third_exists(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result = roster_contact_autocomplete("Ja", FALSE, NULL); + char* result = roster_contact_autocomplete("Ja", FALSE, NULL); assert_string_equal("James", result); free(result); roster_destroy(); } -void find_returns_null(void **state) +void +find_returns_null(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Dave", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result = roster_contact_autocomplete("Mike", FALSE, NULL); + char* result = roster_contact_autocomplete("Mike", FALSE, NULL); assert_null(result); roster_destroy(); } -void find_on_empty_returns_null(void **state) +void +find_on_empty_returns_null(void** state) { roster_create(); - char *result = roster_contact_autocomplete("James", FALSE, NULL); + char* result = roster_contact_autocomplete("James", FALSE, NULL); assert_null(result); roster_destroy(); } -void find_twice_returns_second_when_two_match(void **state) +void +find_twice_returns_second_when_two_match(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Jamie", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result1 = roster_contact_autocomplete("Jam", FALSE, NULL); - char *result2 = roster_contact_autocomplete(result1, FALSE, NULL); + char* result1 = roster_contact_autocomplete("Jam", FALSE, NULL); + char* result2 = roster_contact_autocomplete(result1, FALSE, NULL); assert_string_equal("Jamie", result2); free(result1); free(result2); roster_destroy(); } -void find_five_times_finds_fifth(void **state) +void +find_five_times_finds_fifth(void** state) { roster_create(); roster_add("Jama", NULL, NULL, NULL, FALSE); @@ -260,11 +277,11 @@ void find_five_times_finds_fifth(void **state) roster_add("Jamy", NULL, NULL, NULL, FALSE); roster_add("Jamz", NULL, NULL, NULL, FALSE); - char *result1 = roster_contact_autocomplete("Jam", FALSE, NULL); - char *result2 = roster_contact_autocomplete(result1, FALSE, NULL); - char *result3 = roster_contact_autocomplete(result2, FALSE, NULL); - char *result4 = roster_contact_autocomplete(result3, FALSE, NULL); - char *result5 = roster_contact_autocomplete(result4, FALSE, NULL); + char* result1 = roster_contact_autocomplete("Jam", FALSE, NULL); + char* result2 = roster_contact_autocomplete(result1, FALSE, NULL); + char* result3 = roster_contact_autocomplete(result2, FALSE, NULL); + char* result4 = roster_contact_autocomplete(result3, FALSE, NULL); + char* result5 = roster_contact_autocomplete(result4, FALSE, NULL); assert_string_equal("Jamo", result5); free(result1); free(result2); @@ -274,46 +291,49 @@ void find_five_times_finds_fifth(void **state) roster_destroy(); } -void find_twice_returns_first_when_two_match_and_reset(void **state) +void +find_twice_returns_first_when_two_match_and_reset(void** state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); roster_add("Jamie", NULL, NULL, NULL, FALSE); roster_add("Bob", NULL, NULL, NULL, FALSE); - char *result1 = roster_contact_autocomplete("Jam", FALSE, NULL); + char* result1 = roster_contact_autocomplete("Jam", FALSE, NULL); roster_reset_search_attempts(); - char *result2 = roster_contact_autocomplete(result1, FALSE, NULL); + char* result2 = roster_contact_autocomplete(result1, FALSE, NULL); assert_string_equal("James", result2); free(result1); free(result2); roster_destroy(); } -void add_contact_with_no_group(void **state) +void +add_contact_with_no_group(void** state) { roster_create(); roster_add("person@server.org", NULL, NULL, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 0); g_list_free_full(groups_res, free); roster_destroy(); } -void add_contact_with_group(void **state) +void +add_contact_with_group(void** state) { roster_create(); - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("friends")); roster_add("person@server.org", NULL, groups, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 1); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); @@ -321,19 +341,20 @@ void add_contact_with_group(void **state) roster_destroy(); } -void add_contact_with_two_groups(void **state) +void +add_contact_with_two_groups(void** state) { roster_create(); - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("friends")); groups = g_slist_append(groups, strdup("work")); roster_add("person@server.org", NULL, groups, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 2); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); @@ -344,20 +365,21 @@ void add_contact_with_two_groups(void **state) roster_destroy(); } -void add_contact_with_three_groups(void **state) +void +add_contact_with_three_groups(void** state) { roster_create(); - GSList *groups = NULL; + GSList* groups = NULL; groups = g_slist_append(groups, strdup("friends")); groups = g_slist_append(groups, strdup("work")); groups = g_slist_append(groups, strdup("stuff")); roster_add("person@server.org", NULL, groups, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 3); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); @@ -371,17 +393,18 @@ void add_contact_with_three_groups(void **state) roster_destroy(); } -void add_contact_with_three_groups_update_adding_two(void **state) +void +add_contact_with_three_groups_update_adding_two(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("work")); groups2 = g_slist_append(groups2, strdup("stuff")); @@ -389,10 +412,10 @@ void add_contact_with_three_groups_update_adding_two(void **state) groups2 = g_slist_append(groups2, strdup("people")); roster_update("person@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 5); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); @@ -412,25 +435,26 @@ void add_contact_with_three_groups_update_adding_two(void **state) roster_destroy(); } -void add_contact_with_three_groups_update_removing_one(void **state) +void +add_contact_with_three_groups_update_removing_one(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("stuff")); roster_update("person@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 2); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "friends"); found = g_list_find_custom(groups_res, "stuff", (GCompareFunc)g_strcmp0); @@ -441,24 +465,25 @@ void add_contact_with_three_groups_update_removing_one(void **state) roster_destroy(); } -void add_contact_with_three_groups_update_removing_two(void **state) +void +add_contact_with_three_groups_update_removing_two(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("stuff")); roster_update("person@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 1); - GList *found = g_list_find_custom(groups_res, "stuff", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "stuff", (GCompareFunc)g_strcmp0); assert_true(found != NULL); assert_string_equal(found->data, "stuff"); @@ -466,11 +491,12 @@ void add_contact_with_three_groups_update_removing_two(void **state) roster_destroy(); } -void add_contact_with_three_groups_update_removing_three(void **state) +void +add_contact_with_three_groups_update_removing_three(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); @@ -478,32 +504,33 @@ void add_contact_with_three_groups_update_removing_three(void **state) roster_update("person@server.org", NULL, NULL, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 0); g_list_free_full(groups_res, free); roster_destroy(); } -void add_contact_with_three_groups_update_two_new(void **state) +void +add_contact_with_three_groups_update_two_new(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("newfriends")); groups2 = g_slist_append(groups2, strdup("somepeople")); roster_update("person@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 2); - GList *found = g_list_find_custom(groups_res, "newfriends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "newfriends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); found = g_list_find_custom(groups_res, "somepeople", (GCompareFunc)g_strcmp0); assert_true(found != NULL); @@ -512,11 +539,12 @@ void add_contact_with_three_groups_update_two_new(void **state) roster_destroy(); } -void add_remove_contact_groups(void **state) +void +add_remove_contact_groups(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); @@ -524,32 +552,33 @@ void add_remove_contact_groups(void **state) roster_remove("person@server.org", "person@server.org"); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 0); g_list_free_full(groups_res, free); roster_destroy(); } -void add_contacts_with_different_groups(void **state) +void +add_contacts_with_different_groups(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("newfriends")); groups2 = g_slist_append(groups2, strdup("somepeople")); roster_add("bob@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 5); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); assert_true(found != NULL); @@ -564,26 +593,27 @@ void add_contacts_with_different_groups(void **state) roster_destroy(); } -void add_contacts_with_same_groups(void **state) +void +add_contacts_with_same_groups(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("work")); groups2 = g_slist_append(groups2, strdup("stuff")); roster_add("bob@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 3); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); assert_true(found != NULL); @@ -594,26 +624,27 @@ void add_contacts_with_same_groups(void **state) roster_destroy(); } -void add_contacts_with_overlapping_groups(void **state) +void +add_contacts_with_overlapping_groups(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("work")); groups2 = g_slist_append(groups2, strdup("different")); roster_add("bob@server.org", NULL, groups2, NULL, FALSE); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 4); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); assert_true(found != NULL); @@ -626,17 +657,18 @@ void add_contacts_with_overlapping_groups(void **state) roster_destroy(); } -void remove_contact_with_remaining_in_group(void **state) +void +remove_contact_with_remaining_in_group(void** state) { roster_create(); - GSList *groups1 = NULL; + GSList* groups1 = NULL; groups1 = g_slist_append(groups1, strdup("friends")); groups1 = g_slist_append(groups1, strdup("work")); groups1 = g_slist_append(groups1, strdup("stuff")); roster_add("person@server.org", NULL, groups1, NULL, FALSE); - GSList *groups2 = NULL; + GSList* groups2 = NULL; groups2 = g_slist_append(groups2, strdup("friends")); groups2 = g_slist_append(groups2, strdup("work")); groups2 = g_slist_append(groups2, strdup("different")); @@ -644,10 +676,10 @@ void remove_contact_with_remaining_in_group(void **state) roster_remove("bob@server.org", "bob@server.org"); - GList *groups_res = roster_get_groups(); + GList* groups_res = roster_get_groups(); assert_int_equal(g_list_length(groups_res), 3); - GList *found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); + GList* found = g_list_find_custom(groups_res, "friends", (GCompareFunc)g_strcmp0); assert_true(found != NULL); found = g_list_find_custom(groups_res, "work", (GCompareFunc)g_strcmp0); assert_true(found != NULL); diff --git a/tests/unittests/test_roster_list.h b/tests/unittests/test_roster_list.h index 464ecd55..b9874fec 100644 --- a/tests/unittests/test_roster_list.h +++ b/tests/unittests/test_roster_list.h @@ -1,32 +1,32 @@ -void empty_list_when_none_added(void **state); -void contains_one_element(void **state); -void first_element_correct(void **state); -void contains_two_elements(void **state); -void first_and_second_elements_correct(void **state); -void contains_three_elements(void **state); -void first_three_elements_correct(void **state); -void add_twice_at_beginning_adds_once(void **state); -void add_twice_in_middle_adds_once(void **state); -void add_twice_at_end_adds_once(void **state); -void find_first_exists(void **state); -void find_second_exists(void **state); -void find_third_exists(void **state); -void find_returns_null(void **state); -void find_on_empty_returns_null(void **state); -void find_twice_returns_second_when_two_match(void **state); -void find_five_times_finds_fifth(void **state); -void find_twice_returns_first_when_two_match_and_reset(void **state); -void add_contact_with_no_group(void **state); -void add_contact_with_group(void **state); -void add_contact_with_two_groups(void **state); -void add_contact_with_three_groups(void **state); -void add_contact_with_three_groups_update_adding_two(void **state); -void add_contact_with_three_groups_update_removing_one(void **state); -void add_contact_with_three_groups_update_removing_two(void **state); -void add_contact_with_three_groups_update_removing_three(void **state); -void add_contact_with_three_groups_update_two_new(void **state); -void add_remove_contact_groups(void **state); -void add_contacts_with_different_groups(void **state); -void add_contacts_with_same_groups(void **state); -void add_contacts_with_overlapping_groups(void **state); -void remove_contact_with_remaining_in_group(void **state); +void empty_list_when_none_added(void** state); +void contains_one_element(void** state); +void first_element_correct(void** state); +void contains_two_elements(void** state); +void first_and_second_elements_correct(void** state); +void contains_three_elements(void** state); +void first_three_elements_correct(void** state); +void add_twice_at_beginning_adds_once(void** state); +void add_twice_in_middle_adds_once(void** state); +void add_twice_at_end_adds_once(void** state); +void find_first_exists(void** state); +void find_second_exists(void** state); +void find_third_exists(void** state); +void find_returns_null(void** state); +void find_on_empty_returns_null(void** state); +void find_twice_returns_second_when_two_match(void** state); +void find_five_times_finds_fifth(void** state); +void find_twice_returns_first_when_two_match_and_reset(void** state); +void add_contact_with_no_group(void** state); +void add_contact_with_group(void** state); +void add_contact_with_two_groups(void** state); +void add_contact_with_three_groups(void** state); +void add_contact_with_three_groups_update_adding_two(void** state); +void add_contact_with_three_groups_update_removing_one(void** state); +void add_contact_with_three_groups_update_removing_two(void** state); +void add_contact_with_three_groups_update_removing_three(void** state); +void add_contact_with_three_groups_update_two_new(void** state); +void add_remove_contact_groups(void** state); +void add_contacts_with_different_groups(void** state); +void add_contacts_with_same_groups(void** state); +void add_contacts_with_overlapping_groups(void** state); +void remove_contact_with_remaining_in_group(void** state); diff --git a/tests/unittests/test_server_events.c b/tests/unittests/test_server_events.c index 54688dec..4ecedace 100644 --- a/tests/unittests/test_server_events.c +++ b/tests/unittests/test_server_events.c @@ -17,15 +17,16 @@ #include "plugins/plugins.h" #include "ui/window_list.h" -void console_shows_online_presence_when_set_online(void **state) +void +console_shows_online_presence_when_set_online(void** state) { prefs_set_string(PREF_STATUSES_CONSOLE, "online"); plugins_init(); roster_create(); roster_process_pending_presence(); - char *barejid = "test1@server"; + char* barejid = "test1@server"; roster_add(barejid, "bob", NULL, "both", FALSE); - Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); + Resource* resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); expect_memory(ui_contact_online, barejid, barejid, sizeof(barejid)); expect_memory(ui_contact_online, resource, resource, sizeof(resource)); @@ -37,15 +38,16 @@ void console_shows_online_presence_when_set_online(void **state) plugins_shutdown(); } -void console_shows_online_presence_when_set_all(void **state) +void +console_shows_online_presence_when_set_all(void** state) { prefs_set_string(PREF_STATUSES_CONSOLE, "all"); plugins_init(); roster_create(); roster_process_pending_presence(); - char *barejid = "test1@server"; + char* barejid = "test1@server"; roster_add(barejid, "bob", NULL, "both", FALSE); - Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); + Resource* resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); expect_memory(ui_contact_online, barejid, barejid, sizeof(barejid)); expect_memory(ui_contact_online, resource, resource, sizeof(resource)); @@ -57,15 +59,16 @@ void console_shows_online_presence_when_set_all(void **state) plugins_shutdown(); } -void console_shows_dnd_presence_when_set_all(void **state) +void +console_shows_dnd_presence_when_set_all(void** state) { prefs_set_string(PREF_STATUSES_CONSOLE, "all"); plugins_init(); roster_create(); roster_process_pending_presence(); - char *barejid = "test1@server"; + char* barejid = "test1@server"; roster_add(barejid, "bob", NULL, "both", FALSE); - Resource *resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); + Resource* resource = resource_new("resource", RESOURCE_ONLINE, NULL, 10); expect_memory(ui_contact_online, barejid, barejid, sizeof(barejid)); expect_memory(ui_contact_online, resource, resource, sizeof(resource)); @@ -77,23 +80,24 @@ void console_shows_dnd_presence_when_set_all(void **state) plugins_shutdown(); } -void handle_offline_removes_chat_session(void **state) +void +handle_offline_removes_chat_session(void** state) { plugins_init(); roster_create(); roster_process_pending_presence(); chat_sessions_init(); - char *barejid = "friend@server.chat.com"; - char *resource = "home"; + char* barejid = "friend@server.chat.com"; + char* resource = "home"; roster_add(barejid, "bob", NULL, "both", FALSE); - Resource *resourcep = resource_new(resource, RESOURCE_ONLINE, NULL, 10); + Resource* resourcep = resource_new(resource, RESOURCE_ONLINE, NULL, 10); roster_update_presence(barejid, resourcep, NULL); chat_session_recipient_active(barejid, resource, FALSE); - ProfConsoleWin *console = malloc(sizeof(ProfConsoleWin)); + ProfConsoleWin* console = malloc(sizeof(ProfConsoleWin)); will_return(win_create_console, &console->window); wins_init(); sv_ev_contact_offline(barejid, resource, NULL); - ChatSession *session = chat_session_get(barejid); + ChatSession* session = chat_session_get(barejid); assert_null(session); @@ -102,7 +106,8 @@ void handle_offline_removes_chat_session(void **state) plugins_shutdown(); } -void lost_connection_clears_chat_sessions(void **state) +void +lost_connection_clears_chat_sessions(void** state) { roster_create(); roster_process_pending_presence(); @@ -113,8 +118,8 @@ void lost_connection_clears_chat_sessions(void **state) sv_ev_lost_connection(); - ChatSession *session1 = chat_session_get("bob@server.org"); - ChatSession *session2 = chat_session_get("steve@server.org"); + ChatSession* session1 = chat_session_get("bob@server.org"); + ChatSession* session2 = chat_session_get("steve@server.org"); assert_null(session1); assert_null(session2); } diff --git a/tests/unittests/test_server_events.h b/tests/unittests/test_server_events.h index 81a436f4..1cac6799 100644 --- a/tests/unittests/test_server_events.h +++ b/tests/unittests/test_server_events.h @@ -1,14 +1,14 @@ -void console_doesnt_show_online_presence_when_set_none(void **state); -void console_shows_online_presence_when_set_online(void **state); -void console_shows_online_presence_when_set_all(void **state); -void console_doesnt_show_dnd_presence_when_set_none(void **state); -void console_doesnt_show_dnd_presence_when_set_online(void **state); -void console_shows_dnd_presence_when_set_all(void **state); -void handle_message_error_when_no_recipient(void **state); -void handle_message_error_when_recipient_cancel(void **state); -void handle_message_error_when_recipient_cancel_disables_chat_session(void **state); -void handle_message_error_when_recipient_and_no_type(void **state); -void handle_presence_error_when_no_recipient(void **state); -void handle_presence_error_when_from_recipient(void **state); -void handle_offline_removes_chat_session(void **state); -void lost_connection_clears_chat_sessions(void **state); +void console_doesnt_show_online_presence_when_set_none(void** state); +void console_shows_online_presence_when_set_online(void** state); +void console_shows_online_presence_when_set_all(void** state); +void console_doesnt_show_dnd_presence_when_set_none(void** state); +void console_doesnt_show_dnd_presence_when_set_online(void** state); +void console_shows_dnd_presence_when_set_all(void** state); +void handle_message_error_when_no_recipient(void** state); +void handle_message_error_when_recipient_cancel(void** state); +void handle_message_error_when_recipient_cancel_disables_chat_session(void** state); +void handle_message_error_when_recipient_and_no_type(void** state); +void handle_presence_error_when_no_recipient(void** state); +void handle_presence_error_when_from_recipient(void** state); +void handle_offline_removes_chat_session(void** state); +void lost_connection_clears_chat_sessions(void** state); diff --git a/tests/unittests/tools/stub_http_upload.c b/tests/unittests/tools/stub_http_upload.c index 3cfb1c5d..25a81708 100644 --- a/tests/unittests/tools/stub_http_upload.c +++ b/tests/unittests/tools/stub_http_upload.c @@ -7,26 +7,39 @@ // forward -> ui/win_types.h typedef struct prof_win_t ProfWin; -typedef struct http_upload_t { - char *filename; +typedef struct http_upload_t +{ + char* filename; off_t filesize; curl_off_t bytes_sent; - char *mime_type; - char *get_url; - char *put_url; - ProfWin *window; + char* mime_type; + char* get_url; + char* put_url; + ProfWin* window; pthread_t worker; int cancel; } HTTPUpload; //GSList *upload_processes; -void* http_file_put(void *userdata) { return NULL; } - -char* file_mime_type(const char* const file_name) { return NULL; } -off_t file_size(const char* const file_name) { return 0; } - -void http_upload_cancel_processes() {}; -void http_upload_add_upload() {}; +void* +http_file_put(void* userdata) +{ + return NULL; +} + +char* +file_mime_type(const char* const file_name) +{ + return NULL; +} +off_t +file_size(const char* const file_name) +{ + return 0; +} + +void http_upload_cancel_processes(){}; +void http_upload_add_upload(){}; #endif diff --git a/tests/unittests/ui/stub_ui.c b/tests/unittests/ui/stub_ui.c index e14daa01..8b30f718 100644 --- a/tests/unittests/ui/stub_ui.c +++ b/tests/unittests/ui/stub_ui.c @@ -19,7 +19,7 @@ static char output[256]; void -expect_cons_show(char *expected) +expect_cons_show(char* expected) { expect_string(cons_show, output, expected); } @@ -31,7 +31,7 @@ expect_any_cons_show(void) } void -expect_cons_show_error(char *expected) +expect_cons_show_error(char* expected) { expect_string(cons_show_error, output, expected); } @@ -43,68 +43,142 @@ expect_any_cons_show_error(void) } void -expect_win_println(char *message) +expect_win_println(char* message) { expect_string(win_println, output, message); } // stubs -void ui_init(void) {} -void ui_load_colours(void) {} -void ui_update(void) {} -void ui_close(void) {} -void ui_redraw(void) {} -void ui_resize(void) {} +void +ui_init(void) +{ +} +void +ui_load_colours(void) +{ +} +void +ui_update(void) +{ +} +void +ui_close(void) +{ +} +void +ui_redraw(void) +{ +} +void +ui_resize(void) +{ +} -void ui_focus_win(ProfWin *win) {} +void +ui_focus_win(ProfWin* win) +{ +} #ifdef HAVE_LIBOTR -void chatwin_otr_secured(ProfChatWin *chatwin, gboolean trusted) {} -void chatwin_otr_unsecured(ProfChatWin *chatwin) {} -void chatwin_otr_trust(ProfChatWin *chatwin) {} -void chatwin_otr_untrust(ProfChatWin *chatwin) {} -void chatwin_otr_smp_event(ProfChatWin *chatwin, prof_otr_smp_event_t event, void *data) {} +void +chatwin_otr_secured(ProfChatWin* chatwin, gboolean trusted) +{ +} +void +chatwin_otr_unsecured(ProfChatWin* chatwin) +{ +} +void +chatwin_otr_trust(ProfChatWin* chatwin) +{ +} +void +chatwin_otr_untrust(ProfChatWin* chatwin) +{ +} +void +chatwin_otr_smp_event(ProfChatWin* chatwin, prof_otr_smp_event_t event, void* data) +{ +} #endif -void chatwin_set_enctext(ProfChatWin *chatwin, const char *const enctext) {} -void chatwin_unset_enctext(ProfChatWin *chatwin) {} -void chatwin_set_incoming_char(ProfChatWin *chatwin, const char *const ch) {} -void chatwin_unset_incoming_char(ProfChatWin *chatwin) {} -void chatwin_set_outgoing_char(ProfChatWin *chatwin, const char *const ch) {} -void chatwin_unset_outgoing_char(ProfChatWin *chatwin) {} +void +chatwin_set_enctext(ProfChatWin* chatwin, const char* const enctext) +{ +} +void +chatwin_unset_enctext(ProfChatWin* chatwin) +{ +} +void +chatwin_set_incoming_char(ProfChatWin* chatwin, const char* const ch) +{ +} +void +chatwin_unset_incoming_char(ProfChatWin* chatwin) +{ +} +void +chatwin_set_outgoing_char(ProfChatWin* chatwin, const char* const ch) +{ +} +void +chatwin_unset_outgoing_char(ProfChatWin* chatwin) +{ +} -void ui_sigwinch_handler(int sig) {} +void +ui_sigwinch_handler(int sig) +{ +} -unsigned long ui_get_idle_time(void) +unsigned long +ui_get_idle_time(void) { return 0; } -void ui_reset_idle_time(void) {} +void +ui_reset_idle_time(void) +{ +} -ProfChatWin* chatwin_new(const char * const barejid) +ProfChatWin* +chatwin_new(const char* const barejid) { return NULL; } -void ui_print_system_msg_from_recipient(const char * const barejid, const char *message) {} +void +ui_print_system_msg_from_recipient(const char* const barejid, const char* message) +{ +} -void ui_close_connected_win(int index) {} -int ui_close_all_wins(void) +void +ui_close_connected_win(int index) +{ +} +int +ui_close_all_wins(void) { return 0; } -int ui_close_read_wins(void) +int +ui_close_read_wins(void) { return 0; } // current window actions -void ui_clear_current(void) {} +void +ui_clear_current(void) +{ +} -void ui_current_print_line(const char * const msg, ...) +void +ui_current_print_line(const char* const msg, ...) { va_list args; va_start(args, msg); @@ -113,7 +187,8 @@ void ui_current_print_line(const char * const msg, ...) va_end(args); } -void ui_current_print_formatted_line(const char show_char, int attrs, const char * const msg, ...) +void +ui_current_print_formatted_line(const char show_char, int attrs, const char* const msg, ...) { check_expected(show_char); check_expected(attrs); @@ -124,195 +199,506 @@ void ui_current_print_formatted_line(const char show_char, int attrs, const char va_end(args); } -void ui_close_win(int index) {} +void +ui_close_win(int index) +{ +} -int ui_win_unread(int index) +int +ui_win_unread(int index) { return 0; } -char * ui_ask_password(void) +char* +ui_ask_password(void) { - return mock_ptr_type(char *); + return mock_ptr_type(char*); } -char *ui_get_line(void) +char* +ui_get_line(void) { return NULL; } -void xmlwin_show(ProfXMLWin *xmlwin, const char * const msg) {} +void +xmlwin_show(ProfXMLWin* xmlwin, const char* const msg) +{ +} // ui events -void ui_contact_online(char *barejid, Resource *resource, GDateTime *last_activity) +void +ui_contact_online(char* barejid, Resource* resource, GDateTime* last_activity) { check_expected(barejid); check_expected(resource); check_expected(last_activity); } -void ui_contact_typing(const char * const barejid, const char * const resource) {} -void chatwin_incoming_msg(ProfChatWin *chatwin, ProfMessage *message, gboolean win_created) {} -void chatwin_receipt_received(ProfChatWin *chatwin, const char * const id) {} - -void privwin_incoming_msg(ProfPrivateWin *privatewin, ProfMessage *message) {} - -void ui_disconnected(void) {} -void chatwin_recipient_gone(ProfChatWin *chatwin) {} - -void chatwin_outgoing_msg(ProfChatWin *chatwin, const char *const message, char *id, prof_enc_t enc_mode, gboolean request_receipt, const char *const replace_id) {} -void chatwin_outgoing_carbon(ProfChatWin *chatwin, ProfMessage *message) {} -void privwin_outgoing_msg(ProfPrivateWin *privwin, const char * const message) {} - -void privwin_occupant_offline(ProfPrivateWin *privwin) {} -void privwin_occupant_kicked(ProfPrivateWin *privwin, const char *const actor, const char *const reason) {} -void privwin_occupant_banned(ProfPrivateWin *privwin, const char *const actor, const char *const reason) {} -void privwin_occupant_online(ProfPrivateWin *privwin) {} -void privwin_message_occupant_offline(ProfPrivateWin *privwin) {} - -void privwin_message_left_room(ProfPrivateWin *privwin) {} - -void ui_room_join(const char * const roomjid, gboolean focus) {} -void ui_switch_to_room(const char * const roomjid) {} - -void mucwin_role_change(ProfMucWin *mucwin, const char * const role, const char * const actor, - const char * const reason) {} -void mucwin_affiliation_change(ProfMucWin *mucwin, const char * const affiliation, const char * const actor, - const char * const reason) {} -void mucwin_role_and_affiliation_change(ProfMucWin *mucwin, const char * const role, - const char * const affiliation, const char * const actor, const char * const reason) {} -void mucwin_occupant_role_change(ProfMucWin *mucwin, const char * const nick, const char * const role, - const char * const actor, const char * const reason) {} -void mucwin_occupant_affiliation_change(ProfMucWin *mucwin, const char * const nick, const char * const affiliation, - const char * const actor, const char * const reason) {} -void mucwin_occupant_role_and_affiliation_change(ProfMucWin *mucwin, const char * const nick, const char * const role, - const char * const affiliation, const char * const actor, const char * const reason) {} -void mucwin_roster(ProfMucWin *mucwin, GList *occupants, const char * const presence) {} -void mucwin_history(ProfMucWin *mucwin, const ProfMessage *const message) {} -void mucwin_incoming_msg(ProfMucWin *mucwin, const ProfMessage *const message, GSList *mentions, GList *triggers, gboolean filter_reflection) {} -void mucwin_outgoing_msg(ProfMucWin *mucwin, const char *const message, const char *const id, prof_enc_t enc_mode, const char *const replace_id) {} -void mucwin_subject(ProfMucWin *mucwin, const char * const nick, const char * const subject) {} -void mucwin_requires_config(ProfMucWin *mucwin) {} -void ui_room_destroy(const char * const roomjid) {} -void mucwin_info(ProfMucWin *mucwin) {} -void mucwin_show_role_list(ProfMucWin *mucwin, muc_role_t role) {} -void mucwin_show_affiliation_list(ProfMucWin *mucwin, muc_affiliation_t affiliation) {} -void mucwin_room_info_error(ProfMucWin *mucwin, const char * const error) {} -void mucwin_room_disco_info(ProfMucWin *mucwin, GSList *identities, GSList *features) {} -void ui_room_destroyed(const char * const roomjid, const char * const reason, const char * const new_jid, - const char * const password) {} -void ui_room_kicked(const char * const roomjid, const char * const actor, const char * const reason) {} -void mucwin_occupant_kicked(ProfMucWin *mucwin, const char * const nick, const char * const actor, - const char * const reason) {} -void ui_room_banned(const char * const roomjid, const char * const actor, const char * const reason) {} -void mucwin_occupant_banned(ProfMucWin *mucwin, const char * const nick, const char * const actor, - const char * const reason) {} -void ui_leave_room(const char * const roomjid) {} -void mucwin_broadcast(ProfMucWin *mucwin, const char * const message) {} -void mucwin_occupant_offline(ProfMucWin *mucwin, const char * const nick) {} -void mucwin_occupant_online(ProfMucWin *mucwin, const char * const nick, const char * const roles, - const char * const affiliation, const char * const show, const char * const status) {} -void mucwin_occupant_nick_change(ProfMucWin *mucwin, const char * const old_nick, const char * const nick) {} -void mucwin_nick_change(ProfMucWin *mucwin, const char * const nick) {} -void mucwin_occupant_presence(ProfMucWin *mucwin, const char * const nick, const char * const show, - const char * const status) {} -void mucwin_update_occupants(ProfMucWin *mucwin) {} -void mucwin_show_occupants(ProfMucWin *mucwin) {} -void mucwin_hide_occupants(ProfMucWin *mucwin) {} -void mucwin_set_enctext(ProfMucWin *mucwin, const char *const enctext) {} -void mucwin_unset_enctext(ProfMucWin *mucwin) {} -void mucwin_set_message_char(ProfMucWin *mucwin, const char *const ch) {} -void mucwin_unset_message_char(ProfMucWin *mucwin) {} - -void ui_show_roster(void) {} -void ui_hide_roster(void) {} -void ui_roster_add(const char * const barejid, const char * const name) {} -void ui_roster_remove(const char * const barejid) {} -void ui_contact_already_in_group(const char * const contact, const char * const group) {} -void ui_contact_not_in_group(const char * const contact, const char * const group) {} -void ui_group_added(const char * const contact, const char * const group) {} -void ui_group_removed(const char * const contact, const char * const group) {} -void chatwin_contact_online(ProfChatWin *chatwin, Resource *resource, GDateTime *last_activity) {} -void chatwin_contact_offline(ProfChatWin *chatwin, char *resource, char *status) {} - -void ui_contact_offline(char *barejid, char *resource, char *status) {} - -void ui_handle_recipient_error(const char * const recipient, const char * const err_msg) +void +ui_contact_typing(const char* const barejid, const char* const resource) +{ +} +void +chatwin_incoming_msg(ProfChatWin* chatwin, ProfMessage* message, gboolean win_created) +{ +} +void +chatwin_receipt_received(ProfChatWin* chatwin, const char* const id) +{ +} + +void +privwin_incoming_msg(ProfPrivateWin* privatewin, ProfMessage* message) +{ +} + +void +ui_disconnected(void) +{ +} +void +chatwin_recipient_gone(ProfChatWin* chatwin) +{ +} + +void +chatwin_outgoing_msg(ProfChatWin* chatwin, const char* const message, char* id, prof_enc_t enc_mode, gboolean request_receipt, const char* const replace_id) +{ +} +void +chatwin_outgoing_carbon(ProfChatWin* chatwin, ProfMessage* message) +{ +} +void +privwin_outgoing_msg(ProfPrivateWin* privwin, const char* const message) +{ +} + +void +privwin_occupant_offline(ProfPrivateWin* privwin) +{ +} +void +privwin_occupant_kicked(ProfPrivateWin* privwin, const char* const actor, const char* const reason) +{ +} +void +privwin_occupant_banned(ProfPrivateWin* privwin, const char* const actor, const char* const reason) +{ +} +void +privwin_occupant_online(ProfPrivateWin* privwin) +{ +} +void +privwin_message_occupant_offline(ProfPrivateWin* privwin) +{ +} + +void +privwin_message_left_room(ProfPrivateWin* privwin) +{ +} + +void +ui_room_join(const char* const roomjid, gboolean focus) +{ +} +void +ui_switch_to_room(const char* const roomjid) +{ +} + +void +mucwin_role_change(ProfMucWin* mucwin, const char* const role, const char* const actor, + const char* const reason) +{ +} +void +mucwin_affiliation_change(ProfMucWin* mucwin, const char* const affiliation, const char* const actor, + const char* const reason) +{ +} +void +mucwin_role_and_affiliation_change(ProfMucWin* mucwin, const char* const role, + const char* const affiliation, const char* const actor, const char* const reason) +{ +} +void +mucwin_occupant_role_change(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const actor, const char* const reason) +{ +} +void +mucwin_occupant_affiliation_change(ProfMucWin* mucwin, const char* const nick, const char* const affiliation, + const char* const actor, const char* const reason) +{ +} +void +mucwin_occupant_role_and_affiliation_change(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const affiliation, const char* const actor, const char* const reason) +{ +} +void +mucwin_roster(ProfMucWin* mucwin, GList* occupants, const char* const presence) +{ +} +void +mucwin_history(ProfMucWin* mucwin, const ProfMessage* const message) +{ +} +void +mucwin_incoming_msg(ProfMucWin* mucwin, const ProfMessage* const message, GSList* mentions, GList* triggers, gboolean filter_reflection) +{ +} +void +mucwin_outgoing_msg(ProfMucWin* mucwin, const char* const message, const char* const id, prof_enc_t enc_mode, const char* const replace_id) +{ +} +void +mucwin_subject(ProfMucWin* mucwin, const char* const nick, const char* const subject) +{ +} +void +mucwin_requires_config(ProfMucWin* mucwin) +{ +} +void +ui_room_destroy(const char* const roomjid) +{ +} +void +mucwin_info(ProfMucWin* mucwin) +{ +} +void +mucwin_show_role_list(ProfMucWin* mucwin, muc_role_t role) +{ +} +void +mucwin_show_affiliation_list(ProfMucWin* mucwin, muc_affiliation_t affiliation) +{ +} +void +mucwin_room_info_error(ProfMucWin* mucwin, const char* const error) +{ +} +void +mucwin_room_disco_info(ProfMucWin* mucwin, GSList* identities, GSList* features) +{ +} +void +ui_room_destroyed(const char* const roomjid, const char* const reason, const char* const new_jid, + const char* const password) +{ +} +void +ui_room_kicked(const char* const roomjid, const char* const actor, const char* const reason) +{ +} +void +mucwin_occupant_kicked(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason) +{ +} +void +ui_room_banned(const char* const roomjid, const char* const actor, const char* const reason) +{ +} +void +mucwin_occupant_banned(ProfMucWin* mucwin, const char* const nick, const char* const actor, + const char* const reason) +{ +} +void +ui_leave_room(const char* const roomjid) +{ +} +void +mucwin_broadcast(ProfMucWin* mucwin, const char* const message) +{ +} +void +mucwin_occupant_offline(ProfMucWin* mucwin, const char* const nick) +{ +} +void +mucwin_occupant_online(ProfMucWin* mucwin, const char* const nick, const char* const roles, + const char* const affiliation, const char* const show, const char* const status) +{ +} +void +mucwin_occupant_nick_change(ProfMucWin* mucwin, const char* const old_nick, const char* const nick) +{ +} +void +mucwin_nick_change(ProfMucWin* mucwin, const char* const nick) +{ +} +void +mucwin_occupant_presence(ProfMucWin* mucwin, const char* const nick, const char* const show, + const char* const status) +{ +} +void +mucwin_update_occupants(ProfMucWin* mucwin) +{ +} +void +mucwin_show_occupants(ProfMucWin* mucwin) +{ +} +void +mucwin_hide_occupants(ProfMucWin* mucwin) +{ +} +void +mucwin_set_enctext(ProfMucWin* mucwin, const char* const enctext) +{ +} +void +mucwin_unset_enctext(ProfMucWin* mucwin) +{ +} +void +mucwin_set_message_char(ProfMucWin* mucwin, const char* const ch) +{ +} +void +mucwin_unset_message_char(ProfMucWin* mucwin) +{ +} + +void +ui_show_roster(void) +{ +} +void +ui_hide_roster(void) +{ +} +void +ui_roster_add(const char* const barejid, const char* const name) +{ +} +void +ui_roster_remove(const char* const barejid) +{ +} +void +ui_contact_already_in_group(const char* const contact, const char* const group) +{ +} +void +ui_contact_not_in_group(const char* const contact, const char* const group) +{ +} +void +ui_group_added(const char* const contact, const char* const group) +{ +} +void +ui_group_removed(const char* const contact, const char* const group) +{ +} +void +chatwin_contact_online(ProfChatWin* chatwin, Resource* resource, GDateTime* last_activity) +{ +} +void +chatwin_contact_offline(ProfChatWin* chatwin, char* resource, char* status) +{ +} + +void +ui_contact_offline(char* barejid, char* resource, char* status) +{ +} + +void +ui_handle_recipient_error(const char* const recipient, const char* const err_msg) { check_expected(recipient); check_expected(err_msg); } -void ui_handle_error(const char * const err_msg) +void +ui_handle_error(const char* const err_msg) { check_expected(err_msg); } -void ui_clear_win_title(void) {} -void ui_goodbye_title(void) {} -void confwin_handle_configuration(ProfConfWin *confwin, DataForm *form) {} -void ui_handle_room_configuration_form_error(const char * const roomjid, const char * const message) {} -void ui_handle_room_config_submit_result(const char * const roomjid) {} -void ui_handle_room_config_submit_result_error(const char * const roomjid, const char * const message) {} -void mucwin_affiliation_list_error(ProfMucWin *mucwin, const char * const affiliation, const char * const error) {} -void mucwin_handle_affiliation_list(ProfMucWin *mucwin, const char * const affiliation, GSList *jids) {} -void mucwin_affiliation_set_error(ProfMucWin *mucwin, const char * const jid, const char * const affiliation, - const char * const error) {} -void mucwin_role_set_error(ProfMucWin *mucwin, const char * const nick, const char * const role, - const char * const error) {} -void mucwin_role_list_error(ProfMucWin *mucwin, const char * const role, const char * const error) {} -void mucwin_handle_role_list(ProfMucWin *mucwin, const char * const role, GSList *nicks) {} -void mucwin_kick_error(ProfMucWin *mucwin, const char * const nick, const char * const error) {} -void confwin_show_form(ProfConfWin *confwin) {} -void confwin_show_form_field(ProfConfWin *confwin, DataForm *form, char *tag) {} -void confwin_form_help(ProfConfWin *confwin) {} -void confwin_field_help(ProfConfWin *confwin, char *tag) {} -void ui_show_lines(ProfWin *window, gchar** lines) {} -void ui_redraw_all_room_rosters(void) {} -void ui_show_all_room_rosters(void) {} -void ui_hide_all_room_rosters(void) {} - -gboolean jabber_conn_is_secured(void) +void +ui_clear_win_title(void) +{ +} +void +ui_goodbye_title(void) +{ +} +void +confwin_handle_configuration(ProfConfWin* confwin, DataForm* form) +{ +} +void +ui_handle_room_configuration_form_error(const char* const roomjid, const char* const message) +{ +} +void +ui_handle_room_config_submit_result(const char* const roomjid) +{ +} +void +ui_handle_room_config_submit_result_error(const char* const roomjid, const char* const message) +{ +} +void +mucwin_affiliation_list_error(ProfMucWin* mucwin, const char* const affiliation, const char* const error) +{ +} +void +mucwin_handle_affiliation_list(ProfMucWin* mucwin, const char* const affiliation, GSList* jids) +{ +} +void +mucwin_affiliation_set_error(ProfMucWin* mucwin, const char* const jid, const char* const affiliation, + const char* const error) +{ +} +void +mucwin_role_set_error(ProfMucWin* mucwin, const char* const nick, const char* const role, + const char* const error) +{ +} +void +mucwin_role_list_error(ProfMucWin* mucwin, const char* const role, const char* const error) +{ +} +void +mucwin_handle_role_list(ProfMucWin* mucwin, const char* const role, GSList* nicks) +{ +} +void +mucwin_kick_error(ProfMucWin* mucwin, const char* const nick, const char* const error) +{ +} +void +confwin_show_form(ProfConfWin* confwin) +{ +} +void +confwin_show_form_field(ProfConfWin* confwin, DataForm* form, char* tag) +{ +} +void +confwin_form_help(ProfConfWin* confwin) +{ +} +void +confwin_field_help(ProfConfWin* confwin, char* tag) +{ +} +void +ui_show_lines(ProfWin* window, gchar** lines) +{ +} +void +ui_redraw_all_room_rosters(void) +{ +} +void +ui_show_all_room_rosters(void) +{ +} +void +ui_hide_all_room_rosters(void) +{ +} + +gboolean +jabber_conn_is_secured(void) { return TRUE; } -TLSCertificate* jabber_get_tls_peer_cert(void) +TLSCertificate* +jabber_get_tls_peer_cert(void) { return NULL; } -void cons_show_tlscert(TLSCertificate *cert) {} -void cons_show_tlscert_summary(TLSCertificate *cert) {} +void +cons_show_tlscert(TLSCertificate* cert) +{ +} +void +cons_show_tlscert_summary(TLSCertificate* cert) +{ +} -void ui_prune_wins(void) {} +void +ui_prune_wins(void) +{ +} -void ui_handle_login_account_success(ProfAccount *account, int secured) {} -void ui_update_presence(const resource_presence_t resource_presence, - const char * const message, const char * const show) {} +void +ui_handle_login_account_success(ProfAccount* account, int secured) +{ +} +void +ui_update_presence(const resource_presence_t resource_presence, + const char* const message, const char* const show) +{ +} -char* inp_readline(void) +char* +inp_readline(void) { return NULL; } -void inp_nonblocking(gboolean reset) {} +void +inp_nonblocking(gboolean reset) +{ +} -void ui_inp_history_append(char *inp) {} +void +ui_inp_history_append(char* inp) +{ +} -void ui_invalid_command_usage(const char * const usage, void (*setting_func)(void)) {} +void +ui_invalid_command_usage(const char* const usage, void (*setting_func)(void)) +{ +} -gboolean ui_win_has_unsaved_form(int num) +gboolean +ui_win_has_unsaved_form(int num) { return FALSE; } -void ui_status_bar_inactive(const int win) {} -void ui_status_bar_active(const int win) {} -void ui_status_bar_new(const int win) {} -void ui_write(char *line, int offset) {} +void +ui_status_bar_inactive(const int win) +{ +} +void +ui_status_bar_active(const int win) +{ +} +void +ui_status_bar_new(const int win) +{ +} +void +ui_write(char* line, int offset) +{ +} // console window actions -void cons_show(const char * const msg, ...) +void +cons_show(const char* const msg, ...) { va_list args; va_start(args, msg); @@ -321,34 +707,90 @@ void cons_show(const char * const msg, ...) va_end(args); } -void cons_show_padded(int pad, const char * const msg, ...) {} +void +cons_show_padded(int pad, const char* const msg, ...) +{ +} -void cons_show_help(const char *const cmd, CommandHelp *help) {} +void +cons_show_help(const char* const cmd, CommandHelp* help) +{ +} -void cons_about(void) {} -void cons_help(void) {} -void cons_navigation_help(void) {} -void cons_prefs(void) {} -void cons_show_ui_prefs(void) {} -void cons_show_desktop_prefs(void) {} -void cons_show_chat_prefs(void) {} -void cons_show_log_prefs(void) {} -void cons_show_presence_prefs(void) {} -void cons_show_connection_prefs(void) {} -void cons_show_otr_prefs(void) {} -void cons_show_pgp_prefs(void) {} -void cons_show_omemo_prefs(void) {} +void +cons_about(void) +{ +} +void +cons_help(void) +{ +} +void +cons_navigation_help(void) +{ +} +void +cons_prefs(void) +{ +} +void +cons_show_ui_prefs(void) +{ +} +void +cons_show_desktop_prefs(void) +{ +} +void +cons_show_chat_prefs(void) +{ +} +void +cons_show_log_prefs(void) +{ +} +void +cons_show_presence_prefs(void) +{ +} +void +cons_show_connection_prefs(void) +{ +} +void +cons_show_otr_prefs(void) +{ +} +void +cons_show_pgp_prefs(void) +{ +} +void +cons_show_omemo_prefs(void) +{ +} -void cons_show_account(ProfAccount *account) +void +cons_show_account(ProfAccount* account) { check_expected(account); } -void cons_debug(const char * const msg, ...) {} -void cons_show_time(void) {} -void cons_show_word(const char * const word) {} +void +cons_debug(const char* const msg, ...) +{ +} +void +cons_show_time(void) +{ +} +void +cons_show_word(const char* const word) +{ +} -void cons_show_error(const char * const cmd, ...) +void +cons_show_error(const char* const cmd, ...) { va_list args; va_start(args, cmd); @@ -357,185 +799,450 @@ void cons_show_error(const char * const cmd, ...) va_end(args); } -void cons_show_contacts(GSList * list) {} +void +cons_show_contacts(GSList* list) +{ +} -void cons_show_roster(GSList * list) +void +cons_show_roster(GSList* list) { check_expected(list); } void -cons_bad_cmd_usage(const char * const cmd) +cons_bad_cmd_usage(const char* const cmd) { check_expected(cmd); } -void cons_show_roster_group(const char * const group, GSList * list) {} -void cons_show_wins(gboolean unread) {} -void cons_show_status(const char * const barejid) {} -void cons_show_info(PContact pcontact) {} -void cons_show_caps(const char * const fulljid, resource_presence_t presence) {} -void cons_show_themes(GSList *themes) {} -void cons_show_scripts(GSList *scripts) {} -void cons_show_script(const char *const script, GSList *commands) {} +void +cons_show_roster_group(const char* const group, GSList* list) +{ +} +void +cons_show_wins(gboolean unread) +{ +} +void +cons_show_status(const char* const barejid) +{ +} +void +cons_show_info(PContact pcontact) +{ +} +void +cons_show_caps(const char* const fulljid, resource_presence_t presence) +{ +} +void +cons_show_themes(GSList* themes) +{ +} +void +cons_show_scripts(GSList* scripts) +{ +} +void +cons_show_script(const char* const script, GSList* commands) +{ +} -void cons_show_aliases(GList *aliases) +void +cons_show_aliases(GList* aliases) { check_expected(aliases); } -void cons_show_login_success(ProfAccount *account, int secured) {} -void cons_show_software_version(const char * const jid, - const char * const presence, const char * const name, - const char * const version, const char * const os) {} +void +cons_show_login_success(ProfAccount* account, int secured) +{ +} +void +cons_show_software_version(const char* const jid, + const char* const presence, const char* const name, + const char* const version, const char* const os) +{ +} -void cons_show_account_list(gchar **accounts) +void +cons_show_account_list(gchar** accounts) { check_expected(accounts); } -void cons_show_room_list(GSList *room, const char * const conference_node) {} +void +cons_show_room_list(GSList* room, const char* const conference_node) +{ +} -void cons_show_bookmarks(const GList *list) +void +cons_show_bookmarks(const GList* list) { check_expected(list); } -void cons_show_disco_items(GSList *items, const char * const jid) {} -void cons_show_disco_info(const char *from, GSList *identities, GSList *features) {} -void cons_show_room_invite(const char * const invitor, const char * const room, - const char * const reason) {} -void cons_check_version(gboolean not_available_msg) {} -void cons_show_typing(const char * const barejid) {} -void cons_show_incoming_room_message(const char *const nick, const char *const room, const int win_index, gboolean mention, GList *triggers, int unread) {} -void cons_show_incoming_message(const char * const short_from, const int win_index, int unread) {} -void cons_show_room_invites(GList *invites) {} -void cons_show_received_subs(void) {} -void cons_show_sent_subs(void) {} -void cons_alert(void) {} -void cons_theme_setting(void) {} -void cons_privileges_setting(void) {} -void cons_beep_setting(void) {} -void cons_color_setting(void) {} -void cons_console_setting(void) {} -void cons_flash_setting(void) {} -void cons_splash_setting(void) {} -void cons_vercheck_setting(void) {} -void cons_resource_setting(void) {} -void cons_occupants_setting(void) {} -void cons_roster_setting(void) {} -void cons_presence_setting(void) {} -void cons_wrap_setting(void) {} -void cons_winstidy_setting(void) {} -void cons_titlebar_setting(void) {} -void cons_time_setting(void) {} -void cons_statuses_setting(void) {} -void cons_wintitle_setting(void) {} -void cons_notify_setting(void) {} -void cons_states_setting(void) {} -void cons_outtype_setting(void) {} -void cons_intype_setting(void) {} -void cons_gone_setting(void) {} -void cons_history_setting(void) {} -void cons_carbons_setting(void) {} -void cons_receipts_setting(void) {} -void cons_log_setting(void) {} -void cons_logging_setting(void) {} -void cons_autoaway_setting(void) {} -void cons_reconnect_setting(void) {} -void cons_autoping_setting(void) {} -void cons_autoconnect_setting(void) {} -void cons_rooms_cache_setting(void) {} -void cons_inpblock_setting(void) {} -void cons_winpos_setting(void) {} -void cons_statusbar_setting(void) {} -void cons_tray_setting(void) {} -void cons_os_setting(void) {} -void cons_correction_setting(void) {} -void cons_executable_setting(void) {} -void cons_slashguard_setting(void) {} -void cons_show_bookmarks_ignore(gchar **list, gsize len) {} - -void cons_show_contact_online(PContact contact, Resource *resource, GDateTime *last_activity) +void +cons_show_disco_items(GSList* items, const char* const jid) +{ +} +void +cons_show_disco_info(const char* from, GSList* identities, GSList* features) +{ +} +void +cons_show_room_invite(const char* const invitor, const char* const room, + const char* const reason) +{ +} +void +cons_check_version(gboolean not_available_msg) +{ +} +void +cons_show_typing(const char* const barejid) +{ +} +void +cons_show_incoming_room_message(const char* const nick, const char* const room, const int win_index, gboolean mention, GList* triggers, int unread) +{ +} +void +cons_show_incoming_message(const char* const short_from, const int win_index, int unread) +{ +} +void +cons_show_room_invites(GList* invites) +{ +} +void +cons_show_received_subs(void) +{ +} +void +cons_show_sent_subs(void) +{ +} +void +cons_alert(void) +{ +} +void +cons_theme_setting(void) +{ +} +void +cons_privileges_setting(void) +{ +} +void +cons_beep_setting(void) +{ +} +void +cons_color_setting(void) +{ +} +void +cons_console_setting(void) +{ +} +void +cons_flash_setting(void) +{ +} +void +cons_splash_setting(void) +{ +} +void +cons_vercheck_setting(void) +{ +} +void +cons_resource_setting(void) +{ +} +void +cons_occupants_setting(void) +{ +} +void +cons_roster_setting(void) +{ +} +void +cons_presence_setting(void) +{ +} +void +cons_wrap_setting(void) +{ +} +void +cons_winstidy_setting(void) +{ +} +void +cons_titlebar_setting(void) +{ +} +void +cons_time_setting(void) +{ +} +void +cons_statuses_setting(void) +{ +} +void +cons_wintitle_setting(void) +{ +} +void +cons_notify_setting(void) +{ +} +void +cons_states_setting(void) +{ +} +void +cons_outtype_setting(void) +{ +} +void +cons_intype_setting(void) +{ +} +void +cons_gone_setting(void) +{ +} +void +cons_history_setting(void) +{ +} +void +cons_carbons_setting(void) +{ +} +void +cons_receipts_setting(void) +{ +} +void +cons_log_setting(void) +{ +} +void +cons_logging_setting(void) +{ +} +void +cons_autoaway_setting(void) +{ +} +void +cons_reconnect_setting(void) +{ +} +void +cons_autoping_setting(void) +{ +} +void +cons_autoconnect_setting(void) +{ +} +void +cons_rooms_cache_setting(void) +{ +} +void +cons_inpblock_setting(void) +{ +} +void +cons_winpos_setting(void) +{ +} +void +cons_statusbar_setting(void) +{ +} +void +cons_tray_setting(void) +{ +} +void +cons_os_setting(void) +{ +} +void +cons_correction_setting(void) +{ +} +void +cons_executable_setting(void) +{ +} +void +cons_slashguard_setting(void) +{ +} +void +cons_show_bookmarks_ignore(gchar** list, gsize len) +{ +} + +void +cons_show_contact_online(PContact contact, Resource* resource, GDateTime* last_activity) { check_expected(contact); check_expected(resource); check_expected(last_activity); } -void cons_show_contact_offline(PContact contact, char *resource, char *status) {} -void cons_theme_colours(void) {} -void cons_theme_properties(void) {} +void +cons_show_contact_offline(PContact contact, char* resource, char* status) +{ +} +void +cons_theme_colours(void) +{ +} +void +cons_theme_properties(void) +{ +} // title bar -void title_bar_set_presence(contact_presence_t presence) {} +void +title_bar_set_presence(contact_presence_t presence) +{ +} // status bar -void status_bar_inactive(const int win) {} -void status_bar_active(const int win, win_type_t type, char *identifier) {} -void status_bar_new(const int win, win_type_t type, char *identifier) {} -void status_bar_set_all_inactive(void) {} +void +status_bar_inactive(const int win) +{ +} +void +status_bar_active(const int win, win_type_t type, char* identifier) +{ +} +void +status_bar_new(const int win, win_type_t type, char* identifier) +{ +} +void +status_bar_set_all_inactive(void) +{ +} // roster window -void rosterwin_roster(void) {} +void +rosterwin_roster(void) +{ +} // occupants window -void occupantswin_occupants(const char * const room) {} -void occupantswin_occupants_all(void) {} +void +occupantswin_occupants(const char* const room) +{ +} +void +occupantswin_occupants_all(void) +{ +} // window interface -ProfWin* win_create_console(void) +ProfWin* +win_create_console(void) { return mock_ptr_type(ProfWin*); } -ProfWin* win_create_xmlconsole(void) +ProfWin* +win_create_xmlconsole(void) { return NULL; } -ProfWin* win_create_chat(const char * const barejid) +ProfWin* +win_create_chat(const char* const barejid) { return mock_ptr_type(ProfWin*); } -ProfWin* win_create_muc(const char * const roomjid) +ProfWin* +win_create_muc(const char* const roomjid) { return NULL; } -ProfWin* win_create_config(const char *const title, DataForm *form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void *userdata) +ProfWin* +win_create_config(const char* const title, DataForm* form, ProfConfWinCallback submit, ProfConfWinCallback cancel, const void* userdata) { return NULL; } -ProfWin* win_create_private(const char * const fulljid) +ProfWin* +win_create_private(const char* const fulljid) { return NULL; } -ProfWin* win_create_plugin(const char *const plugin_name, const char * const tag) +ProfWin* +win_create_plugin(const char* const plugin_name, const char* const tag) { return NULL; } -char* win_get_tab_identifier(ProfWin *window) +char* +win_get_tab_identifier(ProfWin* window) { return NULL; } -void win_update_virtual(ProfWin *window) {} -void win_free(ProfWin *window) {} -gboolean win_notify_remind(ProfWin *window) +void +win_update_virtual(ProfWin* window) +{ +} +void +win_free(ProfWin* window) +{ +} +gboolean +win_notify_remind(ProfWin* window) { return TRUE; } -int win_unread(ProfWin *window) +int +win_unread(ProfWin* window) { return 0; } -void win_resize(ProfWin *window) {} -void win_hide_subwin(ProfWin *window) {} -void win_show_subwin(ProfWin *window) {} -void win_refresh_without_subwin(ProfWin *window) {} -void win_refresh_with_subwin(ProfWin *window) {} +void +win_resize(ProfWin* window) +{ +} +void +win_hide_subwin(ProfWin* window) +{ +} +void +win_show_subwin(ProfWin* window) +{ +} +void +win_refresh_without_subwin(ProfWin* window) +{ +} +void +win_refresh_with_subwin(ProfWin* window) +{ +} -void win_println(ProfWin *window, theme_item_t theme, const char *ch, const char *const message, ...) +void +win_println(ProfWin* window, theme_item_t theme, const char* ch, const char* const message, ...) { va_list args; va_start(args, message); @@ -544,35 +1251,84 @@ void win_println(ProfWin *window, theme_item_t theme, const char *ch, const char va_end(args); } -void win_print(ProfWin *window, theme_item_t theme_item, const char *ch, const char *const message, ...) {} -void win_appendln(ProfWin *window, theme_item_t theme_item, const char *const message, ...) {} +void +win_print(ProfWin* window, theme_item_t theme_item, const char* ch, const char* const message, ...) +{ +} +void +win_appendln(ProfWin* window, theme_item_t theme_item, const char* const message, ...) +{ +} -char* win_get_title(ProfWin *window) +char* +win_get_title(ProfWin* window) { return NULL; } -void win_show_occupant(ProfWin *window, Occupant *occupant) {} -void win_show_occupant_info(ProfWin *window, const char * const room, Occupant *occupant) {} -void win_show_contact(ProfWin *window, PContact contact) {} -void win_show_info(ProfWin *window, PContact contact) {} -void win_println_indent(ProfWin *window, int pad, const char * const message, ...) {} -void win_clear(ProfWin *window) {} -char* win_to_string(ProfWin *window) +void +win_show_occupant(ProfWin* window, Occupant* occupant) +{ +} +void +win_show_occupant_info(ProfWin* window, const char* const room, Occupant* occupant) +{ +} +void +win_show_contact(ProfWin* window, PContact contact) +{ +} +void +win_show_info(ProfWin* window, PContact contact) +{ +} +void +win_println_indent(ProfWin* window, int pad, const char* const message, ...) +{ +} +void +win_clear(ProfWin* window) +{ +} +char* +win_to_string(ProfWin* window) { return NULL; } // desktop notifier actions -void notifier_uninit(void) {} - -void notify_typing(const char * const handle) {} -void notify_message(const char *const name, int win, const char *const text) {} -void notify_room_message(const char * const handle, const char * const room, - int win, const char * const text) {} -void notify_remind(void) {} -void notify_invite(const char * const from, const char * const room, - const char * const reason) {} -void notify_subscription(const char * const from) {} -void notify(const char * const message, int timeout, - const char * const category) {} +void +notifier_uninit(void) +{ +} +void +notify_typing(const char* const handle) +{ +} +void +notify_message(const char* const name, int win, const char* const text) +{ +} +void +notify_room_message(const char* const handle, const char* const room, + int win, const char* const text) +{ +} +void +notify_remind(void) +{ +} +void +notify_invite(const char* const from, const char* const room, + const char* const reason) +{ +} +void +notify_subscription(const char* const from) +{ +} +void +notify(const char* const message, int timeout, + const char* const category) +{ +} diff --git a/tests/unittests/ui/stub_ui.h b/tests/unittests/ui/stub_ui.h index 635f719e..faff0710 100644 --- a/tests/unittests/ui/stub_ui.h +++ b/tests/unittests/ui/stub_ui.h @@ -1,5 +1,5 @@ -void expect_cons_show(char *expected); +void expect_cons_show(char* expected); void expect_any_cons_show(void); -void expect_cons_show_error(char *expected); +void expect_cons_show_error(char* expected); void expect_any_cons_show_error(void); -void expect_win_println(char *message); +void expect_win_println(char* message); diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c index 86d0ac62..874f6194 100644 --- a/tests/unittests/unittests.c +++ b/tests/unittests/unittests.c @@ -39,10 +39,12 @@ #include "test_callbacks.h" #include "test_plugins_disco.h" -int main(int argc, char* argv[]) { +int +main(int argc, char* argv[]) +{ setlocale(LC_ALL, "en_GB.UTF-8"); - char *codeset = nl_langinfo(CODESET); - char *lang = getenv("LANG"); + char* codeset = nl_langinfo(CODESET); + char* lang = getenv("LANG"); printf("Charset information:\n"); @@ -217,93 +219,93 @@ int main(int argc, char* argv[]) { unit_test(remove_contact_with_remaining_in_group), unit_test_setup_teardown(returns_false_when_chat_session_does_not_exist, - init_chat_sessions, - close_chat_sessions), + init_chat_sessions, + close_chat_sessions), unit_test_setup_teardown(creates_chat_session_on_recipient_activity, - init_chat_sessions, - close_chat_sessions), + init_chat_sessions, + close_chat_sessions), unit_test_setup_teardown(replaces_chat_session_on_recipient_activity_with_different_resource, - init_chat_sessions, - close_chat_sessions), + init_chat_sessions, + close_chat_sessions), unit_test_setup_teardown(removes_chat_session, - init_chat_sessions, - close_chat_sessions), + init_chat_sessions, + close_chat_sessions), unit_test_setup_teardown(cmd_connect_shows_message_when_disconnecting, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_connecting, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_connected, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_when_no_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_fail_message, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_lowercases_argument_with_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_lowercases_argument_with_no_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_no_server_value, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_connecting_with_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_connects_with_account, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_server_no_port_value, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_no_port_value, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_port_no_server_value, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_port_0, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_port_minus1, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_port_65536, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_message_when_port_contains_chars, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_with_server_when_provided, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_with_port_when_provided, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_with_server_and_port_when_provided, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_server_provided_twice, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_port_provided_twice, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_invalid_first_property, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_connect_shows_usage_when_invalid_second_property, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test(cmd_rooms_shows_message_when_disconnected), unit_test(cmd_rooms_shows_message_when_disconnecting), @@ -404,55 +406,55 @@ int main(int argc, char* argv[]) { unit_test(cmd_presence_shows_usage_when_bad_chat_setting), unit_test(cmd_presence_shows_usage_when_bad_muc_setting), unit_test_setup_teardown(cmd_presence_console_sets_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_console_sets_online, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_console_sets_none, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_chat_sets_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_chat_sets_online, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_chat_sets_none, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_room_sets_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_room_sets_online, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_presence_room_sets_none, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(statuses_console_defaults_to_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(statuses_chat_defaults_to_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(statuses_muc_defaults_to_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(console_shows_online_presence_when_set_online, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(console_shows_online_presence_when_set_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(console_shows_dnd_presence_when_set_all, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(handle_offline_removes_chat_session, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test(lost_connection_clears_chat_sessions), unit_test(cmd_alias_add_shows_usage_when_no_args), @@ -460,20 +462,20 @@ int main(int argc, char* argv[]) { unit_test(cmd_alias_remove_shows_usage_when_no_args), unit_test(cmd_alias_show_usage_when_invalid_subcmd), unit_test_setup_teardown(cmd_alias_add_adds_alias, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_alias_add_shows_message_when_exists, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_alias_remove_removes_alias, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_alias_remove_shows_message_when_no_alias, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_alias_list_shows_all_aliases, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(test_muc_invites_add, muc_before_test, muc_after_test), unit_test_setup_teardown(test_muc_remove_invite, muc_before_test, muc_after_test), @@ -504,20 +506,20 @@ int main(int argc, char* argv[]) { unit_test(cmd_otr_log_shows_usage_when_no_args), unit_test(cmd_otr_log_shows_usage_when_invalid_subcommand), unit_test_setup_teardown(cmd_otr_log_on_enables_logging, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_otr_log_off_disables_logging, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_otr_redact_redacts_logging, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_otr_log_on_shows_warning_when_chlog_disabled, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test_setup_teardown(cmd_otr_log_redact_shows_warning_when_chlog_disabled, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test(cmd_otr_libver_shows_libotr_version), unit_test(cmd_otr_gen_shows_message_when_not_connected), unit_test(cmd_otr_gen_generates_key_for_connected_account), @@ -540,8 +542,8 @@ int main(int argc, char* argv[]) { unit_test(cmd_otr_start_shows_message_when_already_started), unit_test(cmd_otr_start_shows_message_when_no_key), unit_test_setup_teardown(cmd_otr_start_sends_otr_query_message_to_current_recipeint, - load_preferences, - close_preferences), + load_preferences, + close_preferences), #else unit_test(cmd_otr_shows_message_when_otr_unsupported), #endif @@ -608,8 +610,8 @@ int main(int argc, char* argv[]) { unit_test(remove_text_multi_value_removes_when_many), unit_test_setup_teardown(clears_chat_sessions, - load_preferences, - close_preferences), + load_preferences, + close_preferences), unit_test(prof_partial_occurrences_tests), unit_test(prof_whole_occurrences_tests), diff --git a/tests/unittests/xmpp/stub_avatar.c b/tests/unittests/xmpp/stub_avatar.c index 64b8a95f..ccd9cf4d 100644 --- a/tests/unittests/xmpp/stub_avatar.c +++ b/tests/unittests/xmpp/stub_avatar.c @@ -2,6 +2,9 @@ #include <glib.h> #include <stdlib.h> -void avatar_pep_subscribe(void) {}; -gboolean avatar_get_by_nick(const char* nick) {return TRUE;} - +void avatar_pep_subscribe(void){}; +gboolean +avatar_get_by_nick(const char* nick) +{ + return TRUE; +} diff --git a/tests/unittests/xmpp/stub_message.c b/tests/unittests/xmpp/stub_message.c index 3e22e539..e99acbc9 100644 --- a/tests/unittests/xmpp/stub_message.c +++ b/tests/unittests/xmpp/stub_message.c @@ -1,7 +1,12 @@ #include "xmpp/message.h" -ProfMessage *message_init(void) { +ProfMessage* +message_init(void) +{ return NULL; } -void message_free(ProfMessage *message) {} +void +message_free(ProfMessage* message) +{ +} diff --git a/tests/unittests/xmpp/stub_ox.c b/tests/unittests/xmpp/stub_ox.c index 11529533..ce5532ae 100644 --- a/tests/unittests/xmpp/stub_ox.c +++ b/tests/unittests/xmpp/stub_ox.c @@ -2,7 +2,7 @@ #include <glib.h> #include <stdlib.h> -gboolean +gboolean ox_announce_public_key(const char* const filename) { return FALSE; diff --git a/tests/unittests/xmpp/stub_xmpp.c b/tests/unittests/xmpp/stub_xmpp.c index 16392283..e1b6fdd8 100644 --- a/tests/unittests/xmpp/stub_xmpp.c +++ b/tests/unittests/xmpp/stub_xmpp.c @@ -6,13 +6,23 @@ #include "xmpp/xmpp.h" // connection functions -void session_init(void) {} -void session_init_activity(void) {} -void session_check_autoaway(void) {} +void +session_init(void) +{ +} +void +session_init_activity(void) +{ +} +void +session_check_autoaway(void) +{ +} -jabber_conn_status_t session_connect_with_details(const char * const jid, - const char * const passwd, const char * const altdomain, const int port, const char *const tls_policy, - const char *const auth_policy) +jabber_conn_status_t +session_connect_with_details(const char* const jid, + const char* const passwd, const char* const altdomain, const int port, const char* const tls_policy, + const char* const auth_policy) { check_expected(jid); check_expected(passwd); @@ -21,31 +31,45 @@ jabber_conn_status_t session_connect_with_details(const char * const jid, return mock_type(jabber_conn_status_t); } -jabber_conn_status_t session_connect_with_account(const ProfAccount * const account) +jabber_conn_status_t +session_connect_with_account(const ProfAccount* const account) { check_expected(account); return mock_type(jabber_conn_status_t); } -void session_disconnect(void) {} -void session_shutdown(void) {} -void session_process_events(void) {} -const char * connection_get_fulljid(void) +void +session_disconnect(void) +{ +} +void +session_shutdown(void) { - return mock_ptr_type(char *); +} +void +session_process_events(void) +{ +} +const char* +connection_get_fulljid(void) +{ + return mock_ptr_type(char*); } -char* connection_get_barejid(void) +char* +connection_get_barejid(void) { - return mock_ptr_type(char *); + return mock_ptr_type(char*); } -const char * connection_get_domain(void) +const char* +connection_get_domain(void) { return NULL; } -gboolean connection_is_secured(void) +gboolean +connection_is_secured(void) { return 1; } @@ -56,202 +80,355 @@ connection_get_tls_peer_cert(void) return NULL; } - -char* connection_create_uuid(void) +char* +connection_create_uuid(void) { return NULL; } -void connection_free_uuid(char * uuid) {} +void +connection_free_uuid(char* uuid) +{ +} -jabber_conn_status_t connection_get_status(void) +jabber_conn_status_t +connection_get_status(void) { return mock_type(jabber_conn_status_t); } -char* connection_get_presence_msg(void) +char* +connection_get_presence_msg(void) { return mock_ptr_type(char*); } -char* session_get_account_name(void) +char* +session_get_account_name(void) { return mock_ptr_type(char*); } -GList * session_get_available_resources(void) +GList* +session_get_available_resources(void) { return NULL; } -void connection_set_presence_msg(const char *const message) {} +void +connection_set_presence_msg(const char* const message) +{ +} gboolean -connection_send_stanza(const char *const stanza) +connection_send_stanza(const char* const stanza) { return TRUE; } gboolean -connection_supports(const char *const feature) +connection_supports(const char* const feature) { return FALSE; } -const char* connection_get_profanity_identifier(void) { +const char* +connection_get_profanity_identifier(void) +{ return "profident"; } // message functions -char* message_send_chat(const char *const barejid, const char *const msg, const char *const oob_url, gboolean request_receipt, const char *const replace_id) +char* +message_send_chat(const char* const barejid, const char* const msg, const char* const oob_url, gboolean request_receipt, const char* const replace_id) { check_expected(barejid); check_expected(msg); return NULL; } -char* message_send_chat_otr(const char * const barejid, const char * const msg, gboolean request_receipt, const char *const replace_id) +char* +message_send_chat_otr(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id) { check_expected(barejid); check_expected(msg); return NULL; } -char* message_send_chat_pgp(const char * const barejid, const char * const msg, gboolean request_receipt, const char *const replace_id) +char* +message_send_chat_pgp(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id) { return NULL; } -char* message_send_chat_ox(const char * const barejid, const char * const msg, gboolean request_receipt, const char *const replace_id) +char* +message_send_chat_ox(const char* const barejid, const char* const msg, gboolean request_receipt, const char* const replace_id) { return NULL; } -char* message_send_private(const char *const fulljid, const char *const msg, const char *const oob_url) +char* +message_send_private(const char* const fulljid, const char* const msg, const char* const oob_url) { return NULL; } -char* message_send_groupchat(const char *const roomjid, const char *const msg, const char *const oob_url, const char *const replace_id) +char* +message_send_groupchat(const char* const roomjid, const char* const msg, const char* const oob_url, const char* const replace_id) { return NULL; } -void message_send_groupchat_subject(const char * const roomjid, const char * const subject) {} +void +message_send_groupchat_subject(const char* const roomjid, const char* const subject) +{ +} -void message_send_inactive(const char * const barejid) {} -void message_send_composing(const char * const barejid) {} -void message_send_paused(const char * const barejid) {} -void message_send_gone(const char * const barejid) {} +void +message_send_inactive(const char* const barejid) +{ +} +void +message_send_composing(const char* const barejid) +{ +} +void +message_send_paused(const char* const barejid) +{ +} +void +message_send_gone(const char* const barejid) +{ +} -void message_send_invite(const char * const room, const char * const contact, - const char * const reason) {} +void +message_send_invite(const char* const room, const char* const contact, + const char* const reason) +{ +} -bool message_is_sent_by_us(const ProfMessage *const message, bool checkOID) { +bool +message_is_sent_by_us(const ProfMessage* const message, bool checkOID) +{ return TRUE; } // presence functions -void presence_subscription(const char * const jid, const jabber_subscr_t action) {} +void +presence_subscription(const char* const jid, const jabber_subscr_t action) +{ +} -GList* presence_get_subscription_requests(void) +GList* +presence_get_subscription_requests(void) { return NULL; } -gint presence_sub_request_count(void) +gint +presence_sub_request_count(void) { return 0; } -void presence_reset_sub_request_search(void) {} +void +presence_reset_sub_request_search(void) +{ +} -char * presence_sub_request_find(const char * const search_str, gboolean previous, void *context) +char* +presence_sub_request_find(const char* const search_str, gboolean previous, void* context) { - return NULL; + return NULL; } -void presence_join_room(const char *const room, const char *const nick, const char *const passwd) +void +presence_join_room(const char* const room, const char* const nick, const char* const passwd) { check_expected(room); check_expected(nick); check_expected(passwd); } -void presence_change_room_nick(const char * const room, const char * const nick) {} -void presence_leave_chat_room(const char * const room_jid) {} +void +presence_change_room_nick(const char* const room, const char* const nick) +{ +} +void +presence_leave_chat_room(const char* const room_jid) +{ +} -void presence_send(resource_presence_t status, int idle, char *signed_status) +void +presence_send(resource_presence_t status, int idle, char* signed_status) { check_expected(status); check_expected(idle); check_expected(signed_status); } -gboolean presence_sub_request_exists(const char * const bare_jid) +gboolean +presence_sub_request_exists(const char* const bare_jid) { return FALSE; } // iq functions -void iq_disable_carbons() {}; -void iq_enable_carbons() {}; -void iq_send_software_version(const char * const fulljid) {} +void iq_disable_carbons(){}; +void iq_enable_carbons(){}; +void +iq_send_software_version(const char* const fulljid) +{ +} -void iq_room_list_request(gchar *conferencejid, gchar *filter) +void +iq_room_list_request(gchar* conferencejid, gchar* filter) { check_expected(conferencejid); check_expected(filter); } -void iq_disco_info_request(gchar *jid) {} -void iq_disco_items_request(gchar *jid) {} -void iq_set_autoping(int seconds) {} -void iq_http_upload_request(HTTPUpload *upload) {} -void iq_confirm_instant_room(const char * const room_jid) {} -void iq_destroy_room(const char * const room_jid) {} -void iq_request_room_config_form(const char * const room_jid) {} -void iq_submit_room_config(ProfConfWin *confwin) {} -void iq_room_config_cancel(ProfConfWin *confwin) {} -void iq_send_ping(const char * const target) {} -void iq_send_caps_request(const char * const to, const char * const id, - const char * const node, const char * const ver) {} -void iq_send_caps_request_for_jid(const char * const to, const char * const id, - const char * const node, const char * const ver) {} -void iq_send_caps_request_legacy(const char * const to, const char * const id, - const char * const node, const char * const ver) {} -void iq_room_info_request(const char * const room, gboolean display) {} -void iq_room_affiliation_list(const char * const room, char *affiliation, bool show) {} -void iq_room_affiliation_set(const char * const room, const char * const jid, char *affiliation, - const char * const reason) {} -void iq_room_kick_occupant(const char * const room, const char * const nick, const char * const reason) {} -void iq_room_role_set(const char * const room, const char * const nick, char *role, - const char * const reason) {} -void iq_room_role_list(const char * const room, char *role) {} -void iq_last_activity_request(gchar *jid) {} -void iq_autoping_timer_cancel(void) {} -void iq_autoping_check(void) {} -void iq_rooms_cache_clear(void) {} -void iq_command_list(const char *const target) {} -void iq_command_exec(const char *const target, const char *const command) {} +void +iq_disco_info_request(gchar* jid) +{ +} +void +iq_disco_items_request(gchar* jid) +{ +} +void +iq_set_autoping(int seconds) +{ +} +void +iq_http_upload_request(HTTPUpload* upload) +{ +} +void +iq_confirm_instant_room(const char* const room_jid) +{ +} +void +iq_destroy_room(const char* const room_jid) +{ +} +void +iq_request_room_config_form(const char* const room_jid) +{ +} +void +iq_submit_room_config(ProfConfWin* confwin) +{ +} +void +iq_room_config_cancel(ProfConfWin* confwin) +{ +} +void +iq_send_ping(const char* const target) +{ +} +void +iq_send_caps_request(const char* const to, const char* const id, + const char* const node, const char* const ver) +{ +} +void +iq_send_caps_request_for_jid(const char* const to, const char* const id, + const char* const node, const char* const ver) +{ +} +void +iq_send_caps_request_legacy(const char* const to, const char* const id, + const char* const node, const char* const ver) +{ +} +void +iq_room_info_request(const char* const room, gboolean display) +{ +} +void +iq_room_affiliation_list(const char* const room, char* affiliation, bool show) +{ +} +void +iq_room_affiliation_set(const char* const room, const char* const jid, char* affiliation, + const char* const reason) +{ +} +void +iq_room_kick_occupant(const char* const room, const char* const nick, const char* const reason) +{ +} +void +iq_room_role_set(const char* const room, const char* const nick, char* role, + const char* const reason) +{ +} +void +iq_room_role_list(const char* const room, char* role) +{ +} +void +iq_last_activity_request(gchar* jid) +{ +} +void +iq_autoping_timer_cancel(void) +{ +} +void +iq_autoping_check(void) +{ +} +void +iq_rooms_cache_clear(void) +{ +} +void +iq_command_list(const char* const target) +{ +} +void +iq_command_exec(const char* const target, const char* const command) +{ +} // caps functions -void caps_add_feature(char *feature) {} -void caps_remove_feature(char *feature) {} -EntityCapabilities* caps_lookup(const char * const jid) +void +caps_add_feature(char* feature) +{ +} +void +caps_remove_feature(char* feature) +{ +} +EntityCapabilities* +caps_lookup(const char* const jid) { return NULL; } -void caps_close(void) {} -void caps_destroy(EntityCapabilities *caps) {} -void caps_reset_ver(void) {} -gboolean caps_jid_has_feature(const char *const jid, const char *const feature) +void +caps_close(void) +{ +} +void +caps_destroy(EntityCapabilities* caps) +{ +} +void +caps_reset_ver(void) +{ +} +gboolean +caps_jid_has_feature(const char* const jid, const char* const feature) { return FALSE; } -gboolean bookmark_add(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name) +gboolean +bookmark_add(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name) { check_expected(jid); check_expected(nick); @@ -260,78 +437,103 @@ gboolean bookmark_add(const char *jid, const char *nick, const char *password, c return mock_type(gboolean); } -gboolean bookmark_update(const char *jid, const char *nick, const char *password, const char *autojoin_str, const char *name) +gboolean +bookmark_update(const char* jid, const char* nick, const char* password, const char* autojoin_str, const char* name) { return FALSE; } -gboolean bookmark_remove(const char *jid) +gboolean +bookmark_remove(const char* jid) { check_expected(jid); return mock_type(gboolean); } -gboolean bookmark_join(const char *jid) +gboolean +bookmark_join(const char* jid) { return FALSE; } -GList * bookmark_get_list(void) +GList* +bookmark_get_list(void) { - return mock_ptr_type(GList *); + return mock_ptr_type(GList*); } -char * bookmark_find(const char * const search_str, gboolean previous, void *context) +char* +bookmark_find(const char* const search_str, gboolean previous, void* context) { return NULL; } -void bookmark_autocomplete_reset(void) {} +void +bookmark_autocomplete_reset(void) +{ +} -void roster_send_name_change(const char * const barejid, const char * const new_name, GSList *groups) +void +roster_send_name_change(const char* const barejid, const char* const new_name, GSList* groups) { check_expected(barejid); check_expected(new_name); check_expected(groups); } -gboolean bookmark_exists(const char *const room) +gboolean +bookmark_exists(const char* const room) { return FALSE; } -void roster_send_add_to_group(const char * const group, PContact contact) {} -void roster_send_remove_from_group(const char * const group, PContact contact) {} +void +roster_send_add_to_group(const char* const group, PContact contact) +{ +} +void +roster_send_remove_from_group(const char* const group, PContact contact) +{ +} -void roster_send_add_new(const char * const barejid, const char * const name) +void +roster_send_add_new(const char* const barejid, const char* const name) { check_expected(barejid); check_expected(name); } -void roster_send_remove(const char * const barejid) +void +roster_send_remove(const char* const barejid) { check_expected(barejid); } -GList* blocked_list(void) +GList* +blocked_list(void) { return NULL; } -gboolean blocked_add(char *jid) +gboolean +blocked_add(char* jid) { return TRUE; } -gboolean blocked_remove(char *jid) +gboolean +blocked_remove(char* jid) { return TRUE; } -char* blocked_ac_find(const char *const search_str, gboolean previous, void *context) +char* +blocked_ac_find(const char* const search_str, gboolean previous, void* context) { return NULL; } -void blocked_ac_reset(void) {} +void +blocked_ac_reset(void) +{ +} |