[glib] More stream tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] More stream tests
- Date: Tue, 6 Jul 2010 03:15:26 +0000 (UTC)
commit 2764b75d5373d03b46d04fdfa3cc64becf274294
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jul 5 11:38:31 2010 -0400
More stream tests
gio/tests/buffered-input-stream.c | 35 +++++++++++++++++++++++++++++++++++
gio/tests/buffered-output-stream.c | 35 +++++++++++++++++++++++++++++++++++
gio/tests/converter-stream.c | 2 ++
3 files changed, 72 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/buffered-input-stream.c b/gio/tests/buffered-input-stream.c
index b8059bf..4809cc7 100644
--- a/gio/tests/buffered-input-stream.c
+++ b/gio/tests/buffered-input-stream.c
@@ -246,6 +246,40 @@ test_skip (void)
g_object_unref (base);
}
+static void
+test_close (void)
+{
+ GInputStream *base;
+ GInputStream *in;
+ GError *error;
+
+ base = g_memory_input_stream_new_from_data ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ", -1, NULL);
+ in = g_buffered_input_stream_new (base);
+
+ g_assert (g_filter_input_stream_get_close_base_stream (G_FILTER_INPUT_STREAM (in)));
+
+ error = NULL;
+ g_assert (g_input_stream_close (in, NULL, &error));
+ g_assert_no_error (error);
+ g_assert (g_input_stream_is_closed (base));
+
+ g_object_unref (in);
+ g_object_unref (base);
+
+ base = g_memory_input_stream_new_from_data ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ", -1, NULL);
+ in = g_buffered_input_stream_new (base);
+
+ g_filter_input_stream_set_close_base_stream (G_FILTER_INPUT_STREAM (in), FALSE);
+
+ error = NULL;
+ g_assert (g_input_stream_close (in, NULL, &error));
+ g_assert_no_error (error);
+ g_assert (!g_input_stream_is_closed (base));
+
+ g_object_unref (in);
+ g_object_unref (base);
+}
+
int
main (int argc,
char *argv[])
@@ -260,6 +294,7 @@ main (int argc,
g_test_add_func ("/buffered-input-stream/read-byte", test_read_byte);
g_test_add_func ("/buffered-input-stream/read", test_read);
g_test_add_func ("/buffered-input-stream/skip", test_skip);
+ g_test_add_func ("/filter-input-stream/close", test_close);
return g_test_run();
}
diff --git a/gio/tests/buffered-output-stream.c b/gio/tests/buffered-output-stream.c
index e3e3c6f..9ce4d82 100644
--- a/gio/tests/buffered-output-stream.c
+++ b/gio/tests/buffered-output-stream.c
@@ -72,6 +72,40 @@ test_grow (void)
g_object_unref (base);
}
+static void
+test_close (void)
+{
+ GOutputStream *base;
+ GOutputStream *out;
+ GError *error;
+
+ base = g_memory_output_stream_new (g_malloc0 (30), 30, g_realloc, g_free);
+ out = g_buffered_output_stream_new (base);
+
+ g_assert (g_filter_output_stream_get_close_base_stream (G_FILTER_OUTPUT_STREAM (out)));
+
+ error = NULL;
+ g_assert (g_output_stream_close (out, NULL, &error));
+ g_assert_no_error (error);
+ g_assert (g_output_stream_is_closed (base));
+
+ g_object_unref (out);
+ g_object_unref (base);
+
+ base = g_memory_output_stream_new (g_malloc0 (30), 30, g_realloc, g_free);
+ out = g_buffered_output_stream_new (base);
+
+ g_filter_output_stream_set_close_base_stream (G_FILTER_OUTPUT_STREAM (out), FALSE);
+
+ error = NULL;
+ g_assert (g_output_stream_close (out, NULL, &error));
+ g_assert_no_error (error);
+ g_assert (!g_output_stream_is_closed (base));
+
+ g_object_unref (out);
+ g_object_unref (base);
+}
+
int
main (int argc, char *argv[])
{
@@ -81,6 +115,7 @@ main (int argc, char *argv[])
g_test_add_func ("/buffered-output-stream/write", test_write);
g_test_add_func ("/buffered-output-stream/grow", test_grow);
+ g_test_add_func ("/filter-output-stream/close", test_close);
return g_test_run ();
}
diff --git a/gio/tests/converter-stream.c b/gio/tests/converter-stream.c
index ee5a2e4..9ac50c6 100644
--- a/gio/tests/converter-stream.c
+++ b/gio/tests/converter-stream.c
@@ -325,6 +325,7 @@ test_expander (void)
sizeof (unexpanded_data),
NULL);
cstream = g_converter_input_stream_new (mem, expander);
+ g_assert (g_converter_input_stream_get_converter (cstream) == expander);
g_object_unref (mem);
total_read = 0;
@@ -581,6 +582,7 @@ test_corruption (GZlibCompressorFormat format, gint level)
ostream1 = g_memory_output_stream_new (NULL, 0, g_realloc, NULL);
compressor = G_CONVERTER (g_zlib_compressor_new (format, level));
costream1 = g_converter_output_stream_new (ostream1, compressor);
+ g_assert (g_converter_output_stream_get_converter (costream1) == compressor);
g_output_stream_splice (costream1, istream0, 0, NULL, &error);
g_assert_no_error (error);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]