Help: Use stable 'if' namespace instead of experimental
[nijm-empathy.git] / tests / test-irc-helper.c
blob82d933a7dccd398d43db8f686dfffbce5d15122a
1 #include "config.h"
2 #include "test-irc-helper.h"
4 void
5 check_server (TpawIrcServer *server,
6 const gchar *_address,
7 guint _port,
8 gboolean _ssl)
10 gchar *address;
11 guint port;
12 gboolean ssl;
14 g_assert (server != NULL);
16 g_object_get (server,
17 "address", &address,
18 "port", &port,
19 "ssl", &ssl,
20 NULL);
22 g_assert (address != NULL && strcmp (address, _address) == 0);
23 g_assert (port == _port);
24 g_assert (ssl == _ssl);
26 g_free (address);
29 void
30 check_network (TpawIrcNetwork *network,
31 const gchar *_name,
32 const gchar *_charset,
33 struct server_t *_servers,
34 guint nb_servers)
36 gchar *name, *charset;
37 GSList *servers, *l;
38 guint i;
40 g_assert (network != NULL);
42 g_object_get (network,
43 "name", &name,
44 "charset", &charset,
45 NULL);
47 g_assert (name != NULL && strcmp (name, _name) == 0);
48 g_assert (charset != NULL && strcmp (charset, _charset) == 0);
50 servers = tpaw_irc_network_get_servers (network);
51 g_assert (g_slist_length (servers) == nb_servers);
53 /* Is that the right servers ? */
54 for (l = servers, i = 0; l != NULL; l = g_slist_next (l), i++)
56 TpawIrcServer *server;
57 gchar *address;
58 guint port;
59 gboolean ssl;
61 server = l->data;
63 g_object_get (server,
64 "address", &address,
65 "port", &port,
66 "ssl", &ssl,
67 NULL);
69 g_assert (address != NULL && strcmp (address, _servers[i].address)
70 == 0);
71 g_assert (port == _servers[i].port);
72 g_assert (ssl == _servers[i].ssl);
74 g_free (address);
77 g_slist_foreach (servers, (GFunc) g_object_unref, NULL);
78 g_slist_free (servers);
79 g_free (name);
80 g_free (charset);