Field parsing handling; Make a new string pool everytime when loading a class; Call...
[SquirrelJME.git] / nanocoat / tests / include / test.h
blob9828bb33efd1a8be8fb1595a7e2c7b31c213fb03
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
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 // -------------------------------------------------------------------------*/
10 /**
11 * SquirrelJME test support header.
13 * @since 2023/08/09
16 #ifndef SQUIRRELJME_TEST_H
17 #define SQUIRRELJME_TEST_H
19 #include <setjmp.h>
21 #include "sjme/nvm/nvm.h"
22 #include "sjme/debug.h"
23 #include "sjme/error.h"
24 #include "sjme/test/externTest.h"
26 /* Anti-C++. */
27 #ifdef __cplusplus
28 #ifndef SJME_CXX_IS_EXTERNED
29 #define SJME_CXX_IS_EXTERNED
30 #define SJME_CXX_SQUIRRELJME_TEST_H
31 extern "C" {
32 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
33 #endif /* #ifdef __cplusplus */
35 /*--------------------------------------------------------------------------*/
37 /**
38 * The result of a test.
40 * @since 2023/08/09
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,
52 } sjme_testResult;
54 /**
55 * Basic test information structure.
57 * @since 2023/08/09
59 typedef struct sjme_test
61 /** Base jump point for short circuits. */
62 jmp_buf jumpPoint;
64 /** Allocation pool for tests, so one not need be setup. */
65 sjme_alloc_pool* pool;
67 /** Any extra global value that is needed. */
68 sjme_pointer global;
70 /** Error code. */
71 sjme_errorCode error;
72 } sjme_test;
74 /**
75 * Basic test function.
77 * @param test The current test information.
78 * @return The result of the test.
79 * @since 2023/08/09
81 typedef sjme_testResult (*sjme_basicTestFunc)(sjme_test* test);
83 /**
84 * A test which is available.
86 * @since 2023/08/09
88 typedef struct sjme_availableTest
90 /** The name of the test. */
91 sjme_lpcstr name;
93 /** The function which contains the test code. */
94 sjme_basicTestFunc function;
95 } sjme_availableTest;
97 /**
98 * Declares a test.
100 * @param name The name of the test.
101 * @since 2023/11/21
103 #define SJME_TEST_DECLARE(name) \
104 sjme_attrUnused sjme_testResult name(sjme_attrUnused sjme_test* test)
106 #if defined(SJME_CONFIG_DEBUG)
108 * Checks for leaks.
110 * @param pool The pool to check.
111 * @return Any resultant error, if any.
112 * @since 2024/09/28
114 void sjme_test_leakCheck(sjme_alloc_pool* pool);
115 #endif
117 /*--------------------------------------------------------------------------*/
119 /* Anti-C++. */
120 #ifdef __cplusplus
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 */