From beea8c5c847a7bf46ae77d834ed7cc3fb6822c5c Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sun, 19 Aug 2012 02:25:21 -0400 Subject: [PATCH] Improve test coverage for filter streams --- gio/tests/filter-streams.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gio/tests/filter-streams.c b/gio/tests/filter-streams.c index 050a4eaf3..6877a2120 100644 --- a/gio/tests/filter-streams.c +++ b/gio/tests/filter-streams.c @@ -11,13 +11,17 @@ * Author: Ryan Lortie */ +#include #include #include static void test_input_filter (void) { - GInputStream *base, *f1, *f2; + GInputStream *base, *f1, *f2, *s; + gboolean close_base; + gchar buf[1024]; + GError *error = NULL; g_test_bug ("568394"); base = g_memory_input_stream_new_from_data ("abcdefghijk", -1, NULL); @@ -33,11 +37,27 @@ test_input_filter (void) g_assert (!g_input_stream_is_closed (f1)); g_assert (!g_input_stream_is_closed (f2)); + g_object_get (f1, + "close-base-stream", &close_base, + "base-stream", &s, + NULL); + g_assert (!close_base); + g_assert (s == base); + g_object_unref (s); + g_object_unref (f1); g_assert (!g_input_stream_is_closed (base)); g_assert (!g_input_stream_is_closed (f2)); + g_input_stream_skip (f2, 3, NULL, &error); + g_assert_no_error (error); + + memset (buf, 0, 1024); + g_input_stream_read_all (f2, buf, 1024, NULL, NULL, &error); + g_assert_no_error (error); + g_assert_cmpstr (buf, ==, "defghijk"); + g_object_unref (f2); g_assert (g_input_stream_is_closed (base));