Commit 2764b75d authored by Matthias Clasen's avatar Matthias Clasen

More stream tests

parent 10b2606a
......@@ -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();
}
......@@ -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 ();
}
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment