tizen 2.3.1 release
[framework/telephony/libtcore.git] / unit-test / test-network.c
1
2 #include <stdio.h>
3 #include <string.h>
4 #include <stdlib.h>
5
6 #include <glib.h>
7
8 #include <tcore.h>
9 #include <plugin.h>
10 #include <co_network.h>
11
12
13 static void test_operator(void)
14 {
15         TcorePlugin *p;
16         CoreObject *o;
17         struct tcore_network_operator_info noi;
18         struct tcore_network_operator_info *tmp_noi;
19         TReturn ret;
20
21         p = tcore_plugin_new (NULL, NULL, NULL, NULL);
22         g_assert (p);
23
24         o = tcore_network_new (p, "test_network", NULL, NULL);
25         g_assert (o);
26
27         /* Add 2 items */
28         snprintf (noi.mcc, 4, "123");
29         snprintf (noi.mnc, 4, "01");
30         snprintf (noi.name, 41, "Hello");
31         ret = tcore_network_operator_info_add (o, &noi);
32         g_assert (ret == TCORE_RETURN_SUCCESS);
33
34         snprintf (noi.mcc, 4, "123");
35         snprintf (noi.mnc, 4, "02");
36         snprintf (noi.name, 41, "World");
37         ret = tcore_network_operator_info_add (o, &noi);
38         g_assert (ret == TCORE_RETURN_SUCCESS);
39
40         /* Check items */
41         tmp_noi = tcore_network_operator_info_find (o, "123", "01");
42         g_assert (tmp_noi);
43         g_assert_cmpstr (tmp_noi->name, ==, "Hello");
44
45         tmp_noi = tcore_network_operator_info_find (o, "123", "02");
46         g_assert (tmp_noi);
47         g_assert_cmpstr (tmp_noi->name, ==, "World");
48
49         /* Replace item */
50         snprintf (noi.mcc, 4, "123");
51         snprintf (noi.mnc, 4, "02");
52         snprintf (noi.name, 41, "Update");
53         ret = tcore_network_operator_info_add (o, &noi);
54         g_assert (ret == TCORE_RETURN_SUCCESS);
55
56         /* Check items */
57         tmp_noi = tcore_network_operator_info_find (o, "123", "01");
58         g_assert (tmp_noi);
59         g_assert_cmpstr (tmp_noi->name, ==, "Hello");
60
61         tmp_noi = tcore_network_operator_info_find (o, "123", "02");
62         g_assert (tmp_noi);
63         g_assert_cmpstr (tmp_noi->name, ==, "Update");
64
65         tcore_network_free (o);
66         tcore_plugin_free (p);
67 }
68
69 int main(int argc, char **argv)
70 {
71         g_test_init(&argc, &argv, NULL);
72
73         g_test_add_func("/network/operator", test_operator);
74
75         return g_test_run();
76 }