From b22f4a2dd2c05038f45485b850f3ba04bf28afb9 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 19 Aug 2012 02:25:02 -0400 Subject: [PATCH] Improve test coverage for unix streams --- gio/tests/unix-streams.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gio/tests/unix-streams.c b/gio/tests/unix-streams.c index dc8cf35..fd84c50 100644 --- a/gio/tests/unix-streams.c +++ b/gio/tests/unix-streams.c @@ -257,6 +257,43 @@ test_pipe_io (gconstpointer nonblocking) g_object_unref (out); } +static void +test_basic (void) +{ + GUnixInputStream *is; + GUnixOutputStream *os; + gint fd; + gboolean close_fd; + + is = G_UNIX_INPUT_STREAM (g_unix_input_stream_new (0, TRUE)); + g_object_get (is, + "fd", &fd, + "close-fd", &close_fd, + NULL); + g_assert_cmpint (fd, ==, 0); + g_assert (close_fd); + + g_unix_input_stream_set_close_fd (is, FALSE); + g_assert (!g_unix_input_stream_get_close_fd (is)); + g_assert_cmpint (g_unix_input_stream_get_fd (is), ==, 0); + + g_object_unref (is); + + os = G_UNIX_OUTPUT_STREAM (g_unix_output_stream_new (1, TRUE)); + g_object_get (os, + "fd", &fd, + "close-fd", &close_fd, + NULL); + g_assert_cmpint (fd, ==, 1); + g_assert (close_fd); + + g_unix_output_stream_set_close_fd (os, FALSE); + g_assert (!g_unix_output_stream_get_close_fd (os)); + g_assert_cmpint (g_unix_output_stream_get_fd (os), ==, 1); + + g_object_unref (os); +} + int main (int argc, char *argv[]) @@ -264,6 +301,7 @@ main (int argc, g_type_init (); g_test_init (&argc, &argv, NULL); + g_test_add_func ("/unix-streams/basic", test_basic); g_test_add_data_func ("/unix-streams/pipe-io-test", GINT_TO_POINTER (FALSE), test_pipe_io); -- 2.7.4