Merge branch '976-disable-assert-checks' into 'master'
[glib.git] / gio / tests / buffered-input-stream.c
blobef865fc4594d175f708ef548f00d0d40357f523f
1 /* GLib testing framework examples and tests
2 * Copyright (C) 2008 Red Hat, Inc.
3 * Authors: Matthias Clasen <mclasen@redhat.com>
5 * This work is provided "as is"; redistribution and modification
6 * in whole or in part, in any medium, physical or electronic is
7 * permitted without restriction.
9 * This work is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * In no event shall the authors or contributors be liable for any
14 * direct, indirect, incidental, special, exemplary, or consequential
15 * damages (including, but not limited to, procurement of substitute
16 * goods or services; loss of use, data, or profits; or business
17 * interruption) however caused and on any theory of liability, whether
18 * in contract, strict liability, or tort (including negligence or
19 * otherwise) arising in any way out of the use of this software, even
20 * if advised of the possibility of such damage.
23 #include <glib/glib.h>
24 #include <gio/gio.h>
25 #include <stdlib.h>
26 #include <string.h>
28 static void
29 test_peek (void)
31 GInputStream *base;
32 GInputStream *in;
33 gssize npeek;
34 char *buffer;
36 base = g_memory_input_stream_new_from_data ("abcdefghijk", -1, NULL);
37 in = g_buffered_input_stream_new_sized (base, 64);
39 g_buffered_input_stream_fill (G_BUFFERED_INPUT_STREAM (in), 5, NULL, NULL);
40 g_assert_cmpint (g_buffered_input_stream_get_available (G_BUFFERED_INPUT_STREAM (in)), ==, 5);
41 g_buffered_input_stream_fill (G_BUFFERED_INPUT_STREAM (in), -1, NULL, NULL);
42 g_assert_cmpint (g_buffered_input_stream_get_available (G_BUFFERED_INPUT_STREAM (in)), ==, strlen ("abcdefjhijk"));
44 buffer = g_new0 (char, 64);
45 npeek = g_buffered_input_stream_peek (G_BUFFERED_INPUT_STREAM (in), buffer, 2, 3);
46 g_assert_cmpint (npeek, ==, 3);
47 g_assert_cmpstr ("cde", ==, buffer);
48 g_free (buffer);
50 buffer = g_new0 (char, 64);
51 npeek = g_buffered_input_stream_peek (G_BUFFERED_INPUT_STREAM (in), buffer, 9, 5);
52 g_assert_cmpint (npeek, ==, 2);
53 g_assert_cmpstr ("jk", ==, buffer);
54 g_free (buffer);
56 buffer = g_new0 (char, 64);
57 npeek = g_buffered_input_stream_peek (G_BUFFERED_INPUT_STREAM (in), buffer, 75, 3);
58 g_assert_cmpint (npeek, ==, 0);
59 g_free (buffer);
61 g_object_unref (in);
62 g_object_unref (base);
65 static void
66 test_peek_buffer (void)
68 GInputStream *base;
69 GInputStream *in;
70 gssize nfill;
71 gsize bufsize;
72 char *buffer;
74 base = g_memory_input_stream_new_from_data ("abcdefghijk", -1, NULL);
75 in = g_buffered_input_stream_new (base);
77 nfill = g_buffered_input_stream_fill (G_BUFFERED_INPUT_STREAM (in), strlen ("abcdefghijk"), NULL, NULL);
78 buffer = (char *) g_buffered_input_stream_peek_buffer (G_BUFFERED_INPUT_STREAM (in), &bufsize);
79 g_assert_cmpint (nfill, ==, bufsize);
80 g_assert (0 == strncmp ("abcdefghijk", buffer, bufsize));
82 g_object_unref (in);
83 g_object_unref (base);
86 static void
87 test_set_buffer_size (void)
89 GInputStream *base;
90 GInputStream *in;
91 guint bufsize_prop;
92 gsize size, bufsize;
94 base = g_memory_input_stream_new_from_data ("abcdefghijk", -1, NULL);
95 in = g_buffered_input_stream_new (base);
96 size = g_buffered_input_stream_get_buffer_size (G_BUFFERED_INPUT_STREAM (in));
97 g_assert_cmpint (size, ==, 4096);
99 g_buffered_input_stream_set_buffer_size (G_BUFFERED_INPUT_STREAM (in), 64);
100 size = g_buffered_input_stream_get_buffer_size (G_BUFFERED_INPUT_STREAM (in));
101 g_assert_cmpint (size, ==, 64);
103 /* size cannot shrink below current content len */
104 g_buffered_input_stream_fill (G_BUFFERED_INPUT_STREAM (in), strlen ("abcdefghijk"), NULL, NULL);
105 g_buffered_input_stream_peek_buffer (G_BUFFERED_INPUT_STREAM (in), &bufsize);
106 g_buffered_input_stream_set_buffer_size (G_BUFFERED_INPUT_STREAM (in), 2);
107 size = g_buffered_input_stream_get_buffer_size (G_BUFFERED_INPUT_STREAM (in));
108 g_assert_cmpint (size, ==, bufsize);
109 g_object_get (in, "buffer-size", &bufsize_prop, NULL);
110 g_assert_cmpint (bufsize_prop, ==, bufsize);
112 g_object_unref (in);
114 in = g_buffered_input_stream_new_sized (base, 64);
115 size = g_buffered_input_stream_get_buffer_size (G_BUFFERED_INPUT_STREAM (in));
116 g_assert_cmpint (size, ==, 64);
118 g_object_unref (in);
119 g_object_unref (base);
122 static void
123 test_read_byte (void)
125 GInputStream *base;
126 GInputStream *in;
127 GError *error;
129 g_test_bug ("562393");
131 base = g_memory_input_stream_new_from_data ("abcdefgh", -1, NULL);
132 in = g_buffered_input_stream_new (base);
134 error = NULL;
135 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'a');
136 g_assert_no_error (error);
137 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'b');
138 g_assert_no_error (error);
139 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'c');
140 g_assert_no_error (error);
142 g_assert_cmpint (g_input_stream_skip (in, 3, NULL, &error), ==, 3);
143 g_assert_no_error (error);
145 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'g');
146 g_assert_no_error (error);
147 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'h');
148 g_assert_no_error (error);
149 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, -1);
150 g_assert_no_error (error);
152 g_assert (g_input_stream_close (in, NULL, &error));
153 g_assert_no_error (error);
154 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, -1);
155 g_assert_error (error, G_IO_ERROR, G_IO_ERROR_CLOSED);
156 g_error_free (error);
158 g_object_unref (in);
159 g_object_unref (base);
162 static void
163 test_read (void)
165 GInputStream *base;
166 GInputStream *in;
167 gchar buffer[20];
168 GError *error;
170 base = g_memory_input_stream_new_from_data ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, NULL);
171 in = g_buffered_input_stream_new_sized (base, 8);
173 g_assert_cmpint (g_buffered_input_stream_get_available (G_BUFFERED_INPUT_STREAM (in)), ==, 0);
175 error = NULL;
176 g_assert_cmpint (g_buffered_input_stream_fill (G_BUFFERED_INPUT_STREAM (in), 8, NULL, &error), ==, 8);
177 g_assert_no_error (error);
179 g_assert_cmpint (g_buffered_input_stream_get_available (G_BUFFERED_INPUT_STREAM (in)), ==, 8);
181 memset (buffer, 0, 20);
182 g_assert_cmpint (g_input_stream_read (in, &buffer, 16, NULL, &error), ==, 16);
183 g_assert_cmpstr (buffer, ==, "abcdefghijklmnop");
184 g_assert_no_error (error);
186 g_assert_cmpint (g_buffered_input_stream_get_available (G_BUFFERED_INPUT_STREAM (in)), ==, 0);
188 memset (buffer, 0, 20);
189 g_assert_cmpint (g_input_stream_read (in, &buffer, 16, NULL, &error), ==, 16);
190 g_assert_cmpstr (buffer, ==, "qrstuvwxyzABCDEF");
191 g_assert_no_error (error);
193 memset (buffer, 0, 20);
194 g_assert_cmpint (g_input_stream_read (in, &buffer, 16, NULL, &error), ==, 16);
195 g_assert_cmpstr (buffer, ==, "GHIJKLMNOPQRSTUV");
196 g_assert_no_error (error);
198 memset (buffer, 0, 20);
199 g_assert_cmpint (g_input_stream_read (in, &buffer, 16, NULL, &error), ==, 4);
200 g_assert_cmpstr (buffer, ==, "WXYZ");
201 g_assert_no_error (error);
203 memset (buffer, 0, 20);
204 g_assert_cmpint (g_input_stream_read (in, &buffer, 16, NULL, &error), ==, 0);
205 g_assert_no_error (error);
207 g_object_unref (in);
208 g_object_unref (base);
211 static void
212 return_result_cb (GObject *object,
213 GAsyncResult *result,
214 gpointer user_data)
216 GAsyncResult **ret = user_data;
218 *ret = g_object_ref (result);
221 static void
222 test_read_async (void)
224 GInputStream *base;
225 GInputStream *in;
226 gchar buffer[20];
227 GError *error;
228 GAsyncResult *result;
230 base = g_memory_input_stream_new_from_data ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ", -1, NULL);
231 in = g_buffered_input_stream_new_sized (base, 8);
233 g_assert_cmpint (g_buffered_input_stream_get_available (G_BUFFERED_INPUT_STREAM (in)), ==, 0);
235 error = NULL;
236 result = NULL;
237 g_buffered_input_stream_fill_async (G_BUFFERED_INPUT_STREAM (in), 8,
238 G_PRIORITY_DEFAULT, NULL,
239 return_result_cb, &result);
240 while (!result)
241 g_main_context_iteration (NULL, TRUE);
242 g_assert_cmpint (g_buffered_input_stream_fill_finish (G_BUFFERED_INPUT_STREAM (in), result, &error), ==, 8);
243 g_assert_no_error (error);
244 g_clear_object (&result);
246 g_assert_cmpint (g_buffered_input_stream_get_available (G_BUFFERED_INPUT_STREAM (in)), ==, 8);
248 memset (buffer, 0, 20);
249 g_input_stream_read_async (in, &buffer, 16, G_PRIORITY_DEFAULT,
250 NULL, return_result_cb, &result);
251 while (!result)
252 g_main_context_iteration (NULL, TRUE);
253 g_assert_cmpint (g_input_stream_read_finish (in, result, &error), ==, 16);
254 g_assert_cmpstr (buffer, ==, "abcdefghijklmnop");
255 g_assert_no_error (error);
256 g_clear_object (&result);
258 g_assert_cmpint (g_buffered_input_stream_get_available (G_BUFFERED_INPUT_STREAM (in)), ==, 0);
260 memset (buffer, 0, 20);
261 g_input_stream_read_async (in, &buffer, 16, G_PRIORITY_DEFAULT,
262 NULL, return_result_cb, &result);
263 while (!result)
264 g_main_context_iteration (NULL, TRUE);
265 g_assert_cmpint (g_input_stream_read_finish (in, result, &error), ==, 16);
266 g_assert_cmpstr (buffer, ==, "qrstuvwxyzABCDEF");
267 g_assert_no_error (error);
268 g_clear_object (&result);
270 memset (buffer, 0, 20);
271 g_input_stream_read_async (in, &buffer, 16, G_PRIORITY_DEFAULT,
272 NULL, return_result_cb, &result);
273 while (!result)
274 g_main_context_iteration (NULL, TRUE);
275 g_assert_cmpint (g_input_stream_read_finish (in, result, &error), ==, 16);
276 g_assert_cmpstr (buffer, ==, "GHIJKLMNOPQRSTUV");
277 g_assert_no_error (error);
278 g_clear_object (&result);
280 memset (buffer, 0, 20);
281 g_input_stream_read_async (in, &buffer, 16, G_PRIORITY_DEFAULT,
282 NULL, return_result_cb, &result);
283 while (!result)
284 g_main_context_iteration (NULL, TRUE);
285 g_assert_cmpint (g_input_stream_read_finish (in, result, &error), ==, 4);
286 g_assert_cmpstr (buffer, ==, "WXYZ");
287 g_assert_no_error (error);
288 g_clear_object (&result);
290 memset (buffer, 0, 20);
291 g_input_stream_read_async (in, &buffer, 16, G_PRIORITY_DEFAULT,
292 NULL, return_result_cb, &result);
293 while (!result)
294 g_main_context_iteration (NULL, TRUE);
295 g_assert_cmpint (g_input_stream_read_finish (in, result, &error), ==, 0);
296 g_assert_no_error (error);
297 g_clear_object (&result);
299 g_object_unref (in);
300 g_object_unref (base);
303 static void
304 test_skip (void)
306 GInputStream *base;
307 GInputStream *in;
308 GError *error;
310 base = g_memory_input_stream_new_from_data ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ", -1, NULL);
311 in = g_buffered_input_stream_new_sized (base, 5);
313 error = NULL;
314 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'a');
315 g_assert_no_error (error);
316 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'b');
317 g_assert_no_error (error);
318 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'c');
319 g_assert_no_error (error);
321 g_assert_cmpint (g_input_stream_skip (in, 7, NULL, &error), ==, 7);
322 g_assert_no_error (error);
323 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'k');
324 g_assert_no_error (error);
326 g_assert_cmpint (g_input_stream_skip (in, 10, NULL, &error), ==, 10);
327 g_assert_no_error (error);
328 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'v');
329 g_assert_no_error (error);
331 g_assert_cmpint (g_input_stream_skip (in, 20, NULL, &error), ==, 20);
332 g_assert_no_error (error);
333 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'Q');
334 g_assert_no_error (error);
336 g_assert_cmpint (g_input_stream_skip (in, 10, NULL, &error), ==, 8);
337 g_assert_no_error (error);
338 g_assert_cmpint (g_input_stream_skip (in, 10, NULL, &error), ==, 0);
339 g_assert_no_error (error);
341 g_object_unref (in);
342 g_object_unref (base);
345 static void
346 test_skip_async (void)
348 GInputStream *base;
349 GInputStream *in;
350 GError *error;
351 GAsyncResult *result;
353 base = g_memory_input_stream_new_from_data ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ", -1, NULL);
354 in = g_buffered_input_stream_new_sized (base, 5);
356 error = NULL;
357 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'a');
358 g_assert_no_error (error);
359 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'b');
360 g_assert_no_error (error);
361 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'c');
362 g_assert_no_error (error);
364 result = NULL;
365 g_input_stream_skip_async (in, 7, G_PRIORITY_DEFAULT,
366 NULL, return_result_cb, &result);
367 while (!result)
368 g_main_context_iteration (NULL, TRUE);
369 g_assert_cmpint (g_input_stream_skip_finish (in, result, &error), ==, 7);
370 g_assert_no_error (error);
371 g_clear_object (&result);
372 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'k');
373 g_assert_no_error (error);
375 g_input_stream_skip_async (in, 10, G_PRIORITY_DEFAULT,
376 NULL, return_result_cb, &result);
377 while (!result)
378 g_main_context_iteration (NULL, TRUE);
379 g_assert_cmpint (g_input_stream_skip_finish (in, result, &error), ==, 10);
380 g_assert_no_error (error);
381 g_clear_object (&result);
382 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'v');
383 g_assert_no_error (error);
385 g_input_stream_skip_async (in, 20, G_PRIORITY_DEFAULT,
386 NULL, return_result_cb, &result);
387 while (!result)
388 g_main_context_iteration (NULL, TRUE);
389 g_assert_cmpint (g_input_stream_skip_finish (in, result, &error), ==, 20);
390 g_assert_no_error (error);
391 g_clear_object (&result);
392 g_assert_cmpint (g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error), ==, 'Q');
393 g_assert_no_error (error);
395 g_input_stream_skip_async (in, 10, G_PRIORITY_DEFAULT,
396 NULL, return_result_cb, &result);
397 while (!result)
398 g_main_context_iteration (NULL, TRUE);
399 g_assert_cmpint (g_input_stream_skip_finish (in, result, &error), ==, 8);
400 g_clear_object (&result);
401 g_assert_no_error (error);
403 g_input_stream_skip_async (in, 10, G_PRIORITY_DEFAULT,
404 NULL, return_result_cb, &result);
405 while (!result)
406 g_main_context_iteration (NULL, TRUE);
407 g_assert_cmpint (g_input_stream_skip_finish (in, result, &error), ==, 0);
408 g_clear_object (&result);
409 g_assert_no_error (error);
411 g_object_unref (in);
412 g_object_unref (base);
415 static void
416 test_close (void)
418 GInputStream *base;
419 GInputStream *in;
420 GError *error;
422 base = g_memory_input_stream_new_from_data ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ", -1, NULL);
423 in = g_buffered_input_stream_new (base);
425 g_assert (g_filter_input_stream_get_close_base_stream (G_FILTER_INPUT_STREAM (in)));
427 error = NULL;
428 g_assert (g_input_stream_close (in, NULL, &error));
429 g_assert_no_error (error);
430 g_assert (g_input_stream_is_closed (base));
432 g_object_unref (in);
433 g_object_unref (base);
435 base = g_memory_input_stream_new_from_data ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ", -1, NULL);
436 in = g_buffered_input_stream_new (base);
438 g_filter_input_stream_set_close_base_stream (G_FILTER_INPUT_STREAM (in), FALSE);
440 error = NULL;
441 g_assert (g_input_stream_close (in, NULL, &error));
442 g_assert_no_error (error);
443 g_assert (!g_input_stream_is_closed (base));
445 g_object_unref (in);
446 g_object_unref (base);
449 static void
450 test_seek (void)
452 GInputStream *base;
453 GInputStream *in;
454 GError *error;
455 gint byte;
456 gboolean ret;
458 base = g_memory_input_stream_new_from_data ("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ", -1, NULL);
459 in = g_buffered_input_stream_new_sized (base, 4);
460 error = NULL;
462 /* Seek by read */
463 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 0);
464 byte = g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error);
465 g_assert_no_error (error);
466 g_assert_cmpint (byte, ==, 'a');
467 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 1);
469 /* Seek forward (in buffer) */
470 ret = g_seekable_seek (G_SEEKABLE (in), 1, G_SEEK_CUR, NULL, &error);
471 g_assert_no_error (error);
472 g_assert (ret);
473 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 2);
474 byte = g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error);
475 g_assert_no_error (error);
476 g_assert_cmpint (byte, ==, 'c');
477 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 3);
479 /* Seek backward (in buffer) */
480 ret = g_seekable_seek (G_SEEKABLE (in), -2, G_SEEK_CUR, NULL, &error);
481 g_assert_no_error (error);
482 g_assert (ret);
483 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 1);
484 byte = g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error);
485 g_assert_no_error (error);
486 g_assert_cmpint (byte, ==, 'b');
487 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 2);
489 /* Seek forward (outside buffer) */
490 ret = g_seekable_seek (G_SEEKABLE (in), 6, G_SEEK_CUR, NULL, &error);
491 g_assert_no_error (error);
492 g_assert (ret);
493 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 8);
494 byte = g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error);
495 g_assert_no_error (error);
496 g_assert_cmpint (byte, ==, 'i');
497 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 9);
499 /* Seek backward (outside buffer) */
500 ret = g_seekable_seek (G_SEEKABLE (in), -6, G_SEEK_CUR, NULL, &error);
501 g_assert_no_error (error);
502 g_assert (ret);
503 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 3);
504 byte = g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error);
505 g_assert_no_error (error);
506 g_assert_cmpint (byte, ==, 'd');
507 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 4);
509 /* Seek from beginning */
510 ret = g_seekable_seek (G_SEEKABLE (in), 8, G_SEEK_SET, NULL, &error);
511 g_assert_no_error (error);
512 g_assert (ret);
513 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 8);
514 byte = g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error);
515 g_assert_no_error (error);
516 g_assert_cmpint (byte, ==, 'i');
517 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 9);
519 /* Seek from end */
520 ret = g_seekable_seek (G_SEEKABLE (in), -1, G_SEEK_END, NULL, &error);
521 g_assert_no_error (error);
522 g_assert (ret);
523 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 50);
524 byte = g_buffered_input_stream_read_byte (G_BUFFERED_INPUT_STREAM (in), NULL, &error);
525 g_assert_no_error (error);
526 g_assert_cmpint (byte, ==, 'Z');
527 g_assert_cmpint (g_seekable_tell (G_SEEKABLE (in)), ==, 51);
529 /* Cleanup */
530 g_object_unref (in);
531 g_object_unref (base);
535 main (int argc,
536 char *argv[])
538 g_test_init (&argc, &argv, NULL);
539 g_test_bug_base ("http://bugzilla.gnome.org/");
541 g_test_add_func ("/buffered-input-stream/peek", test_peek);
542 g_test_add_func ("/buffered-input-stream/peek-buffer", test_peek_buffer);
543 g_test_add_func ("/buffered-input-stream/set-buffer-size", test_set_buffer_size);
544 g_test_add_func ("/buffered-input-stream/read-byte", test_read_byte);
545 g_test_add_func ("/buffered-input-stream/read", test_read);
546 g_test_add_func ("/buffered-input-stream/read-async", test_read_async);
547 g_test_add_func ("/buffered-input-stream/skip", test_skip);
548 g_test_add_func ("/buffered-input-stream/skip-async", test_skip_async);
549 g_test_add_func ("/buffered-input-stream/seek", test_seek);
550 g_test_add_func ("/filter-input-stream/close", test_close);
552 return g_test_run();