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 // -------------------------------------------------------------------------*/
14 #include "testCloseable.h"
16 sjme_errorCode
testCloseable_new(
17 sjme_attrInNotNull sjme_alloc_pool
* inPool
,
18 sjme_attrOutNotNull sjme_closeable
* outCloseable
,
19 sjme_attrInNotNull sjme_closeable_closeHandlerFunc handlerFunc
,
20 sjme_attrInValue sjme_jboolean isRefCounted
)
23 sjme_closeable result
;
25 if (inPool
== NULL
|| outCloseable
== NULL
|| handlerFunc
== NULL
)
26 return SJME_ERROR_NULL_ARGUMENTS
;
30 if (sjme_error_is(error
= sjme_closeable_alloc(
31 inPool
, sizeof(*result
),
32 handlerFunc
, isRefCounted
,
33 &result
)) || result
== NULL
)
34 return sjme_error_default(error
);
37 *outCloseable
= result
;
38 return SJME_ERROR_NONE
;
41 static sjme_errorCode
testHandler(
42 sjme_attrInNotNull sjme_closeable closeable
)
44 return SJME_ERROR_NONE
;
48 * Generic closeable test.
52 SJME_TEST_DECLARE(testCloseable
)
54 sjme_closeable closing
;
57 if (sjme_error_is(test
->error
= testCloseable_new(test
->pool
,
58 &closing
, testHandler
,
60 return sjme_unit_fail(test
, "Could not make closeable?");
63 return SJME_TEST_RESULT_PASS
;