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 #include "sjme/stream.h"
19 * Tests writing a single byte to the output.
23 SJME_TEST_DECLARE(testStreamWriteSingle
)
25 sjme_stream_output stream
;
28 /* Clear output first. */
29 memset(&value
, 0, sizeof(value
));
31 /* Setup output stream. */
33 if (sjme_error_is(sjme_stream_outputOpenMemory(test
->pool
,
34 &stream
, &value
, 1)) || stream
== NULL
)
35 return sjme_unit_fail(test
, "Could not open output stream.");
37 /* Write single value. */
38 if (sjme_error_is(sjme_stream_outputWriteSingle(stream
,
40 return sjme_unit_fail(test
, "Could not write output value.");
42 /* The write count should be the buffer size. */
43 sjme_unit_equalI(test
,
44 1, stream
->totalWritten
,
45 "Number of written bytes incorrect?");
47 /* Was this value written? */
48 sjme_unit_equalI(test
, 123, value
,
49 "Value was not written?");
52 if (sjme_error_is(sjme_closeable_close(
53 SJME_AS_CLOSEABLE(stream
))))
54 return sjme_unit_fail(test
, "Could not close output stream.");
57 return SJME_TEST_RESULT_PASS
;