mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
Test GUnixSocketAddress construction
This test fails without the previous fix and works properly with it. https://bugzilla.gnome.org/show_bug.cgi?id=698686
This commit is contained in:
parent
9c243beea2
commit
c91af2ab44
1
gio/tests/.gitignore
vendored
1
gio/tests/.gitignore
vendored
@ -99,6 +99,7 @@ simple-async-result
|
||||
simple-proxy
|
||||
sleepy-stream
|
||||
socket
|
||||
socket-address
|
||||
socket-client
|
||||
socket-server
|
||||
srvtarget
|
||||
|
@ -142,6 +142,7 @@ TEST_PROGS += \
|
||||
gapplication \
|
||||
basic-application \
|
||||
gdbus-test-codegen \
|
||||
socket-address \
|
||||
$(NULL)
|
||||
SAMPLE_PROGS += \
|
||||
gdbus-example-unix-fd-client \
|
||||
|
79
gio/tests/socket-address.c
Normal file
79
gio/tests/socket-address.c
Normal file
@ -0,0 +1,79 @@
|
||||
#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 ();
|
||||
}
|
Loading…
Reference in New Issue
Block a user