3 * oFono - Open Source Telephony
5 * Copyright (C) 2008-2011 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
32 #include <ofono/types.h>
36 static const char *invalid_strings[] = {
55 "*04*98*0000*00000*00000#",
59 static void test_invalid(void)
73 for (i = 0; invalid_strings[i]; i++) {
75 g_print("%s...\n", invalid_strings[i]);
77 str = strdup(invalid_strings[i]);
79 ret = parse_ss_control_string(str, &type, &sc,
80 &sia, &sib, &sic, &sid, &dn);
81 if (ret == TRUE && strlen(sid))
84 g_assert(ret == FALSE);
90 static const char *valid_strings[] = {
110 static void test_valid(void)
124 for (i = 0; valid_strings[i]; i++) {
125 if (g_test_verbose())
126 g_print("%s...", valid_strings[i]);
128 str = strdup(valid_strings[i]);
130 ret = parse_ss_control_string(str, &type, &sc,
131 &sia, &sib, &sic, &sid, &dn);
135 g_assert(ret == TRUE);
137 if (g_test_verbose())
138 g_print("parsed as: %d, %s, %s, %s, %s, %s\n",
139 type, sc, sia, sib, sic, dn);
145 static const char *valid_apns[] = {
152 static const char *invalid_apns[] = {
161 static void test_apn(void)
166 for (i = 0; valid_apns[i]; i++) {
167 if (g_test_verbose())
168 g_print("Test Valid:%s\n", valid_apns[i]);
170 res = is_valid_apn(valid_apns[i]);
172 g_assert(res == TRUE);
175 for (i = 0; invalid_apns[i]; i++) {
176 if (g_test_verbose())
177 g_print("Test Invalid:%s\n", invalid_apns[i]);
179 res = is_valid_apn(invalid_apns[i]);
181 g_assert(res == FALSE);
185 int main(int argc, char **argv)
187 g_test_init(&argc, &argv, NULL);
189 g_test_add_func("/testutil/Invalid", test_invalid);
190 g_test_add_func("/testutil/Valid", test_valid);
191 g_test_add_func("/testutil/APN", test_apn);