diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_contact_list.c | 159 |
1 files changed, 58 insertions, 101 deletions
diff --git a/tests/test_contact_list.c b/tests/test_contact_list.c index 042cfef4..fda6ea31 100644 --- a/tests/test_contact_list.c +++ b/tests/test_contact_list.c @@ -31,14 +31,14 @@ static void empty_list_when_none_added(void) static void contains_one_element(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); GSList *list = get_contact_list(); assert_int_equals(1, g_slist_length(list)); } static void first_element_correct(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); GSList *list = get_contact_list(); PContact james = list->data; @@ -47,8 +47,8 @@ static void first_element_correct(void) static void contains_two_elements(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); GSList *list = get_contact_list(); assert_int_equals(2, g_slist_length(list)); @@ -56,8 +56,8 @@ static void contains_two_elements(void) static void first_and_second_elements_correct(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); GSList *list = get_contact_list(); PContact first = list->data; @@ -69,9 +69,9 @@ static void first_and_second_elements_correct(void) static void contains_three_elements(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); GSList *list = get_contact_list(); assert_int_equals(3, g_slist_length(list)); @@ -79,9 +79,9 @@ static void contains_three_elements(void) static void first_three_elements_correct(void) { - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); GSList *list = get_contact_list(); PContact bob = list->data; PContact dave = (g_slist_next(list))->data; @@ -94,10 +94,10 @@ static void first_three_elements_correct(void) static void add_twice_at_beginning_adds_once(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); GSList *list = get_contact_list(); PContact first = list->data; PContact second = (g_slist_next(list))->data; @@ -111,10 +111,10 @@ static void add_twice_at_beginning_adds_once(void) static void add_twice_in_middle_adds_once(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); GSList *list = get_contact_list(); PContact first = list->data; PContact second = (g_slist_next(list))->data; @@ -128,10 +128,10 @@ static void add_twice_in_middle_adds_once(void) static void add_twice_at_end_adds_once(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); GSList *list = get_contact_list(); PContact first = list->data; PContact second = (g_slist_next(list))->data; @@ -143,45 +143,18 @@ static void add_twice_at_end_adds_once(void) assert_string_equals("Bob", p_contact_barejid(third)); } -static void test_show_when_value(void) -{ - contact_list_add("James", NULL, "away", NULL, NULL, FALSE); - GSList *list = get_contact_list(); - PContact james = list->data; - - assert_string_equals("away", p_contact_presence(james)); -} - static void test_show_online_when_no_value(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - GSList *list = get_contact_list(); - PContact james = list->data; - - assert_string_equals("online", p_contact_presence(james)); -} - -static void test_show_online_when_empty_string(void) -{ - contact_list_add("James", NULL, "", NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); GSList *list = get_contact_list(); PContact james = list->data; - assert_string_equals("online", p_contact_presence(james)); -} - -static void test_status_when_value(void) -{ - contact_list_add("James", NULL, NULL, "I'm not here right now", NULL, FALSE); - GSList *list = get_contact_list(); - PContact james = list->data; - - assert_string_equals("I'm not here right now", p_contact_status(james)); + assert_string_equals("offline", p_contact_presence(james)); } static void test_status_when_no_value(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); GSList *list = get_contact_list(); PContact james = list->data; @@ -190,7 +163,7 @@ static void test_status_when_no_value(void) static void update_show(void) { - contact_list_add("James", NULL, "away", NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); contact_list_update_contact("James", "dnd", NULL, NULL, NULL); GSList *list = get_contact_list(); @@ -200,21 +173,9 @@ static void update_show(void) assert_string_equals("dnd", p_contact_presence(first)); } -static void set_show_to_null(void) -{ - contact_list_add("James", NULL, "away", NULL, NULL, FALSE); - contact_list_update_contact("James", NULL, NULL, NULL, NULL); - GSList *list = get_contact_list(); - - assert_int_equals(1, g_slist_length(list)); - PContact james = list->data; - assert_string_equals("James", p_contact_barejid(james)); - assert_is_null(p_contact_presence(james)); -} - static void update_status(void) { - contact_list_add("James", NULL, NULL, "I'm not here right now", NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); contact_list_update_contact("James", NULL, "Gone to lunch", NULL, NULL); GSList *list = get_contact_list(); @@ -226,7 +187,7 @@ static void update_status(void) static void set_status_to_null(void) { - contact_list_add("James", NULL, NULL, "Gone to lunch", NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); contact_list_update_contact("James", NULL, NULL, NULL, NULL); GSList *list = get_contact_list(); @@ -238,9 +199,9 @@ static void set_status_to_null(void) static void find_first_exists(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); char *search = (char *) malloc(2 * sizeof(char)); strcpy(search, "B"); @@ -253,9 +214,9 @@ static void find_first_exists(void) static void find_second_exists(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); char *result = contact_list_find_contact("Dav"); assert_string_equals("Dave", result); @@ -264,9 +225,9 @@ static void find_second_exists(void) static void find_third_exists(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); char *result = contact_list_find_contact("Ja"); assert_string_equals("James", result); @@ -275,9 +236,9 @@ static void find_third_exists(void) static void find_returns_null(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); char *result = contact_list_find_contact("Mike"); assert_is_null(result); @@ -291,9 +252,9 @@ static void find_on_empty_returns_null(void) static void find_twice_returns_second_when_two_match(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Jamie", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Jamie", NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); char *result1 = contact_list_find_contact("Jam"); char *result2 = contact_list_find_contact(result1); @@ -304,16 +265,16 @@ static void find_twice_returns_second_when_two_match(void) static void find_five_times_finds_fifth(void) { - contact_list_add("Jama", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Jamb", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Mike", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Dave", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Jamm", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Jamn", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Matt", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Jamo", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Jamy", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Jamz", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("Jama", NULL, NULL, FALSE); + contact_list_add("Jamb", NULL, NULL, FALSE); + contact_list_add("Mike", NULL, NULL, FALSE); + contact_list_add("Dave", NULL, NULL, FALSE); + contact_list_add("Jamm", NULL, NULL, FALSE); + contact_list_add("Jamn", NULL, NULL, FALSE); + contact_list_add("Matt", NULL, NULL, FALSE); + contact_list_add("Jamo", NULL, NULL, FALSE); + contact_list_add("Jamy", NULL, NULL, FALSE); + contact_list_add("Jamz", NULL, NULL, FALSE); char *result1 = contact_list_find_contact("Jam"); char *result2 = contact_list_find_contact(result1); @@ -330,9 +291,9 @@ static void find_five_times_finds_fifth(void) static void find_twice_returns_first_when_two_match_and_reset(void) { - contact_list_add("James", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Jamie", NULL, NULL, NULL, NULL, FALSE); - contact_list_add("Bob", NULL, NULL, NULL, NULL, FALSE); + contact_list_add("James", NULL, NULL, FALSE); + contact_list_add("Jamie", NULL, NULL, FALSE); + contact_list_add("Bob", NULL, NULL, FALSE); char *result1 = contact_list_find_contact("Jam"); contact_list_reset_search_attempts(); @@ -358,13 +319,9 @@ void register_contact_list_tests(void) TEST(add_twice_at_beginning_adds_once); TEST(add_twice_in_middle_adds_once); TEST(add_twice_at_end_adds_once); - TEST(test_show_when_value); TEST(test_show_online_when_no_value); - TEST(test_show_online_when_empty_string); - TEST(test_status_when_value); TEST(test_status_when_no_value); TEST(update_show); - TEST(set_show_to_null); TEST(update_status); TEST(set_status_to_null); TEST(find_first_exists); |