[glib] gio/tests/socket: add test for g_socket_send_message()
- From: Tim-Philipp Müller <tpm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] gio/tests/socket: add test for g_socket_send_message()
- Date: Thu, 11 Dec 2014 15:23:21 +0000 (UTC)
commit 486485042719dd13c03d5261a7945e94bdf63d69
Author: Tim-Philipp Müller <tim centricular com>
Date: Fri Jun 13 10:48:52 2014 +0100
gio/tests/socket: add test for g_socket_send_message()
gio/tests/socket.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/socket.c b/gio/tests/socket.c
index fb8821e..4a56b52 100644
--- a/gio/tests/socket.c
+++ b/gio/tests/socket.c
@@ -364,6 +364,8 @@ test_ipv6_async (void)
test_ip_async (G_SOCKET_FAMILY_IPV6);
}
+static const gchar testbuf2[] = "0123456789abcdefghijklmnopqrstuvwxyz";
+
static void
test_ip_sync (GSocketFamily family)
{
@@ -415,6 +417,34 @@ test_ip_sync (GSocketFamily family)
g_assert_cmpstr (testbuf, ==, buf);
+ {
+ GOutputVector v[7] = { { NULL, }, };
+
+ v[0].buffer = testbuf2 + 0;
+ v[0].size = 3;
+ v[1].buffer = testbuf2 + 3;
+ v[1].size = 5;
+ v[2].buffer = testbuf2 + 3 + 5;
+ v[2].size = 0;
+ v[3].buffer = testbuf2 + 3 + 5;
+ v[3].size = 6;
+ v[4].buffer = testbuf2 + 3 + 5 + 6;
+ v[4].size = 2;
+ v[5].buffer = testbuf2 + 3 + 5 + 6 + 2;
+ v[5].size = 1;
+ v[6].buffer = testbuf2 + 3 + 5 + 6 + 2 + 1;
+ v[6].size = strlen (testbuf2) - (3 + 5 + 6 + 2 + 1);
+
+ len = g_socket_send_message (client, NULL, v, G_N_ELEMENTS (v), NULL, 0, 0, NULL, &error);
+ g_assert_no_error (error);
+ g_assert_cmpint (len, ==, strlen (testbuf2));
+
+ len = g_socket_receive (client, buf, sizeof (buf), NULL, &error);
+ g_assert_no_error (error);
+ g_assert_cmpint (len, ==, strlen (testbuf2));
+ g_assert_cmpstr (testbuf2, ==, buf);
+ }
+
g_socket_shutdown (client, FALSE, TRUE, &error);
g_assert_no_error (error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]