1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
16 static const sjme_jubyte emptyBuffer
[1] =
22 * Tests reading of an empty stream.
26 SJME_TEST_DECLARE(testStreamEmpty
)
28 sjme_stream_input inputStream
;
32 if (sjme_error_is(sjme_stream_inputOpenMemory(test
->pool
,
33 &inputStream
, emptyBuffer
, 0)))
34 return sjme_unit_fail(test
, "Could not open input stream.");
36 /* Try to read a single byte, it should indicate EOS. */
38 if (sjme_error_is(sjme_stream_inputReadSingle(inputStream
,
40 return sjme_unit_fail(test
, "Could not read single byte.");
43 sjme_unit_equalI(test
, -1, result
,
44 "Incorrect read byte?");
46 /* Close the stream. */
47 if (sjme_error_is(sjme_closeable_close(
48 SJME_AS_CLOSEABLE(inputStream
))))
49 return sjme_unit_fail(test
, "Could not close stream?");
52 return SJME_TEST_RESULT_PASS
;