diff options
author | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2009-07-11 17:53:58 +0100 |
---|---|---|
committer | Danielle Madeley <danielle.madeley@collabora.co.uk> | 2010-02-23 09:53:34 +1100 |
commit | 44981132f41e61ef83be4b09e58e8635da0df0f2 (patch) | |
tree | 22c2a859cb71ddbc7e0ff7f5bfadd98096e91b5f /tests/gnio-util.c | |
parent | 2052b468d77ad5e4dcff9af91b4b4f944a28c41a (diff) | |
download | telepathy-glib-44981132f41e61ef83be4b09e58e8635da0df0f2.tar.gz |
Add test_sockaddr_to_variant_ipv4 testcase
Diffstat (limited to 'tests/gnio-util.c')
-rw-r--r-- | tests/gnio-util.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/gnio-util.c b/tests/gnio-util.c index 9675f30b1..2fbdd0112 100644 --- a/tests/gnio-util.c +++ b/tests/gnio-util.c @@ -6,6 +6,7 @@ #include <gio/gio.h> #include <telepathy-glib/gnio-util.h> +#include <telepathy-glib/util.h> #define IPV4_ADDR "127.0.1.1" #define IPV6_ADDR "::1" @@ -103,6 +104,35 @@ test_variant_to_sockaddr_ipv6 (void) g_object_unref (sockaddr); } +static void +test_sockaddr_to_variant_ipv4 (void) +{ + GInetAddress *hostaddr = g_inet_address_new_from_string (IPV4_ADDR); + GSocketAddress *sockaddr = g_inet_socket_address_new (hostaddr, PORT); + GValue *variant, *value; + GValueArray *array; + TpSocketAddressType type; + + g_object_unref (hostaddr); + + variant = tp_address_variant_from_g_socket_address (sockaddr, &type); + + g_assert (G_VALUE_HOLDS (variant, G_TYPE_VALUE_ARRAY)); + + array = g_value_get_boxed (variant); + value = g_value_array_get_nth (array, 0); + + g_assert (G_VALUE_HOLDS_STRING (value)); + g_assert (strcmp (g_value_get_string (value), IPV4_ADDR) == 0); + + value = g_value_array_get_nth (array, 1); + + g_assert (G_VALUE_HOLDS_UINT (value)); + g_assert (g_value_get_uint (value) == PORT); + + tp_g_value_slice_free (variant); +} + int main (int argc, char **argv) { @@ -110,6 +140,7 @@ main (int argc, char **argv) test_variant_to_sockaddr_ipv4 (); test_variant_to_sockaddr_ipv6 (); + test_sockaddr_to_variant_ipv4 (); return 0; } |