From d35a7a7f7e0101730812925b9804ffea98c7f1ef Mon Sep 17 00:00:00 2001 From: ike08 Date: Wed, 1 Nov 2023 18:30:08 -0600 Subject: [PATCH] Refactor tests to use the new cmocka test runner ## Summary Fixes https://github.com/profanity-im/profanity/issues/1907 Update functional and unit test code to comply with the current cmocka test runner. ## Changes - `UnitTest` struct to `CMUnitTest` struct - `unit_test()` macro to `cmocka_unit_test(f)` macro - `unit_test_setup_teardown()` macro to `cmocka_unit_test_setup_teardown` macro - `run_tests()` macro to `cmocka_run_group_tests()` function - Setup and teardown functions return `int` instead of `void` ## Testing ### Unit Tests `make check` ### Functional Tests I did not compile or run functional tests because they are *shelved* for now. ### Valgrind I'm not entirely sure how to fun Valgrind in this case. I did not do fancy memory management, so it should be fine. --- tests/functionaltests/functionaltests.c | 6 +- tests/functionaltests/proftest.c | 8 +- tests/functionaltests/proftest.h | 4 +- tests/unittests/helpers.c | 12 +- tests/unittests/helpers.h | 8 +- tests/unittests/test_muc.c | 6 +- tests/unittests/test_muc.h | 4 +- tests/unittests/unittests.c | 1132 +++++++++++------------ 8 files changed, 594 insertions(+), 586 deletions(-) diff --git a/tests/functionaltests/functionaltests.c b/tests/functionaltests/functionaltests.c index bee95ad363..3106a0e2c5 100644 --- a/tests/functionaltests/functionaltests.c +++ b/tests/functionaltests/functionaltests.c @@ -23,11 +23,11 @@ #include "test_muc.h" #include "test_disconnect.h" -#define PROF_FUNC_TEST(test) unit_test_setup_teardown(test, init_prof_test, close_prof_test) +#define PROF_FUNC_TEST(test) cmocka_unit_test_setup_teardown(test, init_prof_test, close_prof_test) int main(int argc, char* argv[]) { - const UnitTest all_tests[] = { + const struct CMUnitTest all_tests[] = { PROF_FUNC_TEST(connect_jid_requests_roster), PROF_FUNC_TEST(connect_jid_sends_presence_after_receiving_roster), @@ -111,5 +111,5 @@ int main(int argc, char* argv[]) { PROF_FUNC_TEST(disconnect_ends_session), }; - return run_tests(all_tests); + return cmocka_run_group_tests(all_tests, NULL, NULL); } diff --git a/tests/functionaltests/proftest.c b/tests/functionaltests/proftest.c index ede555f27b..2fe904e42b 100644 --- a/tests/functionaltests/proftest.c +++ b/tests/functionaltests/proftest.c @@ -138,12 +138,12 @@ prof_start(void) setbuf(fp, (char *)0); } -void +int init_prof_test(void **state) { if (stbbr_start(STBBR_LOGDEBUG ,5230, 0) != 0) { assert_true(FALSE); - return; + return -1; } config_orig = getenv("XDG_CONFIG_HOME"); @@ -190,9 +190,10 @@ init_prof_test(void **state) assert_true(prof_output_exact("Private chat time display disabled.")); prof_input("/time xml off"); assert_true(prof_output_exact("XML Console time display disabled.")); + return 0; } -void +int close_prof_test(void **state) { prof_input("/quit"); @@ -203,6 +204,7 @@ close_prof_test(void **state) setenv("XDG_DATA_HOME", data_orig, 1); stbbr_stop(); + return 0; } void diff --git a/tests/functionaltests/proftest.h b/tests/functionaltests/proftest.h index f650cdadc0..a3ff07e973 100644 --- a/tests/functionaltests/proftest.h +++ b/tests/functionaltests/proftest.h @@ -4,8 +4,8 @@ #define XDG_CONFIG_HOME "./tests/functionaltests/files/xdg_config_home" #define XDG_DATA_HOME "./tests/functionaltests/files/xdg_data_home" -void init_prof_test(void **state); -void close_prof_test(void **state); +int init_prof_test(void **state); +int close_prof_test(void **state); void prof_start(void); void prof_connect(void); diff --git a/tests/unittests/helpers.c b/tests/unittests/helpers.c index bc4f8db334..3205e460bd 100644 --- a/tests/unittests/helpers.c +++ b/tests/unittests/helpers.c @@ -44,7 +44,7 @@ remove_data_dir(void** state) rmdir("./tests/files/xdg_data_home"); } -void +int load_preferences(void** state) { create_config_dir(state); @@ -53,29 +53,33 @@ load_preferences(void** state) prefs_load(NULL); } fclose(f); + return 0; } -void +int close_preferences(void** state) { prefs_close(); remove("./tests/files/xdg_config_home/profanity/profrc"); remove_config_dir(state); rmdir("./tests/files"); + return 0; } -void +int init_chat_sessions(void** state) { load_preferences(NULL); chat_sessions_init(); + return 0; } -void +int close_chat_sessions(void** state) { chat_sessions_clear(); close_preferences(NULL); + return 0; } int diff --git a/tests/unittests/helpers.h b/tests/unittests/helpers.h index 34a1d82e5d..0ee2f2c47c 100644 --- a/tests/unittests/helpers.h +++ b/tests/unittests/helpers.h @@ -1,10 +1,10 @@ #include "glib.h" -void load_preferences(void** state); -void close_preferences(void** state); +int load_preferences(void** state); +int close_preferences(void** state); -void init_chat_sessions(void** state); -void close_chat_sessions(void** state); +int init_chat_sessions(void** state); +int close_chat_sessions(void** state); int utf8_pos_to_col(char* str, int utf8_pos); diff --git a/tests/unittests/test_muc.c b/tests/unittests/test_muc.c index 80d6fbcf4f..977e2de869 100644 --- a/tests/unittests/test_muc.c +++ b/tests/unittests/test_muc.c @@ -6,16 +6,18 @@ #include "xmpp/muc.h" -void +int muc_before_test(void** state) { muc_init(); + return 0; } -void +int muc_after_test(void** state) { muc_close(); + return 0; } void diff --git a/tests/unittests/test_muc.h b/tests/unittests/test_muc.h index 2140d52013..df89d6d197 100644 --- a/tests/unittests/test_muc.h +++ b/tests/unittests/test_muc.h @@ -1,5 +1,5 @@ -void muc_before_test(void** state); -void muc_after_test(void** state); +int muc_before_test(void** state); +int muc_after_test(void** state); void test_muc_invites_add(void** state); void test_muc_remove_invite(void** state); diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c index 30f18c5c74..c28f3f2ec1 100644 --- a/tests/unittests/unittests.c +++ b/tests/unittests/unittests.c @@ -57,583 +57,583 @@ main(int argc, char* argv[]) printf(" MB_CUR_MAX: %d\n", (int)MB_CUR_MAX); printf(" MB_LEN_MAX: %d\n", (int)MB_LEN_MAX); - const UnitTest all_tests[] = { - - unit_test(replace_one_substr), - unit_test(replace_one_substr_beginning), - unit_test(replace_one_substr_end), - unit_test(replace_two_substr), - unit_test(replace_char), - unit_test(replace_when_none), - unit_test(replace_when_match), - unit_test(replace_when_string_empty), - unit_test(replace_when_string_null), - unit_test(replace_when_sub_empty), - unit_test(replace_when_sub_null), - unit_test(replace_when_new_empty), - unit_test(replace_when_new_null), - unit_test(test_online_is_valid_resource_presence_string), - unit_test(test_chat_is_valid_resource_presence_string), - unit_test(test_away_is_valid_resource_presence_string), - unit_test(test_xa_is_valid_resource_presence_string), - unit_test(test_dnd_is_valid_resource_presence_string), - unit_test(test_available_is_not_valid_resource_presence_string), - unit_test(test_unavailable_is_not_valid_resource_presence_string), - unit_test(test_blah_is_not_valid_resource_presence_string), - unit_test(utf8_display_len_null_str), - unit_test(utf8_display_len_1_non_wide), - unit_test(utf8_display_len_1_wide), - unit_test(utf8_display_len_non_wide), - unit_test(utf8_display_len_wide), - unit_test(utf8_display_len_all_wide), - unit_test(strip_quotes_does_nothing_when_no_quoted), - unit_test(strip_quotes_strips_first), - unit_test(strip_quotes_strips_last), - unit_test(strip_quotes_strips_both), - unit_test(format_call_external_argv_td), - unit_test(unique_filename_from_url_td), - - unit_test(clear_empty), - unit_test(reset_after_create), - unit_test(find_after_create), - unit_test(get_after_create_returns_null), - unit_test(add_one_and_complete), - unit_test(add_two_and_complete_returns_first), - unit_test(add_two_and_complete_returns_second), - unit_test(add_two_adds_two), - unit_test(add_two_same_adds_one), - unit_test(add_two_same_updates), - unit_test(complete_accented_with_accented), - unit_test(complete_accented_with_base), - unit_test(complete_both_with_accented), - unit_test(complete_both_with_base), - unit_test(complete_ignores_case), - unit_test(complete_previous), - - unit_test(create_jid_from_null_returns_null), - unit_test(create_jid_from_empty_string_returns_null), - unit_test(create_jid_from_full_returns_full), - unit_test(create_jid_from_full_returns_bare), - unit_test(create_jid_from_full_returns_resourcepart), - unit_test(create_jid_from_full_returns_localpart), - unit_test(create_jid_from_full_returns_domainpart), - unit_test(create_jid_from_full_nolocal_returns_full), - unit_test(create_jid_from_full_nolocal_returns_bare), - unit_test(create_jid_from_full_nolocal_returns_resourcepart), - unit_test(create_jid_from_full_nolocal_returns_domainpart), - unit_test(create_jid_from_full_nolocal_returns_null_localpart), - unit_test(create_jid_from_bare_returns_null_full), - unit_test(create_jid_from_bare_returns_null_resource), - unit_test(create_jid_from_bare_returns_bare), - unit_test(create_jid_from_bare_returns_localpart), - unit_test(create_jid_from_bare_returns_domainpart), - unit_test(create_room_jid_returns_room), - unit_test(create_room_jid_returns_nick), - unit_test(create_with_slash_in_resource), - unit_test(create_with_at_in_resource), - unit_test(create_with_at_and_slash_in_resource), - unit_test(create_full_with_trailing_slash), - unit_test(returns_fulljid_when_exists), - unit_test(returns_barejid_when_fulljid_not_exists), - - unit_test(parse_null_returns_null), - unit_test(parse_empty_returns_null), - unit_test(parse_space_returns_null), - unit_test(parse_cmd_no_args_returns_null), - unit_test(parse_cmd_with_space_returns_null), - unit_test(parse_cmd_with_too_few_returns_null), - unit_test(parse_cmd_with_too_many_returns_null), - unit_test(parse_cmd_one_arg), - unit_test(parse_cmd_two_args), - unit_test(parse_cmd_three_args), - unit_test(parse_cmd_three_args_with_spaces), - unit_test(parse_cmd_with_freetext), - unit_test(parse_cmd_one_arg_with_freetext), - unit_test(parse_cmd_two_args_with_freetext), - unit_test(parse_cmd_min_zero), - unit_test(parse_cmd_min_zero_with_freetext), - unit_test(parse_cmd_with_quoted), - unit_test(parse_cmd_with_quoted_and_space), - unit_test(parse_cmd_with_quoted_and_many_spaces), - unit_test(parse_cmd_with_many_quoted_and_many_spaces), - unit_test(parse_cmd_freetext_with_quoted), - unit_test(parse_cmd_freetext_with_quoted_and_space), - unit_test(parse_cmd_freetext_with_quoted_and_many_spaces), - unit_test(parse_cmd_freetext_with_many_quoted_and_many_spaces), - unit_test(parse_cmd_with_quoted_freetext), - unit_test(parse_cmd_with_third_arg_quoted_0_min_3_max), - unit_test(parse_cmd_with_second_arg_quoted_0_min_3_max), - unit_test(parse_cmd_with_second_and_third_arg_quoted_0_min_3_max), - unit_test(count_one_token), - unit_test(count_one_token_quoted_no_whitespace), - unit_test(count_one_token_quoted_with_whitespace), - unit_test(count_two_tokens), - unit_test(count_two_tokens_first_quoted), - unit_test(count_two_tokens_second_quoted), - unit_test(count_two_tokens_both_quoted), - unit_test(get_first_of_one), - unit_test(get_first_of_two), - unit_test(get_first_two_of_three), - unit_test(get_first_two_of_three_first_quoted), - unit_test(get_first_two_of_three_second_quoted), - unit_test(get_first_two_of_three_first_and_second_quoted), - unit_test(parse_options_when_none_returns_empty_hasmap), - unit_test(parse_options_when_opt1_no_val_sets_error), - unit_test(parse_options_when_one_returns_map), - unit_test(parse_options_when_opt2_no_val_sets_error), - unit_test(parse_options_when_two_returns_map), - unit_test(parse_options_when_opt3_no_val_sets_error), - unit_test(parse_options_when_three_returns_map), - unit_test(parse_options_when_unknown_opt_sets_error), - unit_test(parse_options_with_duplicated_option_sets_error), - - unit_test(empty_list_when_none_added), - unit_test(contains_one_element), - unit_test(first_element_correct), - unit_test(contains_two_elements), - unit_test(first_and_second_elements_correct), - unit_test(contains_three_elements), - unit_test(first_three_elements_correct), - unit_test(add_twice_at_beginning_adds_once), - unit_test(add_twice_in_middle_adds_once), - unit_test(add_twice_at_end_adds_once), - unit_test(find_first_exists), - unit_test(find_second_exists), - unit_test(find_third_exists), - unit_test(find_returns_null), - unit_test(find_on_empty_returns_null), - unit_test(find_twice_returns_second_when_two_match), - unit_test(find_five_times_finds_fifth), - unit_test(find_twice_returns_first_when_two_match_and_reset), - unit_test(add_contact_with_no_group), - unit_test(add_contact_with_group), - unit_test(add_contact_with_two_groups), - unit_test(add_contact_with_three_groups), - unit_test(add_contact_with_three_groups_update_adding_two), - unit_test(add_contact_with_three_groups_update_removing_one), - unit_test(add_contact_with_three_groups_update_removing_two), - unit_test(add_contact_with_three_groups_update_removing_three), - unit_test(add_contact_with_three_groups_update_two_new), - unit_test(add_remove_contact_groups), - unit_test(add_contacts_with_different_groups), - unit_test(add_contacts_with_same_groups), - unit_test(add_contacts_with_overlapping_groups), - unit_test(remove_contact_with_remaining_in_group), - unit_test(get_contact_display_name), - unit_test(get_contact_display_name_is_barejid_if_name_is_empty), - unit_test(get_contact_display_name_is_passed_barejid_if_contact_does_not_exist), - - unit_test_setup_teardown(returns_false_when_chat_session_does_not_exist, - init_chat_sessions, - close_chat_sessions), - unit_test_setup_teardown(creates_chat_session_on_recipient_activity, - 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), - unit_test_setup_teardown(removes_chat_session, - init_chat_sessions, - close_chat_sessions), - - unit_test_setup_teardown(cmd_connect_shows_message_when_disconnecting, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_message_when_connecting, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_message_when_connected, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_when_no_account, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_fail_message, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_lowercases_argument_with_account, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_lowercases_argument_with_no_account, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_usage_when_no_server_value, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_message_when_connecting_with_account, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_connects_with_account, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_usage_when_server_no_port_value, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_usage_when_no_port_value, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_usage_when_port_no_server_value, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_message_when_port_0, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_message_when_port_minus1, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_message_when_port_65536, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_message_when_port_contains_chars, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_with_server_when_provided, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_with_port_when_provided, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_with_server_and_port_when_provided, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_usage_when_server_provided_twice, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_usage_when_port_provided_twice, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_usage_when_invalid_first_property, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_connect_shows_usage_when_invalid_second_property, - load_preferences, - close_preferences), - - unit_test(cmd_rooms_shows_message_when_disconnected), - unit_test(cmd_rooms_shows_message_when_disconnecting), - unit_test(cmd_rooms_shows_message_when_connecting), - unit_test(cmd_rooms_uses_account_default_when_no_arg), - unit_test(cmd_rooms_service_arg_used_when_passed), - unit_test(cmd_rooms_filter_arg_used_when_passed), - - unit_test(cmd_account_shows_usage_when_not_connected_and_no_args), - unit_test(cmd_account_shows_account_when_connected_and_no_args), - unit_test(cmd_account_list_shows_accounts), - unit_test(cmd_account_show_shows_usage_when_no_arg), - unit_test(cmd_account_show_shows_message_when_account_does_not_exist), - unit_test(cmd_account_show_shows_account_when_exists), - unit_test(cmd_account_add_shows_usage_when_no_arg), - unit_test(cmd_account_add_adds_account), - unit_test(cmd_account_enable_shows_usage_when_no_arg), - unit_test(cmd_account_enable_enables_account), - unit_test(cmd_account_enable_shows_message_when_account_doesnt_exist), - unit_test(cmd_account_disable_shows_usage_when_no_arg), - unit_test(cmd_account_disable_disables_account), - unit_test(cmd_account_disable_shows_message_when_account_doesnt_exist), - unit_test(cmd_account_rename_shows_usage_when_no_args), - unit_test(cmd_account_rename_shows_usage_when_one_arg), - unit_test(cmd_account_rename_renames_account), - unit_test(cmd_account_rename_shows_message_when_not_renamed), - unit_test(cmd_account_set_shows_usage_when_no_args), - unit_test(cmd_account_set_shows_usage_when_one_arg), - unit_test(cmd_account_set_shows_usage_when_two_args), - unit_test(cmd_account_set_shows_message_when_account_doesnt_exist), - unit_test(cmd_account_set_jid_shows_message_for_malformed_jid), - unit_test(cmd_account_set_jid_sets_barejid), - unit_test(cmd_account_set_jid_sets_resource), - unit_test(cmd_account_set_server_sets_server), - unit_test(cmd_account_set_resource_sets_resource), - unit_test(cmd_account_set_resource_sets_resource_with_online_message), - unit_test(cmd_account_set_password_sets_password), - unit_test(cmd_account_set_eval_password_sets_eval_password), - unit_test(cmd_account_set_password_when_eval_password_set), - unit_test(cmd_account_set_eval_password_when_password_set), - unit_test(cmd_account_set_muc_sets_muc), - unit_test(cmd_account_set_nick_sets_nick), + const struct CMUnitTest all_tests[] = { + + cmocka_unit_test(replace_one_substr), + cmocka_unit_test(replace_one_substr_beginning), + cmocka_unit_test(replace_one_substr_end), + cmocka_unit_test(replace_two_substr), + cmocka_unit_test(replace_char), + cmocka_unit_test(replace_when_none), + cmocka_unit_test(replace_when_match), + cmocka_unit_test(replace_when_string_empty), + cmocka_unit_test(replace_when_string_null), + cmocka_unit_test(replace_when_sub_empty), + cmocka_unit_test(replace_when_sub_null), + cmocka_unit_test(replace_when_new_empty), + cmocka_unit_test(replace_when_new_null), + cmocka_unit_test(test_online_is_valid_resource_presence_string), + cmocka_unit_test(test_chat_is_valid_resource_presence_string), + cmocka_unit_test(test_away_is_valid_resource_presence_string), + cmocka_unit_test(test_xa_is_valid_resource_presence_string), + cmocka_unit_test(test_dnd_is_valid_resource_presence_string), + cmocka_unit_test(test_available_is_not_valid_resource_presence_string), + cmocka_unit_test(test_unavailable_is_not_valid_resource_presence_string), + cmocka_unit_test(test_blah_is_not_valid_resource_presence_string), + cmocka_unit_test(utf8_display_len_null_str), + cmocka_unit_test(utf8_display_len_1_non_wide), + cmocka_unit_test(utf8_display_len_1_wide), + cmocka_unit_test(utf8_display_len_non_wide), + cmocka_unit_test(utf8_display_len_wide), + cmocka_unit_test(utf8_display_len_all_wide), + cmocka_unit_test(strip_quotes_does_nothing_when_no_quoted), + cmocka_unit_test(strip_quotes_strips_first), + cmocka_unit_test(strip_quotes_strips_last), + cmocka_unit_test(strip_quotes_strips_both), + cmocka_unit_test(format_call_external_argv_td), + cmocka_unit_test(unique_filename_from_url_td), + + cmocka_unit_test(clear_empty), + cmocka_unit_test(reset_after_create), + cmocka_unit_test(find_after_create), + cmocka_unit_test(get_after_create_returns_null), + cmocka_unit_test(add_one_and_complete), + cmocka_unit_test(add_two_and_complete_returns_first), + cmocka_unit_test(add_two_and_complete_returns_second), + cmocka_unit_test(add_two_adds_two), + cmocka_unit_test(add_two_same_adds_one), + cmocka_unit_test(add_two_same_updates), + cmocka_unit_test(complete_accented_with_accented), + cmocka_unit_test(complete_accented_with_base), + cmocka_unit_test(complete_both_with_accented), + cmocka_unit_test(complete_both_with_base), + cmocka_unit_test(complete_ignores_case), + cmocka_unit_test(complete_previous), + + cmocka_unit_test(create_jid_from_null_returns_null), + cmocka_unit_test(create_jid_from_empty_string_returns_null), + cmocka_unit_test(create_jid_from_full_returns_full), + cmocka_unit_test(create_jid_from_full_returns_bare), + cmocka_unit_test(create_jid_from_full_returns_resourcepart), + cmocka_unit_test(create_jid_from_full_returns_localpart), + cmocka_unit_test(create_jid_from_full_returns_domainpart), + cmocka_unit_test(create_jid_from_full_nolocal_returns_full), + cmocka_unit_test(create_jid_from_full_nolocal_returns_bare), + cmocka_unit_test(create_jid_from_full_nolocal_returns_resourcepart), + cmocka_unit_test(create_jid_from_full_nolocal_returns_domainpart), + cmocka_unit_test(create_jid_from_full_nolocal_returns_null_localpart), + cmocka_unit_test(create_jid_from_bare_returns_null_full), + cmocka_unit_test(create_jid_from_bare_returns_null_resource), + cmocka_unit_test(create_jid_from_bare_returns_bare), + cmocka_unit_test(create_jid_from_bare_returns_localpart), + cmocka_unit_test(create_jid_from_bare_returns_domainpart), + cmocka_unit_test(create_room_jid_returns_room), + cmocka_unit_test(create_room_jid_returns_nick), + cmocka_unit_test(create_with_slash_in_resource), + cmocka_unit_test(create_with_at_in_resource), + cmocka_unit_test(create_with_at_and_slash_in_resource), + cmocka_unit_test(create_full_with_trailing_slash), + cmocka_unit_test(returns_fulljid_when_exists), + cmocka_unit_test(returns_barejid_when_fulljid_not_exists), + + cmocka_unit_test(parse_null_returns_null), + cmocka_unit_test(parse_empty_returns_null), + cmocka_unit_test(parse_space_returns_null), + cmocka_unit_test(parse_cmd_no_args_returns_null), + cmocka_unit_test(parse_cmd_with_space_returns_null), + cmocka_unit_test(parse_cmd_with_too_few_returns_null), + cmocka_unit_test(parse_cmd_with_too_many_returns_null), + cmocka_unit_test(parse_cmd_one_arg), + cmocka_unit_test(parse_cmd_two_args), + cmocka_unit_test(parse_cmd_three_args), + cmocka_unit_test(parse_cmd_three_args_with_spaces), + cmocka_unit_test(parse_cmd_with_freetext), + cmocka_unit_test(parse_cmd_one_arg_with_freetext), + cmocka_unit_test(parse_cmd_two_args_with_freetext), + cmocka_unit_test(parse_cmd_min_zero), + cmocka_unit_test(parse_cmd_min_zero_with_freetext), + cmocka_unit_test(parse_cmd_with_quoted), + cmocka_unit_test(parse_cmd_with_quoted_and_space), + cmocka_unit_test(parse_cmd_with_quoted_and_many_spaces), + cmocka_unit_test(parse_cmd_with_many_quoted_and_many_spaces), + cmocka_unit_test(parse_cmd_freetext_with_quoted), + cmocka_unit_test(parse_cmd_freetext_with_quoted_and_space), + cmocka_unit_test(parse_cmd_freetext_with_quoted_and_many_spaces), + cmocka_unit_test(parse_cmd_freetext_with_many_quoted_and_many_spaces), + cmocka_unit_test(parse_cmd_with_quoted_freetext), + cmocka_unit_test(parse_cmd_with_third_arg_quoted_0_min_3_max), + cmocka_unit_test(parse_cmd_with_second_arg_quoted_0_min_3_max), + cmocka_unit_test(parse_cmd_with_second_and_third_arg_quoted_0_min_3_max), + cmocka_unit_test(count_one_token), + cmocka_unit_test(count_one_token_quoted_no_whitespace), + cmocka_unit_test(count_one_token_quoted_with_whitespace), + cmocka_unit_test(count_two_tokens), + cmocka_unit_test(count_two_tokens_first_quoted), + cmocka_unit_test(count_two_tokens_second_quoted), + cmocka_unit_test(count_two_tokens_both_quoted), + cmocka_unit_test(get_first_of_one), + cmocka_unit_test(get_first_of_two), + cmocka_unit_test(get_first_two_of_three), + cmocka_unit_test(get_first_two_of_three_first_quoted), + cmocka_unit_test(get_first_two_of_three_second_quoted), + cmocka_unit_test(get_first_two_of_three_first_and_second_quoted), + cmocka_unit_test(parse_options_when_none_returns_empty_hasmap), + cmocka_unit_test(parse_options_when_opt1_no_val_sets_error), + cmocka_unit_test(parse_options_when_one_returns_map), + cmocka_unit_test(parse_options_when_opt2_no_val_sets_error), + cmocka_unit_test(parse_options_when_two_returns_map), + cmocka_unit_test(parse_options_when_opt3_no_val_sets_error), + cmocka_unit_test(parse_options_when_three_returns_map), + cmocka_unit_test(parse_options_when_unknown_opt_sets_error), + cmocka_unit_test(parse_options_with_duplicated_option_sets_error), + + cmocka_unit_test(empty_list_when_none_added), + cmocka_unit_test(contains_one_element), + cmocka_unit_test(first_element_correct), + cmocka_unit_test(contains_two_elements), + cmocka_unit_test(first_and_second_elements_correct), + cmocka_unit_test(contains_three_elements), + cmocka_unit_test(first_three_elements_correct), + cmocka_unit_test(add_twice_at_beginning_adds_once), + cmocka_unit_test(add_twice_in_middle_adds_once), + cmocka_unit_test(add_twice_at_end_adds_once), + cmocka_unit_test(find_first_exists), + cmocka_unit_test(find_second_exists), + cmocka_unit_test(find_third_exists), + cmocka_unit_test(find_returns_null), + cmocka_unit_test(find_on_empty_returns_null), + cmocka_unit_test(find_twice_returns_second_when_two_match), + cmocka_unit_test(find_five_times_finds_fifth), + cmocka_unit_test(find_twice_returns_first_when_two_match_and_reset), + cmocka_unit_test(add_contact_with_no_group), + cmocka_unit_test(add_contact_with_group), + cmocka_unit_test(add_contact_with_two_groups), + cmocka_unit_test(add_contact_with_three_groups), + cmocka_unit_test(add_contact_with_three_groups_update_adding_two), + cmocka_unit_test(add_contact_with_three_groups_update_removing_one), + cmocka_unit_test(add_contact_with_three_groups_update_removing_two), + cmocka_unit_test(add_contact_with_three_groups_update_removing_three), + cmocka_unit_test(add_contact_with_three_groups_update_two_new), + cmocka_unit_test(add_remove_contact_groups), + cmocka_unit_test(add_contacts_with_different_groups), + cmocka_unit_test(add_contacts_with_same_groups), + cmocka_unit_test(add_contacts_with_overlapping_groups), + cmocka_unit_test(remove_contact_with_remaining_in_group), + cmocka_unit_test(get_contact_display_name), + cmocka_unit_test(get_contact_display_name_is_barejid_if_name_is_empty), + cmocka_unit_test(get_contact_display_name_is_passed_barejid_if_contact_does_not_exist), + + cmocka_unit_test_setup_teardown(returns_false_when_chat_session_does_not_exist, + init_chat_sessions, + close_chat_sessions), + cmocka_unit_test_setup_teardown(creates_chat_session_on_recipient_activity, + init_chat_sessions, + close_chat_sessions), + cmocka_unit_test_setup_teardown(replaces_chat_session_on_recipient_activity_with_different_resource, + init_chat_sessions, + close_chat_sessions), + cmocka_unit_test_setup_teardown(removes_chat_session, + init_chat_sessions, + close_chat_sessions), + + cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_disconnecting, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_connecting, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_connected, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_when_no_account, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_fail_message, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_lowercases_argument_with_account, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_lowercases_argument_with_no_account, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_asks_password_when_not_in_account, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_no_server_value, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_connecting_with_account, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_connects_with_account, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_server_no_port_value, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_no_port_value, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_port_no_server_value, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_port_0, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_port_minus1, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_port_65536, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_message_when_port_contains_chars, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_with_server_when_provided, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_with_port_when_provided, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_with_server_and_port_when_provided, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_server_provided_twice, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_port_provided_twice, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_invalid_first_property, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_connect_shows_usage_when_invalid_second_property, + load_preferences, + close_preferences), + + cmocka_unit_test(cmd_rooms_shows_message_when_disconnected), + cmocka_unit_test(cmd_rooms_shows_message_when_disconnecting), + cmocka_unit_test(cmd_rooms_shows_message_when_connecting), + cmocka_unit_test(cmd_rooms_uses_account_default_when_no_arg), + cmocka_unit_test(cmd_rooms_service_arg_used_when_passed), + cmocka_unit_test(cmd_rooms_filter_arg_used_when_passed), + + cmocka_unit_test(cmd_account_shows_usage_when_not_connected_and_no_args), + cmocka_unit_test(cmd_account_shows_account_when_connected_and_no_args), + cmocka_unit_test(cmd_account_list_shows_accounts), + cmocka_unit_test(cmd_account_show_shows_usage_when_no_arg), + cmocka_unit_test(cmd_account_show_shows_message_when_account_does_not_exist), + cmocka_unit_test(cmd_account_show_shows_account_when_exists), + cmocka_unit_test(cmd_account_add_shows_usage_when_no_arg), + cmocka_unit_test(cmd_account_add_adds_account), + cmocka_unit_test(cmd_account_enable_shows_usage_when_no_arg), + cmocka_unit_test(cmd_account_enable_enables_account), + cmocka_unit_test(cmd_account_enable_shows_message_when_account_doesnt_exist), + cmocka_unit_test(cmd_account_disable_shows_usage_when_no_arg), + cmocka_unit_test(cmd_account_disable_disables_account), + cmocka_unit_test(cmd_account_disable_shows_message_when_account_doesnt_exist), + cmocka_unit_test(cmd_account_rename_shows_usage_when_no_args), + cmocka_unit_test(cmd_account_rename_shows_usage_when_one_arg), + cmocka_unit_test(cmd_account_rename_renames_account), + cmocka_unit_test(cmd_account_rename_shows_message_when_not_renamed), + cmocka_unit_test(cmd_account_set_shows_usage_when_no_args), + cmocka_unit_test(cmd_account_set_shows_usage_when_one_arg), + cmocka_unit_test(cmd_account_set_shows_usage_when_two_args), + cmocka_unit_test(cmd_account_set_shows_message_when_account_doesnt_exist), + cmocka_unit_test(cmd_account_set_jid_shows_message_for_malformed_jid), + cmocka_unit_test(cmd_account_set_jid_sets_barejid), + cmocka_unit_test(cmd_account_set_jid_sets_resource), + cmocka_unit_test(cmd_account_set_server_sets_server), + cmocka_unit_test(cmd_account_set_resource_sets_resource), + cmocka_unit_test(cmd_account_set_resource_sets_resource_with_online_message), + cmocka_unit_test(cmd_account_set_password_sets_password), + cmocka_unit_test(cmd_account_set_eval_password_sets_eval_password), + cmocka_unit_test(cmd_account_set_password_when_eval_password_set), + cmocka_unit_test(cmd_account_set_eval_password_when_password_set), + cmocka_unit_test(cmd_account_set_muc_sets_muc), + cmocka_unit_test(cmd_account_set_nick_sets_nick), #ifdef HAVE_LIBOTR - unit_test(cmd_account_show_message_for_missing_otr_policy), - unit_test(cmd_account_show_message_for_invalid_otr_policy), - unit_test(cmd_account_set_otr_sets_otr), + cmocka_unit_test(cmd_account_show_message_for_missing_otr_policy), + cmocka_unit_test(cmd_account_show_message_for_invalid_otr_policy), + cmocka_unit_test(cmd_account_set_otr_sets_otr), #endif - unit_test(cmd_account_set_status_shows_message_when_invalid_status), - unit_test(cmd_account_set_status_sets_status_when_valid), - unit_test(cmd_account_set_status_sets_status_when_last), - unit_test(cmd_account_set_invalid_presence_string_priority_shows_message), - unit_test(cmd_account_set_last_priority_shows_message), - unit_test(cmd_account_set_online_priority_sets_preference), - unit_test(cmd_account_set_chat_priority_sets_preference), - unit_test(cmd_account_set_away_priority_sets_preference), - unit_test(cmd_account_set_xa_priority_sets_preference), - unit_test(cmd_account_set_dnd_priority_sets_preference), - unit_test(cmd_account_set_priority_too_low_shows_message), - unit_test(cmd_account_set_priority_too_high_shows_message), - unit_test(cmd_account_set_priority_when_not_number_shows_message), - unit_test(cmd_account_set_priority_when_empty_shows_message), - unit_test(cmd_account_set_priority_updates_presence_when_account_connected_with_presence), - unit_test(cmd_account_clear_shows_usage_when_no_args), - unit_test(cmd_account_clear_shows_usage_when_one_arg), - unit_test(cmd_account_clear_shows_message_when_account_doesnt_exist), - unit_test(cmd_account_clear_shows_message_when_invalid_property), - - unit_test(cmd_sub_shows_message_when_not_connected), - unit_test(cmd_sub_shows_usage_when_no_arg), - - unit_test(contact_in_group), - unit_test(contact_not_in_group), - unit_test(contact_name_when_name_exists), - unit_test(contact_jid_when_name_not_exists), - unit_test(contact_string_when_name_exists), - unit_test(contact_string_when_name_not_exists), - unit_test(contact_string_when_default_resource), - unit_test(contact_presence_offline), - unit_test(contact_presence_uses_highest_priority), - unit_test(contact_presence_chat_when_same_prioroty), - unit_test(contact_presence_online_when_same_prioroty), - unit_test(contact_presence_away_when_same_prioroty), - unit_test(contact_presence_xa_when_same_prioroty), - unit_test(contact_presence_dnd), - unit_test(contact_subscribed_when_to), - unit_test(contact_subscribed_when_both), - unit_test(contact_not_subscribed_when_from), - unit_test(contact_not_subscribed_when_no_subscription_value), - unit_test(contact_not_available), - unit_test(contact_not_available_when_highest_priority_away), - unit_test(contact_not_available_when_highest_priority_xa), - unit_test(contact_not_available_when_highest_priority_dnd), - unit_test(contact_available_when_highest_priority_online), - unit_test(contact_available_when_highest_priority_chat), - - unit_test(cmd_presence_shows_usage_when_bad_subcmd), - unit_test(cmd_presence_shows_usage_when_bad_console_setting), - 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), - unit_test_setup_teardown(cmd_presence_console_sets_online, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_presence_console_sets_none, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_presence_chat_sets_all, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_presence_chat_sets_online, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_presence_chat_sets_none, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_presence_room_sets_all, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_presence_room_sets_online, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_presence_room_sets_none, - load_preferences, - close_preferences), - - unit_test_setup_teardown(statuses_console_defaults_to_all, - load_preferences, - close_preferences), - unit_test_setup_teardown(statuses_chat_defaults_to_all, - load_preferences, - close_preferences), - unit_test_setup_teardown(statuses_muc_defaults_to_all, - load_preferences, - close_preferences), - - unit_test_setup_teardown(console_shows_online_presence_when_set_online, - load_preferences, - close_preferences), - unit_test_setup_teardown(console_shows_online_presence_when_set_all, - load_preferences, - close_preferences), - unit_test_setup_teardown(console_shows_dnd_presence_when_set_all, - load_preferences, - close_preferences), - unit_test_setup_teardown(handle_offline_removes_chat_session, - load_preferences, - close_preferences), - unit_test(lost_connection_clears_chat_sessions), - - unit_test(cmd_alias_add_shows_usage_when_no_args), - unit_test(cmd_alias_add_shows_usage_when_no_value), - 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), - unit_test_setup_teardown(cmd_alias_add_shows_message_when_exists, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_alias_remove_removes_alias, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_alias_remove_shows_message_when_no_alias, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_alias_list_shows_all_aliases, - 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), - unit_test_setup_teardown(test_muc_invites_count_0, muc_before_test, muc_after_test), - unit_test_setup_teardown(test_muc_invites_count_5, muc_before_test, muc_after_test), - unit_test_setup_teardown(test_muc_room_is_not_active, muc_before_test, muc_after_test), - unit_test_setup_teardown(test_muc_active, muc_before_test, muc_after_test), - - unit_test(cmd_bookmark_shows_message_when_disconnected), - unit_test(cmd_bookmark_shows_message_when_disconnecting), - unit_test(cmd_bookmark_shows_message_when_connecting), - unit_test(cmd_bookmark_shows_usage_when_no_args), - unit_test(cmd_bookmark_list_shows_bookmarks), - unit_test(cmd_bookmark_add_shows_message_when_invalid_jid), - unit_test(cmd_bookmark_add_adds_bookmark_with_jid), - unit_test(cmd_bookmark_uses_roomjid_in_room), - unit_test(cmd_bookmark_add_uses_roomjid_in_room), - unit_test(cmd_bookmark_add_uses_supplied_jid_in_room), - unit_test(cmd_bookmark_remove_uses_roomjid_in_room), - unit_test(cmd_bookmark_remove_uses_supplied_jid_in_room), - unit_test(cmd_bookmark_add_adds_bookmark_with_jid_nick), - unit_test(cmd_bookmark_add_adds_bookmark_with_jid_autojoin), - unit_test(cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin), - unit_test(cmd_bookmark_remove_removes_bookmark), - unit_test(cmd_bookmark_remove_shows_message_when_no_bookmark), + cmocka_unit_test(cmd_account_set_status_shows_message_when_invalid_status), + cmocka_unit_test(cmd_account_set_status_sets_status_when_valid), + cmocka_unit_test(cmd_account_set_status_sets_status_when_last), + cmocka_unit_test(cmd_account_set_invalid_presence_string_priority_shows_message), + cmocka_unit_test(cmd_account_set_last_priority_shows_message), + cmocka_unit_test(cmd_account_set_online_priority_sets_preference), + cmocka_unit_test(cmd_account_set_chat_priority_sets_preference), + cmocka_unit_test(cmd_account_set_away_priority_sets_preference), + cmocka_unit_test(cmd_account_set_xa_priority_sets_preference), + cmocka_unit_test(cmd_account_set_dnd_priority_sets_preference), + cmocka_unit_test(cmd_account_set_priority_too_low_shows_message), + cmocka_unit_test(cmd_account_set_priority_too_high_shows_message), + cmocka_unit_test(cmd_account_set_priority_when_not_number_shows_message), + cmocka_unit_test(cmd_account_set_priority_when_empty_shows_message), + cmocka_unit_test(cmd_account_set_priority_updates_presence_when_account_connected_with_presence), + cmocka_unit_test(cmd_account_clear_shows_usage_when_no_args), + cmocka_unit_test(cmd_account_clear_shows_usage_when_one_arg), + cmocka_unit_test(cmd_account_clear_shows_message_when_account_doesnt_exist), + cmocka_unit_test(cmd_account_clear_shows_message_when_invalid_property), + + cmocka_unit_test(cmd_sub_shows_message_when_not_connected), + cmocka_unit_test(cmd_sub_shows_usage_when_no_arg), + + cmocka_unit_test(contact_in_group), + cmocka_unit_test(contact_not_in_group), + cmocka_unit_test(contact_name_when_name_exists), + cmocka_unit_test(contact_jid_when_name_not_exists), + cmocka_unit_test(contact_string_when_name_exists), + cmocka_unit_test(contact_string_when_name_not_exists), + cmocka_unit_test(contact_string_when_default_resource), + cmocka_unit_test(contact_presence_offline), + cmocka_unit_test(contact_presence_uses_highest_priority), + cmocka_unit_test(contact_presence_chat_when_same_prioroty), + cmocka_unit_test(contact_presence_online_when_same_prioroty), + cmocka_unit_test(contact_presence_away_when_same_prioroty), + cmocka_unit_test(contact_presence_xa_when_same_prioroty), + cmocka_unit_test(contact_presence_dnd), + cmocka_unit_test(contact_subscribed_when_to), + cmocka_unit_test(contact_subscribed_when_both), + cmocka_unit_test(contact_not_subscribed_when_from), + cmocka_unit_test(contact_not_subscribed_when_no_subscription_value), + cmocka_unit_test(contact_not_available), + cmocka_unit_test(contact_not_available_when_highest_priority_away), + cmocka_unit_test(contact_not_available_when_highest_priority_xa), + cmocka_unit_test(contact_not_available_when_highest_priority_dnd), + cmocka_unit_test(contact_available_when_highest_priority_online), + cmocka_unit_test(contact_available_when_highest_priority_chat), + + cmocka_unit_test(cmd_presence_shows_usage_when_bad_subcmd), + cmocka_unit_test(cmd_presence_shows_usage_when_bad_console_setting), + cmocka_unit_test(cmd_presence_shows_usage_when_bad_chat_setting), + cmocka_unit_test(cmd_presence_shows_usage_when_bad_muc_setting), + cmocka_unit_test_setup_teardown(cmd_presence_console_sets_all, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_presence_console_sets_online, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_presence_console_sets_none, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_presence_chat_sets_all, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_presence_chat_sets_online, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_presence_chat_sets_none, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_presence_room_sets_all, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_presence_room_sets_online, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_presence_room_sets_none, + load_preferences, + close_preferences), + + cmocka_unit_test_setup_teardown(statuses_console_defaults_to_all, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(statuses_chat_defaults_to_all, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(statuses_muc_defaults_to_all, + load_preferences, + close_preferences), + + cmocka_unit_test_setup_teardown(console_shows_online_presence_when_set_online, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(console_shows_online_presence_when_set_all, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(console_shows_dnd_presence_when_set_all, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(handle_offline_removes_chat_session, + load_preferences, + close_preferences), + cmocka_unit_test(lost_connection_clears_chat_sessions), + + cmocka_unit_test(cmd_alias_add_shows_usage_when_no_args), + cmocka_unit_test(cmd_alias_add_shows_usage_when_no_value), + cmocka_unit_test(cmd_alias_remove_shows_usage_when_no_args), + cmocka_unit_test(cmd_alias_show_usage_when_invalid_subcmd), + cmocka_unit_test_setup_teardown(cmd_alias_add_adds_alias, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_alias_add_shows_message_when_exists, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_alias_remove_removes_alias, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_alias_remove_shows_message_when_no_alias, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_alias_list_shows_all_aliases, + load_preferences, + close_preferences), + + cmocka_unit_test_setup_teardown(test_muc_invites_add, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(test_muc_remove_invite, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(test_muc_invites_count_0, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(test_muc_invites_count_5, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(test_muc_room_is_not_active, muc_before_test, muc_after_test), + cmocka_unit_test_setup_teardown(test_muc_active, muc_before_test, muc_after_test), + + cmocka_unit_test(cmd_bookmark_shows_message_when_disconnected), + cmocka_unit_test(cmd_bookmark_shows_message_when_disconnecting), + cmocka_unit_test(cmd_bookmark_shows_message_when_connecting), + cmocka_unit_test(cmd_bookmark_shows_usage_when_no_args), + cmocka_unit_test(cmd_bookmark_list_shows_bookmarks), + cmocka_unit_test(cmd_bookmark_add_shows_message_when_invalid_jid), + cmocka_unit_test(cmd_bookmark_add_adds_bookmark_with_jid), + cmocka_unit_test(cmd_bookmark_uses_roomjid_in_room), + cmocka_unit_test(cmd_bookmark_add_uses_roomjid_in_room), + cmocka_unit_test(cmd_bookmark_add_uses_supplied_jid_in_room), + cmocka_unit_test(cmd_bookmark_remove_uses_roomjid_in_room), + cmocka_unit_test(cmd_bookmark_remove_uses_supplied_jid_in_room), + cmocka_unit_test(cmd_bookmark_add_adds_bookmark_with_jid_nick), + cmocka_unit_test(cmd_bookmark_add_adds_bookmark_with_jid_autojoin), + cmocka_unit_test(cmd_bookmark_add_adds_bookmark_with_jid_nick_autojoin), + cmocka_unit_test(cmd_bookmark_remove_removes_bookmark), + cmocka_unit_test(cmd_bookmark_remove_shows_message_when_no_bookmark), #ifdef HAVE_LIBOTR - 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), - unit_test_setup_teardown(cmd_otr_log_off_disables_logging, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_otr_redact_redacts_logging, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_otr_log_on_shows_warning_when_chlog_disabled, - load_preferences, - close_preferences), - unit_test_setup_teardown(cmd_otr_log_redact_shows_warning_when_chlog_disabled, - 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), - unit_test(cmd_otr_gen_shows_message_when_disconnected), - unit_test(cmd_otr_gen_shows_message_when_connecting), - unit_test(cmd_otr_gen_shows_message_when_disconnecting), - unit_test(cmd_otr_myfp_shows_message_when_disconnected), - unit_test(cmd_otr_myfp_shows_message_when_connecting), - unit_test(cmd_otr_myfp_shows_message_when_disconnecting), - unit_test(cmd_otr_myfp_shows_message_when_no_key), - unit_test(cmd_otr_myfp_shows_my_fingerprint), - unit_test(cmd_otr_theirfp_shows_message_when_in_console), - unit_test(cmd_otr_theirfp_shows_message_when_in_muc), - unit_test(cmd_otr_theirfp_shows_message_when_in_private), - unit_test(cmd_otr_theirfp_shows_message_when_non_otr_chat_window), - unit_test(cmd_otr_theirfp_shows_fingerprint), - unit_test(cmd_otr_start_shows_message_when_in_console), - unit_test(cmd_otr_start_shows_message_when_in_muc), - unit_test(cmd_otr_start_shows_message_when_in_private), - 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), + cmocka_unit_test(cmd_otr_log_shows_usage_when_no_args), + cmocka_unit_test(cmd_otr_log_shows_usage_when_invalid_subcommand), + cmocka_unit_test_setup_teardown(cmd_otr_log_on_enables_logging, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_otr_log_off_disables_logging, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_otr_redact_redacts_logging, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_otr_log_on_shows_warning_when_chlog_disabled, + load_preferences, + close_preferences), + cmocka_unit_test_setup_teardown(cmd_otr_log_redact_shows_warning_when_chlog_disabled, + load_preferences, + close_preferences), + cmocka_unit_test(cmd_otr_libver_shows_libotr_version), + cmocka_unit_test(cmd_otr_gen_shows_message_when_not_connected), + cmocka_unit_test(cmd_otr_gen_generates_key_for_connected_account), + cmocka_unit_test(cmd_otr_gen_shows_message_when_disconnected), + cmocka_unit_test(cmd_otr_gen_shows_message_when_connecting), + cmocka_unit_test(cmd_otr_gen_shows_message_when_disconnecting), + cmocka_unit_test(cmd_otr_myfp_shows_message_when_disconnected), + cmocka_unit_test(cmd_otr_myfp_shows_message_when_connecting), + cmocka_unit_test(cmd_otr_myfp_shows_message_when_disconnecting), + cmocka_unit_test(cmd_otr_myfp_shows_message_when_no_key), + cmocka_unit_test(cmd_otr_myfp_shows_my_fingerprint), + cmocka_unit_test(cmd_otr_theirfp_shows_message_when_in_console), + cmocka_unit_test(cmd_otr_theirfp_shows_message_when_in_muc), + cmocka_unit_test(cmd_otr_theirfp_shows_message_when_in_private), + cmocka_unit_test(cmd_otr_theirfp_shows_message_when_non_otr_chat_window), + cmocka_unit_test(cmd_otr_theirfp_shows_fingerprint), + cmocka_unit_test(cmd_otr_start_shows_message_when_in_console), + cmocka_unit_test(cmd_otr_start_shows_message_when_in_muc), + cmocka_unit_test(cmd_otr_start_shows_message_when_in_private), + cmocka_unit_test(cmd_otr_start_shows_message_when_already_started), + cmocka_unit_test(cmd_otr_start_shows_message_when_no_key), + cmocka_unit_test_setup_teardown(cmd_otr_start_sends_otr_query_message_to_current_recipeint, + load_preferences, + close_preferences), #else - unit_test(cmd_otr_shows_message_when_otr_unsupported), + cmocka_unit_test(cmd_otr_shows_message_when_otr_unsupported), #endif #ifdef HAVE_LIBGPGME - unit_test(cmd_pgp_shows_usage_when_no_args), - unit_test(cmd_pgp_start_shows_message_when_disconnected), - unit_test(cmd_pgp_start_shows_message_when_disconnecting), - unit_test(cmd_pgp_start_shows_message_when_connecting), - unit_test(cmd_pgp_start_shows_message_when_no_arg_in_console), - unit_test(cmd_pgp_start_shows_message_when_no_arg_in_muc), - unit_test(cmd_pgp_start_shows_message_when_no_arg_in_conf), - unit_test(cmd_pgp_start_shows_message_when_no_arg_in_private), - unit_test(cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole), + cmocka_unit_test(cmd_pgp_shows_usage_when_no_args), + cmocka_unit_test(cmd_pgp_start_shows_message_when_disconnected), + cmocka_unit_test(cmd_pgp_start_shows_message_when_disconnecting), + cmocka_unit_test(cmd_pgp_start_shows_message_when_connecting), + cmocka_unit_test(cmd_pgp_start_shows_message_when_no_arg_in_console), + cmocka_unit_test(cmd_pgp_start_shows_message_when_no_arg_in_muc), + cmocka_unit_test(cmd_pgp_start_shows_message_when_no_arg_in_conf), + cmocka_unit_test(cmd_pgp_start_shows_message_when_no_arg_in_private), + cmocka_unit_test(cmd_pgp_start_shows_message_when_no_arg_in_xmlconsole), #else - unit_test(cmd_pgp_shows_message_when_pgp_unsupported), + cmocka_unit_test(cmd_pgp_shows_message_when_pgp_unsupported), #endif - unit_test(cmd_join_shows_message_when_disconnecting), - unit_test(cmd_join_shows_message_when_connecting), - unit_test(cmd_join_shows_message_when_disconnected), - unit_test(cmd_join_shows_error_message_when_invalid_room_jid), - unit_test(cmd_join_uses_account_mucservice_when_no_service_specified), - unit_test(cmd_join_uses_supplied_nick), - unit_test(cmd_join_uses_account_nick_when_not_supplied), - unit_test(cmd_join_uses_password_when_supplied), - - unit_test(cmd_roster_shows_message_when_disconnecting), - unit_test(cmd_roster_shows_message_when_connecting), - unit_test(cmd_roster_shows_message_when_disconnected), - unit_test(cmd_roster_shows_roster_when_no_args), - unit_test(cmd_roster_add_shows_message_when_no_jid), - unit_test(cmd_roster_add_sends_roster_add_request), - unit_test(cmd_roster_remove_shows_message_when_no_jid), - unit_test(cmd_roster_remove_sends_roster_remove_request), - unit_test(cmd_roster_remove_nickname_sends_roster_remove_request), - unit_test(cmd_roster_nick_shows_message_when_no_jid), - unit_test(cmd_roster_nick_shows_message_when_no_nick), - unit_test(cmd_roster_nick_shows_message_when_no_contact_exists), - unit_test(cmd_roster_nick_sends_name_change_request), - unit_test(cmd_roster_clearnick_shows_message_when_no_jid), - unit_test(cmd_roster_clearnick_shows_message_when_no_contact_exists), - unit_test(cmd_roster_clearnick_sends_name_change_request_with_empty_nick), - - unit_test(get_form_type_field_returns_null_no_fields), - unit_test(get_form_type_field_returns_null_when_not_present), - unit_test(get_form_type_field_returns_value_when_present), - unit_test(get_field_type_returns_unknown_when_no_fields), - unit_test(get_field_type_returns_correct_type), - unit_test(set_value_adds_when_none), - unit_test(set_value_updates_when_one), - unit_test(add_unique_value_adds_when_none), - unit_test(add_unique_value_does_nothing_when_exists), - unit_test(add_unique_value_adds_when_doesnt_exist), - unit_test(add_value_adds_when_none), - unit_test(add_value_adds_when_some), - unit_test(add_value_adds_when_exists), - unit_test(remove_value_does_nothing_when_none), - unit_test(remove_value_does_nothing_when_doesnt_exist), - unit_test(remove_value_removes_when_one), - unit_test(remove_value_removes_when_many), - unit_test(remove_text_multi_value_does_nothing_when_none), - unit_test(remove_text_multi_value_does_nothing_when_doesnt_exist), - unit_test(remove_text_multi_value_removes_when_one), - unit_test(remove_text_multi_value_removes_when_many), - - unit_test_setup_teardown(clears_chat_sessions, - load_preferences, - close_preferences), - - unit_test(prof_partial_occurrences_tests), - unit_test(prof_whole_occurrences_tests), - unit_test(prof_occurrences_of_large_message_tests), - - unit_test(returns_no_commands), - unit_test(returns_commands), - - unit_test(returns_empty_list_when_none), - unit_test(returns_added_feature), - unit_test(resets_features_on_close), - unit_test(returns_all_added_features), - unit_test(does_not_add_duplicate_feature), - unit_test(removes_plugin_features), - unit_test(does_not_remove_feature_when_more_than_one_reference), + cmocka_unit_test(cmd_join_shows_message_when_disconnecting), + cmocka_unit_test(cmd_join_shows_message_when_connecting), + cmocka_unit_test(cmd_join_shows_message_when_disconnected), + cmocka_unit_test(cmd_join_shows_error_message_when_invalid_room_jid), + cmocka_unit_test(cmd_join_uses_account_mucservice_when_no_service_specified), + cmocka_unit_test(cmd_join_uses_supplied_nick), + cmocka_unit_test(cmd_join_uses_account_nick_when_not_supplied), + cmocka_unit_test(cmd_join_uses_password_when_supplied), + + cmocka_unit_test(cmd_roster_shows_message_when_disconnecting), + cmocka_unit_test(cmd_roster_shows_message_when_connecting), + cmocka_unit_test(cmd_roster_shows_message_when_disconnected), + cmocka_unit_test(cmd_roster_shows_roster_when_no_args), + cmocka_unit_test(cmd_roster_add_shows_message_when_no_jid), + cmocka_unit_test(cmd_roster_add_sends_roster_add_request), + cmocka_unit_test(cmd_roster_remove_shows_message_when_no_jid), + cmocka_unit_test(cmd_roster_remove_sends_roster_remove_request), + cmocka_unit_test(cmd_roster_remove_nickname_sends_roster_remove_request), + cmocka_unit_test(cmd_roster_nick_shows_message_when_no_jid), + cmocka_unit_test(cmd_roster_nick_shows_message_when_no_nick), + cmocka_unit_test(cmd_roster_nick_shows_message_when_no_contact_exists), + cmocka_unit_test(cmd_roster_nick_sends_name_change_request), + cmocka_unit_test(cmd_roster_clearnick_shows_message_when_no_jid), + cmocka_unit_test(cmd_roster_clearnick_shows_message_when_no_contact_exists), + cmocka_unit_test(cmd_roster_clearnick_sends_name_change_request_with_empty_nick), + + cmocka_unit_test(get_form_type_field_returns_null_no_fields), + cmocka_unit_test(get_form_type_field_returns_null_when_not_present), + cmocka_unit_test(get_form_type_field_returns_value_when_present), + cmocka_unit_test(get_field_type_returns_unknown_when_no_fields), + cmocka_unit_test(get_field_type_returns_correct_type), + cmocka_unit_test(set_value_adds_when_none), + cmocka_unit_test(set_value_updates_when_one), + cmocka_unit_test(add_unique_value_adds_when_none), + cmocka_unit_test(add_unique_value_does_nothing_when_exists), + cmocka_unit_test(add_unique_value_adds_when_doesnt_exist), + cmocka_unit_test(add_value_adds_when_none), + cmocka_unit_test(add_value_adds_when_some), + cmocka_unit_test(add_value_adds_when_exists), + cmocka_unit_test(remove_value_does_nothing_when_none), + cmocka_unit_test(remove_value_does_nothing_when_doesnt_exist), + cmocka_unit_test(remove_value_removes_when_one), + cmocka_unit_test(remove_value_removes_when_many), + cmocka_unit_test(remove_text_multi_value_does_nothing_when_none), + cmocka_unit_test(remove_text_multi_value_does_nothing_when_doesnt_exist), + cmocka_unit_test(remove_text_multi_value_removes_when_one), + cmocka_unit_test(remove_text_multi_value_removes_when_many), + + cmocka_unit_test_setup_teardown(clears_chat_sessions, + load_preferences, + close_preferences), + + cmocka_unit_test(prof_partial_occurrences_tests), + cmocka_unit_test(prof_whole_occurrences_tests), + cmocka_unit_test(prof_occurrences_of_large_message_tests), + + cmocka_unit_test(returns_no_commands), + cmocka_unit_test(returns_commands), + + cmocka_unit_test(returns_empty_list_when_none), + cmocka_unit_test(returns_added_feature), + cmocka_unit_test(resets_features_on_close), + cmocka_unit_test(returns_all_added_features), + cmocka_unit_test(does_not_add_duplicate_feature), + cmocka_unit_test(removes_plugin_features), + cmocka_unit_test(does_not_remove_feature_when_more_than_one_reference), }; - return run_tests(all_tests); + return cmocka_run_group_tests(all_tests, NULL, NULL); }