mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-12 23:46:17 +01:00
Improve test coverage for filter streams
This commit is contained in:
parent
b22f4a2dd2
commit
beea8c5c84
@ -11,13 +11,17 @@
|
|||||||
* Author: Ryan Lortie <desrt@desrt.ca>
|
* Author: Ryan Lortie <desrt@desrt.ca>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
#include <glib/glib.h>
|
#include <glib/glib.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
test_input_filter (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");
|
g_test_bug ("568394");
|
||||||
base = g_memory_input_stream_new_from_data ("abcdefghijk", -1, NULL);
|
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 (f1));
|
||||||
g_assert (!g_input_stream_is_closed (f2));
|
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_object_unref (f1);
|
||||||
|
|
||||||
g_assert (!g_input_stream_is_closed (base));
|
g_assert (!g_input_stream_is_closed (base));
|
||||||
g_assert (!g_input_stream_is_closed (f2));
|
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_object_unref (f2);
|
||||||
|
|
||||||
g_assert (g_input_stream_is_closed (base));
|
g_assert (g_input_stream_is_closed (base));
|
||||||
|
Loading…
Reference in New Issue
Block a user