mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Refactored testsuite for less verbose output
This commit is contained in:
parent
c7325de073
commit
10fb692f7f
@ -44,7 +44,7 @@ void add_one_and_complete(void **state)
|
||||
autocomplete_add(ac, "Hello");
|
||||
char *result = autocomplete_complete(ac, "Hel");
|
||||
|
||||
assert_string_equal("Hello", result);
|
||||
assert_string_equal("Hello aaaa", result);
|
||||
|
||||
autocomplete_clear(ac);
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ void replace_two_substr(void **state)
|
||||
|
||||
char *result = str_replace(string, sub, new);
|
||||
|
||||
assert_string_equal("it was a was string", result);
|
||||
assert_string_equal("it was a was string ssss", result);
|
||||
}
|
||||
|
||||
void replace_char(void **state)
|
||||
|
@ -1,4 +1,7 @@
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stddef.h>
|
||||
#include <setjmp.h>
|
||||
#include <cmocka.h>
|
||||
@ -16,8 +19,12 @@
|
||||
#include "test_parser.h"
|
||||
#include "test_roster_list.h"
|
||||
|
||||
#define PROF_RUN_TESTS(name) fprintf(stderr, "\n-> Running %s\n", #name); \
|
||||
fflush(stderr); \
|
||||
result += run_tests(name);
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
const UnitTest tests[] = {
|
||||
const UnitTest common_tests[] = {
|
||||
unit_test(replace_one_substr),
|
||||
unit_test(replace_one_substr_beginning),
|
||||
unit_test(replace_one_substr_end),
|
||||
@ -58,7 +65,9 @@ int main(int argc, char* argv[]) {
|
||||
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),
|
||||
};
|
||||
|
||||
const UnitTest autocomplete_tests[] = {
|
||||
unit_test(clear_empty),
|
||||
unit_test(reset_after_create),
|
||||
unit_test(find_after_create),
|
||||
@ -69,7 +78,9 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(add_two_adds_two),
|
||||
unit_test(add_two_same_adds_one),
|
||||
unit_test(add_two_same_updates),
|
||||
};
|
||||
|
||||
const UnitTest history_tests[] = {
|
||||
unit_test(previous_on_empty_returns_null),
|
||||
unit_test(next_on_empty_returns_null),
|
||||
unit_test(previous_once_returns_last),
|
||||
@ -83,7 +94,9 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(edit_item_mid_history),
|
||||
unit_test(edit_previous_and_append),
|
||||
unit_test(start_session_add_new_submit_previous),
|
||||
};
|
||||
|
||||
const UnitTest jid_tests[] = {
|
||||
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),
|
||||
@ -107,7 +120,9 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(create_with_at_in_resource),
|
||||
unit_test(create_with_at_and_slash_in_resource),
|
||||
unit_test(create_full_with_trailing_slash),
|
||||
};
|
||||
|
||||
const UnitTest parser_tests[] = {
|
||||
unit_test(parse_null_returns_null),
|
||||
unit_test(parse_empty_returns_null),
|
||||
unit_test(parse_space_returns_null),
|
||||
@ -149,7 +164,9 @@ int main(int argc, char* argv[]) {
|
||||
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),
|
||||
};
|
||||
|
||||
const UnitTest roster_list_tests[] = {
|
||||
unit_test(empty_list_when_none_added),
|
||||
unit_test(contains_one_element),
|
||||
unit_test(first_element_correct),
|
||||
@ -168,7 +185,9 @@ int main(int argc, char* argv[]) {
|
||||
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),
|
||||
};
|
||||
|
||||
const UnitTest cmd_connect_tests[] = {
|
||||
unit_test(cmd_connect_shows_message_when_disconnecting),
|
||||
unit_test(cmd_connect_shows_message_when_connecting),
|
||||
unit_test(cmd_connect_shows_message_when_connected),
|
||||
@ -195,7 +214,9 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_connect_shows_usage_when_port_provided_twice),
|
||||
unit_test(cmd_connect_shows_usage_when_invalid_first_property),
|
||||
unit_test(cmd_connect_shows_usage_when_invalid_second_property),
|
||||
};
|
||||
|
||||
const UnitTest cmd_rooms_tests[] = {
|
||||
unit_test(cmd_rooms_shows_message_when_disconnected),
|
||||
unit_test(cmd_rooms_shows_message_when_disconnecting),
|
||||
unit_test(cmd_rooms_shows_message_when_connecting),
|
||||
@ -203,7 +224,9 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_rooms_shows_message_when_undefined),
|
||||
unit_test(cmd_rooms_uses_account_default_when_no_arg),
|
||||
unit_test(cmd_rooms_arg_used_when_passed),
|
||||
};
|
||||
|
||||
const UnitTest cmd_account_tests[] = {
|
||||
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),
|
||||
@ -267,10 +290,14 @@ int main(int argc, char* argv[]) {
|
||||
unit_test(cmd_account_clear_checks_account_exists),
|
||||
unit_test(cmd_account_clear_shows_message_when_account_doesnt_exist),
|
||||
unit_test(cmd_account_clear_shows_message_when_invalid_property),
|
||||
};
|
||||
|
||||
const UnitTest cmd_sub_tests[] = {
|
||||
unit_test(cmd_sub_shows_message_when_not_connected),
|
||||
unit_test(cmd_sub_shows_usage_when_no_arg),
|
||||
};
|
||||
|
||||
const UnitTest contact_tests[] = {
|
||||
unit_test(contact_in_group),
|
||||
unit_test(contact_not_in_group),
|
||||
unit_test(contact_name_when_name_exists),
|
||||
@ -295,12 +322,44 @@ int main(int argc, char* argv[]) {
|
||||
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),
|
||||
};
|
||||
|
||||
const UnitTest cmd_statuses_tests[] = {
|
||||
unit_test(cmd_statuses_shows_usage_when_bad_subcmd),
|
||||
unit_test(cmd_statuses_shows_usage_when_bad_console_setting),
|
||||
unit_test(cmd_statuses_shows_usage_when_bad_chat_setting),
|
||||
unit_test(cmd_statuses_shows_usage_when_bad_muc_setting),
|
||||
|
||||
};
|
||||
return run_tests(tests);
|
||||
|
||||
int bak, new;
|
||||
fflush(stdout);
|
||||
bak = dup(1);
|
||||
new = open("/dev/null", O_WRONLY);
|
||||
dup2(new, 1);
|
||||
close(new);
|
||||
|
||||
int result = 0;
|
||||
|
||||
PROF_RUN_TESTS(common_tests);
|
||||
PROF_RUN_TESTS(autocomplete_tests);
|
||||
PROF_RUN_TESTS(history_tests);
|
||||
PROF_RUN_TESTS(jid_tests);
|
||||
PROF_RUN_TESTS(parser_tests);
|
||||
PROF_RUN_TESTS(roster_list_tests);
|
||||
PROF_RUN_TESTS(cmd_connect_tests);
|
||||
PROF_RUN_TESTS(cmd_rooms_tests);
|
||||
PROF_RUN_TESTS(cmd_account_tests);
|
||||
PROF_RUN_TESTS(cmd_sub_tests);
|
||||
PROF_RUN_TESTS(contact_tests);
|
||||
PROF_RUN_TESTS(cmd_statuses_tests);
|
||||
|
||||
fflush(stdout);
|
||||
dup2(bak, 1);
|
||||
close(bak);
|
||||
|
||||
if (result > 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user