2
3
4
5
6
7
9#ifndef GIMBAL_TEST_SUITE_H
10#define GIMBAL_TEST_SUITE_H
12#include "../meta/instances/gimbal_object.h"
13#include "../meta/signals/gimbal_signal.h"
16
17
18
20#define GBL_TEST_SUITE(self) (GBL_CAST(GblTestSuite, self))
22#define GBL_TEST_SUITE_GET_CLASS(self) (GBL_CLASSOF(GblTestSuite, self))
28#define GBL_SELF_TYPE GblTestSuite
37
38
39
40
41
42
43typedef GBL_RESULT (*GblTestCaseFn)(
GBL_SELF, GblContext* pCtx);
52
53
54
55
56
57
58
59
62 GBL_RESULT (*pFnSuiteInit) (
GBL_SELF, GblContext* pCtx);
64 GBL_RESULT (*pFnSuiteFinal)(
GBL_SELF, GblContext* pCtx);
66 GBL_RESULT (*pFnCaseInit) (
GBL_SELF, GblContext* pCtx);
68 GBL_RESULT (*pFnCaseFinal) (
GBL_SELF, GblContext* pCtx);
74
75
76
77
78
79
80
81
86 GBL_RESULT (*pFnSuiteName)(
GBL_CSELF,
const char** ppName);
88 GBL_RESULT (*pFnCaseCount)(
GBL_CSELF, size_t *pSize);
90 GBL_RESULT (*pFnCaseName) (
GBL_CSELF, size_t index,
const char** ppName);
92 GBL_RESULT (*pFnCaseRun) (
GBL_SELF, GblContext* pCtx, size_t index);
96
97
98
99
100
101
102
103
104
105
132 const GblTestSuiteVTable* pVTable,
134 size_t instancePrivateSize,
138
139
140
144 const GblTestSuiteVTable* pVTable,
154
155
156
170
171
172
183
184
185
201
202
203
223#define GblTestSuite_create(...)
224 GblTestSuite_createDefault_
(__VA_ARGS__)
225#define GblTestSuite_createDefault_(...)
227#define GblTestSuite_createDefault__(type, name, vtable, size, klass, ...)
228 (GblTestSuite_create
)(type, name, vtable, size, klass)
#define GBL_CLASS_CAST(cType, klass)
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_INSTANCE_DERIVE(derivedInstance, baseInstance)
#define GBL_CLASS_DERIVE(...)
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)
#define GBL_STRING_TYPE
Builtin ID for string GblVariant type.
#define GBL_UINT32_TYPE
Builtin ID for uint32_t GblVariant type.
#define GBL_PROPERTIES(object,...)
Declares a list of properties for the given object/instance structure.
GBL_RESULT GblTestSuite_initCase(GblTestSuite *pSelf, GblContext *pCtx)
Calls the case-level initialization function for the next test case.
GBL_RESULT GblTestSuite_finalCase(GblTestSuite *pSelf, GblContext *pCtx)
Calls the case-level finalization function for the previous test case.
GblBool GblTestSuite_ran(const GblTestSuite *pSelf)
Returns GBL_TRUE if the test suite has been run and GBL_FALSE otherwise.
const char * GblTestSuite_name(const GblTestSuite *pSelf)
Returns the string name of the test suite.
GblTestSuite * GblTestSuite_create(GblType type, const char *pName, const GblTestSuiteVTable *pVTable, size_t size, GblTestSuiteClass *pClass)
Creates a new GblTestSuite instance with the given properties (or defaults if not specified).
GBL_RESULT GblTestSuite_addCases(GblTestSuite *pSelf, const GblTestCase *pCases)
Enqueues an array of cases, terminated by a final entry of all NULL values.
GblBool GblTestSuite_passed(const GblTestSuite *pSelf)
Returns GBL_TRUE if the test suite passed and GBL_FALSE otherwise.
const char * GblTestSuite_caseName(const GblTestSuite *pSelf, size_t index)
Returns the name of the test case at the given index within the test suite.
GBL_RESULT GblTestSuite_result(const GblTestSuite *pSelf)
Returns the top-level aggregate result for the overall test suite.
GblBool GblTestSuite_caseRan(const GblTestSuite *pSelf, const char *pCaseName)
Returns whether the test case with the given name has run.
GBL_RESULT GblTestSuite_addCase(GblTestSuite *pSelf, const char *pName, GblTestCaseFn pFnTest)
Enqueues a single test case into the given test suite.
GblTestScenario * GblTestSuite_scenario(const GblTestSuite *pSelf)
Returns the parent test scenario object or NULL if there isn't one.
GBL_RESULT GblTestSuite_caseResult(const GblTestSuite *pSelf, size_t index)
Returns the result of the test case at the given index within the test suite.
GblRefCount GblTestSuite_unref(GblTestSuite *pSelf)
Decrements the refcount of the given GblTestSuite by 1, destroying it if it reaches 0.
GblType GblTestSuite_type(void)
Returns the GblType UUID associated with GblTestSuite.
GBL_RESULT GblTestSuite_initSuite(GblTestSuite *pSelf, GblContext *pCtx)
Calls the top-level initialization function for the entire suite.
size_t GblTestSuite_caseCount(const GblTestSuite *pSelf)
Returns the number of test cases within the given test suite.
GBL_RESULT GblTestSuite_finalSuite(GblTestSuite *pSelf, GblContext *pCtx)
Calls the top-level finalization function for the entire suite.
size_t GblTestSuite_caseIndex(const GblTestSuite *pSelf, const char *pCaseName)
Returns the index of the test case with the given name within the test suite.
GBL_RESULT GblTestSuite_skipCase(GblTestSuite *pSelf, GblContext *pCtx, size_t index)
Skips the test case at index within the given suite.
GblType GblTestSuite_register(const char *pName, const GblTestSuiteVTable *pVTable, size_t instanceSize, size_t instancePrivateSize, GblFlags typeFlags)
Registers a new GblType deriving from GBL_TEST_SUITE_TYPE.
GBL_RESULT GblTestSuite_runCase(GblTestSuite *pSelf, GblContext *pCtx, size_t index)
Runs the test case at index within the given suite, returning its result code.
GblBool GblTestSuite_casePassed(const GblTestSuite *pSelf, const char *pCaseName)
Returns whether the test case with the given name has passed.
GblTestSuite * GblTestSuite_ref(GblTestSuite *pSelf)
Returns a new reference to the GblTestSuite, incrementing its reference count by 1.
uint32_t GblFlags
Standard-sized flags type, 32-bits across platforms.
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
Captures a result, its stringified message, and a source context.
Represenst a single test case within a GblTestSuite.
const char * pName
Name of the test case.
GblTestCaseFn pFnRun
Function callback for the test case.
const GblTestSuiteVTable * pVTable
Pointer to external virtual method table + default test case array.
GblObject representing a collection of unit test cases.
GblCallRecord lastRecord
Call record of the failing test case.
size_t casesRun
Number of test cases which have run.
size_t casesFailed
Number of test cases which have failed.
size_t failingCase
Failing test case index.
size_t casesSkipped
Number of test cases which have been skipped.
size_t casesPassed
Number of test cases which have passed.
Virtual table structure for a GblTestSuiteClass.
const GblTestCase * pCases
Pointer to a NULL-terminated array of test cases to add to the suite.