void empty_list_when_none_added(void **state) { roster_create(); GSList *list = roster_get_contacts(ROSTER_ORD_NAME); assert_null(list); roster_destroy(); }
void contains_one_element(void **state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); GSList *list = roster_get_contacts(ROSTER_ORD_NAME); assert_int_equal(1, g_slist_length(list)); roster_destroy(); }
void first_element_correct(void **state) { roster_create(); roster_add("James", NULL, NULL, NULL, FALSE); GSList *list = roster_get_contacts(ROSTER_ORD_NAME); PContact james = list->data; assert_string_equal("James", p_contact_barejid(james)); roster_destroy(); }
void rosterwin_roster(void) { ProfWin *console = wins_get_console(); if (console) { ProfLayoutSplit *layout = (ProfLayoutSplit*)console->layout; assert(layout->memcheck == LAYOUT_SPLIT_MEMCHECK); char *by = prefs_get_string(PREF_ROSTER_BY); if (g_strcmp0(by, "presence") == 0) { werase(layout->subwin); _rosterwin_contacts_by_presence(layout, "chat", " -Available for chat"); _rosterwin_contacts_by_presence(layout, "online", " -Online"); _rosterwin_contacts_by_presence(layout, "away", " -Away"); _rosterwin_contacts_by_presence(layout, "xa", " -Extended Away"); _rosterwin_contacts_by_presence(layout, "dnd", " -Do not disturb"); if (prefs_get_boolean(PREF_ROSTER_OFFLINE)) { _rosterwin_contacts_by_presence(layout, "offline", " -Offline"); } } else if (g_strcmp0(by, "group") == 0) { werase(layout->subwin); GSList *groups = roster_get_groups(); GSList *curr_group = groups; while (curr_group) { _rosterwin_contacts_by_group(layout, curr_group->data); curr_group = g_slist_next(curr_group); } g_slist_free_full(groups, free); _rosterwin_contacts_by_no_group(layout); } else { GSList *contacts = roster_get_contacts(); if (contacts) { werase(layout->subwin); wattron(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); win_printline_nowrap(layout->subwin, " -Roster"); wattroff(layout->subwin, theme_attrs(THEME_ROSTER_HEADER)); GSList *curr_contact = contacts; while (curr_contact) { PContact contact = curr_contact->data; _rosterwin_contact(layout, contact); curr_contact = g_slist_next(curr_contact); } } g_slist_free(contacts); } free(by); } }
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); PContact first = list->data; PContact second = (g_slist_next(list))->data; assert_string_equal("Dave", p_contact_barejid(first)); assert_string_equal("James", p_contact_barejid(second)); roster_destroy(); }
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); PContact bob = list->data; PContact dave = (g_slist_next(list))->data; PContact james = (g_slist_next(g_slist_next(list)))->data; assert_string_equal("James", p_contact_barejid(james)); assert_string_equal("Dave", p_contact_barejid(dave)); assert_string_equal("Bob", p_contact_barejid(bob)); roster_destroy(); }
void cons_show_sent_subs(void) { if (roster_has_pending_subscriptions()) { GSList *contacts = roster_get_contacts(); PContact contact = NULL; cons_show("Awaiting subscription responses from:"); while (contacts != NULL) { contact = (PContact) contacts->data; if (p_contact_pending_out(contact)) { cons_show(" %s", p_contact_barejid(contact)); } contacts = g_slist_next(contacts); } } else { cons_show("No pending requests sent."); } }
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); PContact first = list->data; PContact second = (g_slist_next(list))->data; PContact third = (g_slist_next(g_slist_next(list)))->data; assert_int_equal(3, g_slist_length(list)); assert_string_equal("Bob", p_contact_barejid(first)); assert_string_equal("Dave", p_contact_barejid(second)); assert_string_equal("James", p_contact_barejid(third)); roster_destroy(); }