[glib] Add a test for skipping



commit fb120b5d8717f9798be28cdc7bab768f7ca0309a
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jul 4 20:50:50 2010 -0400

    Add a test for skipping

 gio/tests/buffered-input-stream.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/buffered-input-stream.c b/gio/tests/buffered-input-stream.c
index 8d111e6..3702ca5 100644
--- a/gio/tests/buffered-input-stream.c
+++ b/gio/tests/buffered-input-stream.c
@@ -124,6 +124,26 @@ test_read_byte (void)
   g_object_unref (in);
 }
 
+static void
+test_skip (void)
+{
+  GInputStream *base;
+  GInputStream *in;
+
+  base = g_memory_input_stream_new_from_data ("abcdefghijk", -1, NULL);
+  in = g_buffered_input_stream_new_sized (base, 5);
+
+  g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, NULL), ==, 'a');
+  g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, NULL), ==, 'b');
+  g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, NULL), ==, 'c');
+
+  g_assert_cmpint (g_input_stream_skip (in, 7, NULL, NULL), ==, 7);
+  
+  g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, NULL), ==, 'k');
+
+  g_object_unref (in);
+}
+
 int
 main (int   argc,
       char *argv[])
@@ -136,6 +156,7 @@ main (int   argc,
   g_test_add_func ("/buffered-input-stream/peek-buffer", test_peek_buffer);
   g_test_add_func ("/buffered-input-stream/set-buffer-size", test_set_buffer_size);
   g_test_add_func ("/buffered-input-stream/read-byte", test_read_byte);
+  g_test_add_func ("/buffered-input-stream/skip", test_skip);
 
   return g_test_run();
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]