Replace functions which called once with their bodies
[pidgin-git.git] / libpurple / tests / test_account_option.c
blobf46bff567b1fbeb2083919b8393fc63d3cb43320
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>
24 #include <string.h>
26 #include <purple.h>
28 /******************************************************************************
29 * Helpers
30 *****************************************************************************/
31 static void
32 test_purple_account_option_compare(PurpleAccountOption *opt1,
33 PurpleAccountOption *opt2)
35 g_assert_cmpint(purple_account_option_get_pref_type(opt1),
36 ==,
37 purple_account_option_get_pref_type(opt2));
38 g_assert_cmpstr(purple_account_option_get_text(opt1),
39 ==,
40 purple_account_option_get_text(opt2));
41 g_assert_cmpstr(purple_account_option_get_setting(opt1),
42 ==,
43 purple_account_option_get_setting(opt2));
46 static void
47 test_purple_account_option_compare_string(PurpleAccountOption *opt1,
48 PurpleAccountOption *opt2)
50 test_purple_account_option_compare(opt1, opt2);
52 g_assert_cmpstr(purple_account_option_get_default_string(opt1),
53 ==,
54 purple_account_option_get_default_string(opt2));
55 g_assert_cmpint(purple_account_option_string_get_masked(opt1),
56 ==,
57 purple_account_option_string_get_masked(opt2));
60 /******************************************************************************
61 * Tests
62 *****************************************************************************/
63 static void
64 test_purple_account_option_copy_int(void) {
65 PurpleAccountOption *opt1, *opt2;
67 opt1 = purple_account_option_new(PURPLE_PREF_INT, "int", "test-int");
68 opt2 = purple_account_option_copy(opt1);
70 test_purple_account_option_compare(opt1, opt2);
73 static void
74 test_purple_account_option_copy_int_with_default(void) {
75 PurpleAccountOption *opt1, *opt2;
77 opt1 = purple_account_option_new(PURPLE_PREF_INT, "int", "test-int");
78 purple_account_option_set_default_int(opt1, 42);
80 opt2 = purple_account_option_copy(opt1);
82 test_purple_account_option_compare(opt1, opt2);
84 g_assert_cmpint(purple_account_option_get_default_int(opt1),
85 ==,
86 purple_account_option_get_default_int(opt2));
89 static void
90 test_purple_account_option_copy_string(void) {
91 PurpleAccountOption *opt1, *opt2;
93 opt1 = purple_account_option_new(PURPLE_PREF_STRING, "string", "test-string");
95 opt2 = purple_account_option_copy(opt1);
96 test_purple_account_option_compare_string(opt1, opt2);
99 static void
100 test_purple_account_option_copy_string_with_default(void) {
101 PurpleAccountOption *opt1, *opt2;
103 opt1 = purple_account_option_new(PURPLE_PREF_STRING, "string", "test-string");
104 purple_account_option_set_default_string(opt1, "default");
106 opt2 = purple_account_option_copy(opt1);
107 test_purple_account_option_compare_string(opt1, opt2);
110 static void
111 test_purple_account_option_copy_string_with_masked(void) {
112 PurpleAccountOption *opt1, *opt2;
114 opt1 = purple_account_option_new(PURPLE_PREF_STRING, "string", "test-string");
115 purple_account_option_string_set_masked(opt1, TRUE);
117 opt2 = purple_account_option_copy(opt1);
118 test_purple_account_option_compare_string(opt1, opt2);
121 /******************************************************************************
122 * Main
123 *****************************************************************************/
124 gint
125 main(gint argc, gchar **argv) {
126 gint res = 0;
128 g_test_init(&argc, &argv, NULL);
130 g_test_set_nonfatal_assertions();
132 g_test_add_func(
133 "/account_option/copy/int",
134 test_purple_account_option_copy_int
137 g_test_add_func(
138 "/account_option/copy/int_with_default",
139 test_purple_account_option_copy_int_with_default
142 g_test_add_func(
143 "/account_option/copy/string",
144 test_purple_account_option_copy_string
147 g_test_add_func(
148 "/account_option/copy/string_with_default",
149 test_purple_account_option_copy_string_with_default
152 g_test_add_func(
153 "/account_option/copy/string_with_masked",
154 test_purple_account_option_copy_string_with_masked
157 res = g_test_run();
159 return res;