From e4bf7335d889d82dedf962f2a2590f1a1b7455b6 Mon Sep 17 00:00:00 2001 From: Dustin Lagoy Date: Wed, 30 Jun 2021 18:58:07 -0400 Subject: Add unit tests for roster_get_display_name --- tests/unittests/test_roster_list.c | 32 ++++++++++++++++++++++++++++++++ tests/unittests/test_roster_list.h | 3 +++ tests/unittests/unittests.c | 3 +++ 3 files changed, 38 insertions(+) (limited to 'tests') diff --git a/tests/unittests/test_roster_list.c b/tests/unittests/test_roster_list.c index b46e7b57..fc10d1a7 100644 --- a/tests/unittests/test_roster_list.c +++ b/tests/unittests/test_roster_list.c @@ -689,3 +689,35 @@ remove_contact_with_remaining_in_group(void** state) g_list_free_full(groups_res, free); roster_destroy(); } + +void +get_contact_display_name(void** state) +{ + roster_create(); + roster_add("person@server.org", "nickname", NULL, NULL, FALSE); + + assert_string_equal("nickname", roster_get_display_name("person@server.org")); + + roster_destroy(); +} + +void +get_contact_display_name_is_barejid_if_name_is_empty(void** state) +{ + roster_create(); + roster_add("person@server.org", NULL, NULL, NULL, FALSE); + + assert_string_equal("person@server.org", roster_get_display_name("person@server.org")); + + roster_destroy(); +} + +void +get_contact_display_name_is_passed_barejid_if_contact_does_not_exist(void** state) +{ + roster_create(); + + assert_string_equal("person@server.org", roster_get_display_name("person@server.org")); + + roster_destroy(); +} diff --git a/tests/unittests/test_roster_list.h b/tests/unittests/test_roster_list.h index b9874fec..81983d46 100644 --- a/tests/unittests/test_roster_list.h +++ b/tests/unittests/test_roster_list.h @@ -30,3 +30,6 @@ 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 get_contact_display_name(void** state); +void get_contact_display_name_is_barejid_if_name_is_empty(void** state); +void get_contact_display_name_is_passed_barejid_if_contact_does_not_exist(void** state); diff --git a/tests/unittests/unittests.c b/tests/unittests/unittests.c index 7fd3b192..e2293004 100644 --- a/tests/unittests/unittests.c +++ b/tests/unittests/unittests.c @@ -219,6 +219,9 @@ main(int argc, char* argv[]) 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, -- cgit 1.4.1-2-gfad0 ion.c
blob: fd934737364ac2d5b13c1b50841b8087a0a3ca75 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51