2
3
4
5
6
7
8
9
10
11
12
13#ifndef GIMBAL_TEST_MACROS_H
14#define GIMBAL_TEST_MACROS_H
16#include "../preprocessor/gimbal_macro_utils.h"
28GBL_INLINE const char* GBL_TEST_COMPARE_FMT_DFLT_ (
void) {
return "Values differed"; }
29GBL_INLINE const char* GBL_TEST_COMPARE_FMT_CHAR_ (
void) {
return "Values differed [actual: %c, expected: %c]"; }
30GBL_INLINE const char* GBL_TEST_COMPARE_FMT_INT_ (
void) {
return "Values differed [actual: %d, expected: %d]"; }
31GBL_INLINE const char* GBL_TEST_COMPARE_FMT_UINT_ (
void) {
return "Values differed [actual: %u, expected: %u]"; }
32GBL_INLINE const char* GBL_TEST_COMPARE_FMT_LINT_ (
void) {
return "Values differed [actual: %" PRId64
", expected: %" PRId64
"]"; }
33GBL_INLINE const char* GBL_TEST_COMPARE_FMT_LUINT_(
void) {
return "Values differed [actual: %" PRIu64
", expected: %" PRIu64
"]"; }
34GBL_INLINE const char* GBL_TEST_COMPARE_FMT_STR_ (
void) {
return "Values differed [actual: %s, expected: %s]"; }
35GBL_INLINE const char* GBL_TEST_COMPARE_FMT_FLT_ (
void) {
return "Values differed [actual: %f, expected: %f]"; }
36GBL_INLINE const char* GBL_TEST_COMPARE_FMT_PTR_ (
void) {
return "Values differed [actual: %p, expected: %p]"; }
38#define GBL_TEST_COMPARE_FMT_TABLE_ (
39 GBL_TEST_COMPARE_FMT_PTR_,
41 (char, GBL_TEST_COMPARE_FMT_CHAR_),
42 (int16_t, GBL_TEST_COMPARE_FMT_INT_),
43 (int32_t, GBL_TEST_COMPARE_FMT_INT_),
44 (int64_t, GBL_TEST_COMPARE_FMT_LINT_),
45 (uint8_t, GBL_TEST_COMPARE_FMT_UINT_),
46 (uint16_t, GBL_TEST_COMPARE_FMT_UINT_),
47 (uint32_t, GBL_TEST_COMPARE_FMT_UINT_),
48 (uint64_t, GBL_TEST_COMPARE_FMT_LUINT_),
49 (const char*, GBL_TEST_COMPARE_FMT_STR_),
50 (char*, GBL_TEST_COMPARE_FMT_STR_),
51 (float, GBL_TEST_COMPARE_FMT_FLT_),
52 (double, GBL_TEST_COMPARE_FMT_FLT_),
53 (const void*, GBL_TEST_COMPARE_FMT_PTR_)
58GBL_INLINE GblBool GBL_TEST_COMPARE_CMP_UINTPTR_(uintptr_t actual, uintptr_t expected) {
return actual == expected; }
59GBL_INLINE GblBool GBL_TEST_COMPARE_CMP_PTR_ (
const void* pActual,
const void* pExpected) {
return pActual == pExpected; }
60GBL_INLINE GblBool GBL_TEST_COMPARE_CMP_UINT32_ (uint32_t actual, uint32_t expected) {
return actual == expected; }
61GBL_INLINE GblBool GBL_TEST_COMPARE_CMP_UINT64_ (uint64_t actual, uint64_t expected) {
return actual == expected; }
62GBL_INLINE GblBool GBL_TEST_COMPARE_CMP_INT32_ (int32_t actual, int32_t expected) {
return actual == expected; }
63GBL_INLINE GblBool GBL_TEST_COMPARE_CMP_INT64_ (int64_t actual, int64_t expected) {
return actual == expected; }
64GBL_INLINE GblBool GBL_TEST_COMPARE_CMP_DBL_ (
double actual,
double expected) {
return actual == expected; }
65GBL_INLINE GblBool GBL_TEST_COMPARE_CMP_STR_ (
const char* pActual,
const char* pExpected) {
return pActual == pExpected ||
66 (pActual && pExpected &&
67 strcmp(pActual, pExpected) == 0); }
70#if defined(GBL_DREAMCAST)
71# define GBL_TEST_CMP_PLATFORM_ENTRIES()
72 (size_t , GBL_TEST_COMPARE_CMP_UINT32_),
73 (int, GBL_TEST_COMPARE_CMP_INT32_),
75# define GBL_TEST_CMP_PLATFORM_ENTRIES()
76 (size_t , GBL_TEST_COMPARE_CMP_UINT32_),
77 (int, GBL_TEST_COMPARE_CMP_INT32_),
78#elif (defined(__APPLE__) && defined(GBL_64BIT
))
79# define GBL_TEST_CMP_PLATFORM_ENTRIES()
80 (size_t , GBL_TEST_COMPARE_CMP_UINT64_),
81 (long, GBL_TEST_COMPARE_CMP_INT64_),
82#elif defined(__EMSCRIPTEN__)
83# define GBL_TEST_CMP_PLATFORM_ENTRIES()
84 (size_t , GBL_TEST_COMPARE_CMP_UINT64_),
85 (int8_t, GBL_TEST_COMPARE_CMP_UINT32_),
87# define GBL_TEST_CMP_PLATFORM_ENTRIES()
90#define GBL_TEST_COMPARE_CMP_TABLE_ (
91 GBL_TEST_COMPARE_CMP_PTR_,
93 (char, GBL_TEST_COMPARE_CMP_INT32_),
94 (int16_t, GBL_TEST_COMPARE_CMP_INT32_),
95 (int32_t, GBL_TEST_COMPARE_CMP_INT32_),
96 (int64_t, GBL_TEST_COMPARE_CMP_INT64_),
97 (uint8_t, GBL_TEST_COMPARE_CMP_UINT32_),
98 (uint16_t, GBL_TEST_COMPARE_CMP_UINT32_),
99 (uint32_t, GBL_TEST_COMPARE_CMP_UINT32_),
100 (uint64_t, GBL_TEST_COMPARE_CMP_UINT64_),
101 GBL_TEST_CMP_PLATFORM_ENTRIES
()
102 (const char*, GBL_TEST_COMPARE_CMP_STR_),
103 (char*, GBL_TEST_COMPARE_CMP_STR_),
104 (float, GBL_TEST_COMPARE_CMP_DBL_),
105 (double, GBL_TEST_COMPARE_CMP_DBL_),
106 (const void*, GBL_TEST_COMPARE_CMP_PTR_)
116 "Values differed [expected: %d, actual: %d]",
120 "Values differed [expected: %u, actual: %u]",
124 "Values differed [expected: %s, actual: %s]",
128 "Values differed [expected: %f, actual: %f]",
132 "Values differed [exptected: %p, actual: %p]",
145#define GBL_TEST_EXPECT_ERROR()
149 "Skipping test case due to GBL_CONFIG_ASSERT_ERROR_ENABLED.");
151 if(pScenario) GblTestScenario_expectError(pScenario);
155#ifndef GBL_SELF_TYPE_NAME
156# define GBL_SELF_TYPE_NAME pSelf
159#ifndef GBL_TEST_SUITE_CONTEXT_NAME
160# define GBL_TEST_SUITE_CONTEXT_NAME pCtx
163#ifndef GBL_SELF_TYPE_PRIVATE_NAME
164# define GBL_SELF_TYPE_PRIVATE_NAME pFixture
167#ifndef GBL_SELF_TYPE_PRIVATE
168# define GBL_SELF_TYPE_PRIVATE GBL_GLUE(GBL_SELF_TYPE, _)
171#define GBL_TEST_CASE(name)
183#define GBL_TEST_CASE_END
186#define GBL_TEST_FIXTURE_TYPE
189#define GBL_TEST_FIXTURE
195# define GBL_TEST_REGISTER(...)
198# define GBL_TEST_REGISTER(...)
199 GBL_TEST_REGISTER_(__VA_ARGS__)
202#define GBL_TEST_REGISTER_(...)
205 const static GblTestCase cases[] = {
209 const static GblTestSuiteVTable vTable = {
216 type = GblTestSuite_register(GblQuark_internStatic(GBL_STRINGIFY(GBL_SELF_TYPE)),
218 sizeof(GBL_SELF_TYPE),
220 GBL_TYPE_FLAGS_NONE);
225}
227#define GBL_TEST_CASE_PAIR(suiteName, caseName)
232#define GBL_TEST_NO_INIT
235#define GBL_TEST_NO_FINAL
#define GBL_CTX_VERIFY_CALL(...)
#define GBL_CTX_END_BLOCK()
#define GBL_CTX_VERIFY_LAST_RECORD()
#define GBL_CTX_BEGIN(...)
#define GBL_CTX_VERIFY_EXPRESSION(...)
#define GBL_CTX_VERIFY(...)
#define GBL_CTX_CONTEXT()
#define GBL_DECLARE_STRUCT(S)
#define GBL_PRIVATE(cType, self)
#define GBL_TUPLE_FOREACH(MACRO_, DATA_, TUPLE_)
#define GBL_META_GENERIC_MACRO_GENERATE(traits, X)
#define GBL_RESULT_ERROR(value)
#define GBL_TEST_FIXTURE_TYPE
#define GBL_TEST_COMPARE_FMT_(value)
#define GBL_TEST_COMPARE_CMP_(actual, expected)
#define GBL_SELF_TYPE_PRIVATE
#define GBL_TEST_CASE(name)
#define GBL_TEST_CASE_PAIR(suiteName, caseName)
#define GBL_TEST_REGISTER_(...)
#define GBL_SELF_TYPE_PRIVATE_NAME
#define GBL_TEST_CASE_END
#define GBL_SELF_TYPE_NAME
#define GBL_TEST_SUITE_CONTEXT_NAME
#define GBL_TEST_SCENARIO(self)
#define GBL_INVALID_TYPE
GblType UUID of the invalid type.
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)