1 /*
2  * This program is free software: you can redistribute it and/or modify it
3  * under the terms of the GNU Lesser General Public License as published by
4  * the Free Software Foundation.
5  *
6  * This program is distributed in the hope that it will be useful, but
7  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
8  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
9  * for more details.
10  *
11  * You should have received a copy of the GNU Lesser General Public License
12  * along with this program. If not, see <http://www.gnu.org/licenses/>.
13  *
14  */
15 
16 #include <stdlib.h>
17 #include <string.h>
18 #include <libebook/libebook.h>
19 
20 /* TEL;WORK,VOICE:... should map to PHONE_BUSINESS
21  * TEL;VOICE:... should map to PHONE_OTHER
22  * TEL;FAX:... should map to OTHER_FAX. */
23 #define VCARD \
24   "BEGIN:VCARD\n" \
25   "FN:Janet Jackson\n" \
26   "N:Janet\n" \
27   "TEL;WORK,VOICE:123-123-1234\n" \
28   "TEL;VOICE:456-456-4567\n" \
29   "TEL;FAX:321-321-4321\n" \
30   "END:VCARD\n"
31 
32 static void
test_business(void)33 test_business (void)
34 {
35 	EContact *contact;
36 	const gchar *phone;
37 
38 	contact = e_contact_new_from_vcard (VCARD);
39 
40 	phone = e_contact_get_const (contact, E_CONTACT_PHONE_BUSINESS);
41 	g_assert (phone != NULL);
42 	g_assert_cmpstr (phone, ==, "123-123-1234");
43 
44 	g_object_unref (contact);
45 }
46 
47 static void
test_other_phone(void)48 test_other_phone (void)
49 {
50 	EContact *contact;
51 	const gchar *phone;
52 
53 	contact = e_contact_new_from_vcard (VCARD);
54 
55 	phone = e_contact_get_const (contact, E_CONTACT_PHONE_OTHER);
56 	g_assert (phone != NULL);
57 	g_assert_cmpstr (phone, ==, "456-456-4567");
58 
59 	g_object_unref (contact);
60 }
61 
62 static void
test_other_fax(void)63 test_other_fax (void)
64 {
65 	EContact *contact;
66 	const gchar *phone;
67 
68 	contact = e_contact_new_from_vcard (VCARD);
69 
70 	phone = e_contact_get_const (contact, E_CONTACT_PHONE_OTHER_FAX);
71 	g_assert (phone != NULL);
72 	g_assert_cmpstr (phone, ==, "321-321-4321");
73 
74 	g_object_unref (contact);
75 }
76 
77 gint
main(gint argc,gchar ** argv)78 main (gint argc,
79       gchar **argv)
80 {
81 	g_test_init (&argc, &argv, NULL);
82 	g_test_bug_base ("http://bugzilla.gnome.org/");
83 
84 	g_test_add_func ("/Contact/UntypedPhones/Business", test_business);
85 	g_test_add_func ("/Contact/UntypedPhones/OtherPhone", test_other_phone);
86 	g_test_add_func ("/Contact/UntypedPhones/OtherFax", test_other_fax);
87 
88 	return g_test_run ();
89 }
90