[glib] Improve GMemoryInputStream test coverage
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib] Improve GMemoryInputStream test coverage
- Date: Sun, 2 Jun 2013 05:48:25 +0000 (UTC)
commit 0326f146fd3bbff74e7ca1e77bef814601c1a981
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Jun 2 01:44:49 2013 -0400
Improve GMemoryInputStream test coverage
gio/tests/memory-input-stream.c | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/memory-input-stream.c b/gio/tests/memory-input-stream.c
index 48fa3c7..2bf3d45 100644
--- a/gio/tests/memory-input-stream.c
+++ b/gio/tests/memory-input-stream.c
@@ -263,6 +263,28 @@ test_read_bytes (void)
g_object_unref (stream);
}
+static void
+test_from_bytes (void)
+{
+ gchar data[4096], buffer[4096];
+ GBytes *bytes;
+ GError *error = NULL;
+ GInputStream *stream;
+ gint i;
+
+ for (i = 0; i < 4096; i++)
+ data[i] = 1 + i % 255;
+
+ bytes = g_bytes_new_static (data, 4096);
+ stream = g_memory_input_stream_new_from_bytes (bytes);
+ g_assert (g_input_stream_read (stream, buffer, 2048, NULL, &error) == 2048);
+ g_assert_no_error (error);
+ g_assert (strncmp (data, buffer, 2048) == 0);
+
+ g_object_unref (stream);
+ g_bytes_unref (bytes);
+}
+
int
main (int argc,
char *argv[])
@@ -274,6 +296,7 @@ main (int argc,
g_test_add_func ("/memory-input-stream/seek", test_seek);
g_test_add_func ("/memory-input-stream/truncate", test_truncate);
g_test_add_func ("/memory-input-stream/read-bytes", test_read_bytes);
+ g_test_add_func ("/memory-input-stream/from-bytes", test_from_bytes);
return g_test_run();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]