mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-02 15:46:17 +01:00
c91af2ab44
This test fails without the previous fix and works properly with it. https://bugzilla.gnome.org/show_bug.cgi?id=698686
80 lines
2.9 KiB
C
80 lines
2.9 KiB
C
#include <gio/gunixsocketaddress.h>
|
|
|
|
static void
|
|
test_unix_socket_address_construct (void)
|
|
{
|
|
GUnixSocketAddress *a;
|
|
|
|
a = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS, NULL);
|
|
g_assert_cmpint (g_unix_socket_address_get_address_type (a), ==, G_UNIX_SOCKET_ADDRESS_PATH);
|
|
g_object_unref (a);
|
|
|
|
/* Try passing some default values for the arguments explicitly and
|
|
* make sure it makes no difference.
|
|
*/
|
|
a = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS, "address-type", G_UNIX_SOCKET_ADDRESS_PATH, NULL);
|
|
g_assert_cmpint (g_unix_socket_address_get_address_type (a), ==, G_UNIX_SOCKET_ADDRESS_PATH);
|
|
g_object_unref (a);
|
|
|
|
a = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS, "abstract", FALSE, NULL);
|
|
g_assert_cmpint (g_unix_socket_address_get_address_type (a), ==, G_UNIX_SOCKET_ADDRESS_PATH);
|
|
g_object_unref (a);
|
|
|
|
a = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
|
|
"abstract", FALSE,
|
|
"address-type", G_UNIX_SOCKET_ADDRESS_PATH,
|
|
NULL);
|
|
g_assert_cmpint (g_unix_socket_address_get_address_type (a), ==, G_UNIX_SOCKET_ADDRESS_PATH);
|
|
g_object_unref (a);
|
|
|
|
a = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
|
|
"address-type", G_UNIX_SOCKET_ADDRESS_PATH,
|
|
"abstract", FALSE,
|
|
NULL);
|
|
g_assert_cmpint (g_unix_socket_address_get_address_type (a), ==, G_UNIX_SOCKET_ADDRESS_PATH);
|
|
g_object_unref (a);
|
|
|
|
/* Try explicitly setting abstract to TRUE */
|
|
a = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
|
|
"abstract", TRUE,
|
|
NULL);
|
|
g_assert_cmpint (g_unix_socket_address_get_address_type (a), ==, G_UNIX_SOCKET_ADDRESS_ABSTRACT_PADDED);
|
|
g_object_unref (a);
|
|
|
|
/* Try explicitly setting a different kind of address */
|
|
a = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
|
|
"address-type", G_UNIX_SOCKET_ADDRESS_ANONYMOUS,
|
|
NULL);
|
|
g_assert_cmpint (g_unix_socket_address_get_address_type (a), ==, G_UNIX_SOCKET_ADDRESS_ANONYMOUS);
|
|
g_object_unref (a);
|
|
|
|
/* Now try explicitly setting a different type of address after
|
|
* setting abstract to FALSE.
|
|
*/
|
|
a = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
|
|
"abstract", FALSE,
|
|
"address-type", G_UNIX_SOCKET_ADDRESS_ANONYMOUS,
|
|
NULL);
|
|
g_assert_cmpint (g_unix_socket_address_get_address_type (a), ==, G_UNIX_SOCKET_ADDRESS_ANONYMOUS);
|
|
g_object_unref (a);
|
|
|
|
/* And the other way around */
|
|
a = g_object_new (G_TYPE_UNIX_SOCKET_ADDRESS,
|
|
"address-type", G_UNIX_SOCKET_ADDRESS_ANONYMOUS,
|
|
"abstract", FALSE,
|
|
NULL);
|
|
g_assert_cmpint (g_unix_socket_address_get_address_type (a), ==, G_UNIX_SOCKET_ADDRESS_ANONYMOUS);
|
|
g_object_unref (a);
|
|
}
|
|
|
|
int
|
|
main (int argc,
|
|
char **argv)
|
|
{
|
|
g_test_init (&argc, &argv, NULL);
|
|
|
|
g_test_add_func ("/socket/address/unix/construct", test_unix_socket_address_construct);
|
|
|
|
return g_test_run ();
|
|
}
|