libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_test_scenario.h
Go to the documentation of this file.
1/*! \file
2 * \brief GblTestScenario and related functions.
3 * \ingroup testing
4 *
5 * \author 2023, 2024 Falco Girgis
6 * \copyright MIT License
7 */
8#ifndef GIMBAL_TEST_SCENARIO_H
9#define GIMBAL_TEST_SCENARIO_H
10
11#include "../meta/instances/gimbal_context.h"
12#include "../meta/signals/gimbal_signal.h"
13
14/*! \name Type System
15 * \brief Type UUID and cast operators
16 * @{
17 */
18#define GBL_TEST_SCENARIO_TYPE (GBL_TYPEID(GblTestScenario))
19#define GBL_TEST_SCENARIO(self) (GBL_CAST(GblTestScenario, self))
20#define GBL_TEST_SCENARIO_CLASS(klass) (GBL_CLASS_CAST(GblTestScenario, klass))
21#define GBL_TEST_SCENARIO_GET_CLASS(self) (GBL_CLASSOF(GblTestScenario, self))
22//! @}
23
24#define GBL_SELF_TYPE GblTestScenario
25
27
28GBL_FORWARD_DECLARE_STRUCT(GblTestScenario);
29GBL_FORWARD_DECLARE_STRUCT(GblTestSuite);
30
31/*! \struct GblTestScenarioClass
32 * \extends GblContextClass
33 * \brief GblClass VTable structure for a GblTestScenario
34 *
35 * Provides a series of overridable virtual methods for looking
36 * up into individual GblTestSuites and executing them. This allows
37 * for mapping to a custom back-end that doesn't use GblTestSuite
38 * objects.
39 *
40 * \sa GblTestScenario
41 */
42GBL_CLASS_DERIVE(GblTestScenario, GblContext)
43 GBL_RESULT (*pFnBegin) (GBL_SELF);
44 GBL_RESULT (*pFnEnd) (GBL_SELF);
45 GBL_RESULT (*pFnRun) (GBL_SELF, int argc, const char* argv[]);
46 GBL_RESULT (*pFnSuiteBegin)(GBL_SELF, const GblTestSuite* pSuite);
47 GBL_RESULT (*pFnSuiteEnd) (GBL_SELF, const GblTestSuite* pSuite);
49
50/*! \struct GblTestScenario
51 * \extends GblContext
52 * \ingroup testing
53 * \brief Represents a single top-level test object
54 *
55 * GblTestScenario is the highest-level test object in the
56 * testing framework, and is logically divided into a series
57 * of related, yet independently executing GblTestSuite
58 * objects.
59 *
60 * \sa GblTestScenarioClass
61 */
63 GBL_RESULT result;
64 size_t suitesRun;
65 size_t suitesPassed;
66 size_t suitesFailed;
67 size_t suitesSkipped;
68 size_t caseCount;
69 size_t casesRun;
70 size_t casesPassed;
71 size_t casesFailed;
72 size_t casesSkipped;
73 double totalTime;
75
76GBL_PROPERTIES(GblTestScenario,
77 (testResult, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE),
78 (suiteCount, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE),
79 (suitesRun, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE),
80 (suitesPassed, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE),
81 (suitesFailed, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE),
82 (suitesSkipped, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE),
83 (caseCount, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE),
84 (casesRun, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE),
85 (casesPassed, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE),
86 (casesFailed, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE),
87 (casesSkipped, GBL_GENERIC, (READ, SAVE), GBL_UINT32_TYPE)
88)
89
90GBL_SIGNALS(GblTestScenario,
91 (began),
92 (ended),
93 (suiteBegan, (GBL_INSTANCE_TYPE, pSuite)),
94 (suiteEnded, (GBL_INSTANCE_TYPE, pSuite)),
95 (caseBegan, (GBL_INSTANCE_TYPE, pSuite), (GBL_SIZE_TYPE, caseIndex)),
96 (caseEnded, (GBL_INSTANCE_TYPE, pSuite), (GBL_SIZE_TYPE, caseIndex))
97)
98
99GBL_EXPORT GblType GblTestScenario_type (void) GBL_NOEXCEPT;
100GBL_EXPORT GblTestScenario* GblTestScenario_create (const char* pName) GBL_NOEXCEPT;
101GBL_EXPORT GblTestScenario* GblTestScenario_ref (GBL_SELF) GBL_NOEXCEPT;
102GBL_EXPORT GblRefCount GblTestScenario_unref (GBL_SELF) GBL_NOEXCEPT;
103GBL_EXPORT GBL_RESULT GblTestScenario_enqueueSuite (GBL_SELF, const GblTestSuite* pSuite) GBL_NOEXCEPT;
104GBL_EXPORT GblTestSuite* GblTestScenario_currentSuite (GBL_CSELF) GBL_NOEXCEPT;
105GBL_EXPORT GblTestSuite* GblTestScenario_findSuite (GBL_CSELF, const char* pName) GBL_NOEXCEPT;
106GBL_EXPORT size_t GblTestScenario_currentCase (GBL_CSELF) GBL_NOEXCEPT;
107GBL_EXPORT GBL_RESULT GblTestScenario_run (GBL_SELF, int argc, const char* argv[]) GBL_NOEXCEPT;
108GBL_EXPORT int GblTestScenario_exec (GBL_SELF, int argc, const char* argv[]) GBL_NOEXCEPT;
109GBL_EXPORT GblBool GblTestScenario_ran (GBL_CSELF) GBL_NOEXCEPT;
110GBL_EXPORT GblBool GblTestScenario_passed (GBL_CSELF) GBL_NOEXCEPT;
111GBL_EXPORT void GblTestScenario_expectError (GBL_CSELF) GBL_NOEXCEPT;
112
114
115#undef GBL_SELF_TYPE
116
117#endif // GIMBAL_TEST_SCENARIO_H
#define GBL_CLASS_CAST(cType, klass)
#define GBL_NOEXCEPT
#define GBL_DECLS_BEGIN
#define GBL_FORWARD_DECLARE_STRUCT(S)
#define GBL_TYPEID(instanceStruct)
#define GBL_INSTANCE_DERIVE(derivedInstance, baseInstance)
#define GBL_CLASS_DERIVE(...)
#define GBL_INSTANCE_END
#define GBL_EXPORT
#define GBL_CLASS_END
#define GBL_CLASSOF(cType, self)
#define GBL_CAST(cType, self)
#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.
#define GBL_SIGNALS(instanceStruct,...)
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
uintptr_t GblType
Meta Type UUID.
Definition gimbal_type.h:51
Represents a single top-level test object.