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 // -------------------------------------------------------------------------*/
11 * SquirrelJME test support header.
16 #ifndef SQUIRRELJME_TEST_H
17 #define SQUIRRELJME_TEST_H
21 #include "sjme/nvm/nvm.h"
22 #include "sjme/debug.h"
23 #include "sjme/error.h"
24 #include "sjme/test/externTest.h"
28 #ifndef SJME_CXX_IS_EXTERNED
29 #define SJME_CXX_IS_EXTERNED
30 #define SJME_CXX_SQUIRRELJME_TEST_H
32 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
33 #endif /* #ifdef __cplusplus */
35 /*--------------------------------------------------------------------------*/
38 * The result of a test.
42 typedef enum sjme_testResult
44 /** The test passed. */
45 SJME_TEST_RESULT_PASS
= 0,
47 /** The test failed. */
48 SJME_TEST_RESULT_FAIL
= 1,
50 /** The test skipped. */
51 SJME_TEST_RESULT_SKIP
= 2,
55 * Basic test information structure.
59 typedef struct sjme_test
61 /** Base jump point for short circuits. */
64 /** Allocation pool for tests, so one not need be setup. */
65 sjme_alloc_pool
* pool
;
67 /** Any extra global value that is needed. */
75 * Basic test function.
77 * @param test The current test information.
78 * @return The result of the test.
81 typedef sjme_testResult (*sjme_basicTestFunc
)(sjme_test
* test
);
84 * A test which is available.
88 typedef struct sjme_availableTest
90 /** The name of the test. */
93 /** The function which contains the test code. */
94 sjme_basicTestFunc function
;
100 * @param name The name of the test.
103 #define SJME_TEST_DECLARE(name) \
104 sjme_attrUnused sjme_testResult name(sjme_attrUnused sjme_test* test)
106 #if defined(SJME_CONFIG_DEBUG)
110 * @param pool The pool to check.
111 * @return Any resultant error, if any.
114 void sjme_test_leakCheck(sjme_alloc_pool
* pool
);
117 /*--------------------------------------------------------------------------*/
121 #ifdef SJME_CXX_SQUIRRELJME_TEST_H
123 #undef SJME_CXX_SQUIRRELJME_TEST_H
124 #undef SJME_CXX_IS_EXTERNED
125 #endif /* #ifdef SJME_CXX_SQUIRRELJME_TEST_H */
126 #endif /* #ifdef __cplusplus */
128 #endif /* SQUIRRELJME_TEST_H */