[glib] Test GUnixSocketAddress construction
- From: Ryan Lortie <ryanl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Test GUnixSocketAddress construction
- Date: Tue, 23 Apr 2013 18:36:26 +0000 (UTC)
commit c91af2ab44c20556f3d3493edff686cf77137fda
Author: Ryan Lortie <desrt desrt ca>
Date: Tue Apr 23 14:30:42 2013 -0400
Test GUnixSocketAddress construction
This test fails without the previous fix and works properly with it.
https://bugzilla.gnome.org/show_bug.cgi?id=698686
gio/tests/.gitignore | 1 +
gio/tests/Makefile.am | 1 +
gio/tests/socket-address.c | 79 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 81 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/.gitignore b/gio/tests/.gitignore
index 4e172ae..0652ff7 100644
--- a/gio/tests/.gitignore
+++ b/gio/tests/.gitignore
@@ -99,6 +99,7 @@ simple-async-result
simple-proxy
sleepy-stream
socket
+socket-address
socket-client
socket-server
srvtarget
diff --git a/gio/tests/Makefile.am b/gio/tests/Makefile.am
index c8a4090..f7d7fe3 100644
--- a/gio/tests/Makefile.am
+++ b/gio/tests/Makefile.am
@@ -142,6 +142,7 @@ TEST_PROGS += \
gapplication \
basic-application \
gdbus-test-codegen \
+ socket-address \
$(NULL)
SAMPLE_PROGS += \
gdbus-example-unix-fd-client \
diff --git a/gio/tests/socket-address.c b/gio/tests/socket-address.c
new file mode 100644
index 0000000..c3cd809
--- /dev/null
+++ b/gio/tests/socket-address.c
@@ -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 ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]