Replace functions which called once with their bodies
[pidgin-git.git] / libpurple / tests / test_smiley_list.c
blobc49c2cdcf632713343a2ffc6199b11df5e2ae032
1 /*
2 * Purple
4 * Purple is the legal property of its developers, whose names are too
5 * numerous to list here. Please refer to the COPYRIGHT file distributed
6 * with this source distribution
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at
11 * your option) any later version.
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
23 #include <glib.h>
25 #include <purple.h>
27 /******************************************************************************
28 * Test
29 *****************************************************************************/
30 static void
31 test_smiley_list_new(void) {
32 PurpleSmileyList *list = NULL;
34 list = purple_smiley_list_new();
36 g_assert(purple_smiley_list_is_empty(list));
37 g_assert(purple_smiley_list_get_unique(list) == NULL);
38 g_assert(purple_smiley_list_get_all(list) == NULL);
40 g_object_unref(G_OBJECT(list));
43 static void
44 test_smiley_list_add_remove(void) {
45 PurpleSmileyList *list = NULL;
46 PurpleSmiley *smiley = NULL, *smiley2 = NULL;
47 PurpleTrie *trie = NULL;
48 gboolean added = FALSE;
50 list = purple_smiley_list_new();
52 g_assert(purple_smiley_list_is_empty(list));
54 /* create a smiley */
55 smiley = purple_smiley_new_from_data("testing", NULL, 0);
57 /* add the smiley to the list */
58 added = purple_smiley_list_add(list, smiley);
59 g_assert(added);
60 g_assert(!purple_smiley_list_is_empty(list));
62 /* make sure we can get it back out */
63 smiley2 = purple_smiley_list_get_by_shortcut(list, "testing");
64 g_assert(smiley == smiley2);
66 /* make sure it returns a valid trie */
67 trie = purple_smiley_list_get_trie(list);
68 g_assert(PURPLE_IS_TRIE(trie));
69 /* don't free the trie, as it's ownership is not transfered to us */
71 /* add it again (should fail) */
72 added = purple_smiley_list_add(list, smiley);
73 g_assert(!added);
75 /* now remove it and make sure the list is empty */
76 purple_smiley_list_remove(list, smiley);
77 g_assert(purple_smiley_list_is_empty(list));
79 g_object_unref(G_OBJECT(smiley));
80 g_object_unref(G_OBJECT(list));
83 /******************************************************************************
84 * Main
85 *****************************************************************************/
86 gint
87 main(gint argc, gchar **argv) {
88 g_test_init(&argc, &argv, NULL);
90 g_test_set_nonfatal_assertions();
92 g_test_add_func("/smiley_list/new", test_smiley_list_new);
93 g_test_add_func("/smiley_list/add-remove", test_smiley_list_add_remove);
95 return g_test_run();