libGimbal 0.1.0
C17-Based Extended Standard Library and Cross-Language Runtime Framework
Loading...
Searching...
No Matches
gimbal_test_suite.h File Reference

Go to the source code of this file.

Data Structures

struct  GblTestCase
 
struct  GblTestSuiteVTable
 
struct  GblTestSuiteClass
 
struct  GblTestSuite
 

Macros

#define GBL_TEST_CASE_LAST
 
Type System

Type UUID and cast operators

#define GBL_TEST_SUITE_TYPE
 
#define GBL_TEST_SUITE(self)
 
#define GBL_TEST_SUITE_CLASS(klass)
 
#define GBL_TEST_SUITE_GET_CLASS(self)
 

Typedefs

typedef GBL_RESULT(* GblTestCaseFn) (GblTestSuite *pSelf, GblContext *pCtx)
 

Functions

GblType GblTestSuite_type (void)
 
GblType GblTestSuite_register (const char *pName, const GblTestSuiteVTable *pVTable, size_t instanceSize, size_t instancePrivateSize, GblFlags typeFlags)
 
Test Suite Creation

Methods for managing test suite lifetimes.

GblTestSuiteGblTestSuite_create (GblType type, const char *pName, const GblTestSuiteVTable *pVTable, size_t size, GblTestSuiteClass *pClass)
 
GblTestSuiteGblTestSuite_ref (GblTestSuite *pSelf)
 
GblRefCount GblTestSuite_unref (GblTestSuite *pSelf)
 
Test Suite Properties

Methods providing accessors for test suite properties.

const char * GblTestSuite_name (const GblTestSuite *pSelf)
 
GblBool GblTestSuite_ran (const GblTestSuite *pSelf)
 
GblBool GblTestSuite_passed (const GblTestSuite *pSelf)
 
GblTestScenarioGblTestSuite_scenario (const GblTestSuite *pSelf)
 
GBL_RESULT GblTestSuite_result (const GblTestSuite *pSelf)
 
Test Case Registration

Methods for adding test cases to the suite.

GBL_RESULT GblTestSuite_addCase (GblTestSuite *pSelf, const char *pName, GblTestCaseFn pFnTest)
 
GBL_RESULT GblTestSuite_addCases (GblTestSuite *pSelf, const GblTestCase *pCases)
 
Test Case Accessors

Methods for accessing test-case properties.

GblBool GblTestSuite_caseRan (const GblTestSuite *pSelf, const char *pCaseName)
 
GblBool GblTestSuite_casePassed (const GblTestSuite *pSelf, const char *pCaseName)
 
size_t GblTestSuite_caseCount (const GblTestSuite *pSelf)
 
const char * GblTestSuite_caseName (const GblTestSuite *pSelf, size_t index)
 
size_t GblTestSuite_caseIndex (const GblTestSuite *pSelf, const char *pCaseName)
 
GBL_RESULT GblTestSuite_caseResult (const GblTestSuite *pSelf, size_t index)
 
Test Execution

Methods for executing the test suite.

GBL_RESULT GblTestSuite_initSuite (GblTestSuite *pSelf, GblContext *pCtx)
 
GBL_RESULT GblTestSuite_finalSuite (GblTestSuite *pSelf, GblContext *pCtx)
 
GBL_RESULT GblTestSuite_initCase (GblTestSuite *pSelf, GblContext *pCtx)
 
GBL_RESULT GblTestSuite_finalCase (GblTestSuite *pSelf, GblContext *pCtx)
 
GBL_RESULT GblTestSuite_runCase (GblTestSuite *pSelf, GblContext *pCtx, size_t index)
 
GBL_RESULT GblTestSuite_skipCase (GblTestSuite *pSelf, GblContext *pCtx, size_t index)
 

Detailed Description

GblTestSuite structure and related functions.

Author
2023, 2024 Falco Girgis

Definition in file gimbal_test_suite.h.

Macro Definition Documentation

◆ GBL_TEST_SUITE_TYPE

#define GBL_TEST_SUITE_TYPE

GblType UUID.

Definition at line 19 of file gimbal_test_suite.h.

◆ GBL_TEST_SUITE

#define GBL_TEST_SUITE (   self)

GblInstance cast operator.

Definition at line 20 of file gimbal_test_suite.h.

◆ GBL_TEST_SUITE_CLASS

#define GBL_TEST_SUITE_CLASS (   klass)

GblClass cast operator.

Definition at line 21 of file gimbal_test_suite.h.

◆ GBL_TEST_SUITE_GET_CLASS

#define GBL_TEST_SUITE_GET_CLASS (   self)

GblInstance to GblClass operator.

Definition at line 22 of file gimbal_test_suite.h.

◆ GBL_TEST_CASE_LAST

#define GBL_TEST_CASE_LAST

Convenience macro for NULL-terminating the test case list.

Definition at line 26 of file gimbal_test_suite.h.

Typedef Documentation

◆ GblTestCaseFn

typedef GBL_RESULT(* GblTestCaseFn) (GblTestSuite *pSelf, GblContext *pCtx)

Function signature for a single test case.

Parameters
pSelfThe owning GblTestSuite object pointer.
pCtxThe GblContext object for the test suite.
Returns
The result of the unit test case.

Definition at line 43 of file gimbal_test_suite.h.

Function Documentation

◆ GblTestSuite_type()

GblType GblTestSuite_type ( void  )

Returns the GblType UUID associated with GblTestSuite.

◆ GblTestSuite_register()

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.

◆ GblTestSuite_create()

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).

◆ GblTestSuite_ref()

GblTestSuite * GblTestSuite_ref ( GblTestSuite pSelf)

Returns a new reference to the GblTestSuite, incrementing its reference count by 1.

◆ GblTestSuite_unref()

GblRefCount GblTestSuite_unref ( GblTestSuite pSelf)

Decrements the refcount of the given GblTestSuite by 1, destroying it if it reaches 0.

◆ GblTestSuite_name()

const char * GblTestSuite_name ( const GblTestSuite pSelf)

Returns the string name of the test suite.

◆ GblTestSuite_ran()

GblBool GblTestSuite_ran ( const GblTestSuite pSelf)

Returns GBL_TRUE if the test suite has been run and GBL_FALSE otherwise.

◆ GblTestSuite_passed()

GblBool GblTestSuite_passed ( const GblTestSuite pSelf)

Returns GBL_TRUE if the test suite passed and GBL_FALSE otherwise.

◆ GblTestSuite_scenario()

GblTestScenario * GblTestSuite_scenario ( const GblTestSuite pSelf)

Returns the parent test scenario object or NULL if there isn't one.

◆ GblTestSuite_result()

GBL_RESULT GblTestSuite_result ( const GblTestSuite pSelf)

Returns the top-level aggregate result for the overall test suite.

◆ GblTestSuite_addCase()

GBL_RESULT GblTestSuite_addCase ( GblTestSuite pSelf,
const char *  pName,
GblTestCaseFn  pFnTest 
)

Enqueues a single test case into the given test suite.

◆ GblTestSuite_addCases()

GBL_RESULT GblTestSuite_addCases ( GblTestSuite pSelf,
const GblTestCase pCases 
)

Enqueues an array of cases, terminated by a final entry of all NULL values.

◆ GblTestSuite_caseRan()

GblBool GblTestSuite_caseRan ( const GblTestSuite pSelf,
const char *  pCaseName 
)

Returns whether the test case with the given name has run.

◆ GblTestSuite_casePassed()

GblBool GblTestSuite_casePassed ( const GblTestSuite pSelf,
const char *  pCaseName 
)

Returns whether the test case with the given name has passed.

◆ GblTestSuite_caseCount()

size_t GblTestSuite_caseCount ( const GblTestSuite pSelf)

Returns the number of test cases within the given test suite.

◆ GblTestSuite_caseName()

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.

◆ GblTestSuite_caseIndex()

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.

◆ GblTestSuite_caseResult()

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.

◆ GblTestSuite_initSuite()

GBL_RESULT GblTestSuite_initSuite ( GblTestSuite pSelf,
GblContext pCtx 
)

Calls the top-level initialization function for the entire suite.

◆ GblTestSuite_finalSuite()

GBL_RESULT GblTestSuite_finalSuite ( GblTestSuite pSelf,
GblContext pCtx 
)

Calls the top-level finalization function for the entire suite.

◆ GblTestSuite_initCase()

GBL_RESULT GblTestSuite_initCase ( GblTestSuite pSelf,
GblContext pCtx 
)

Calls the case-level initialization function for the next test case.

◆ GblTestSuite_finalCase()

GBL_RESULT GblTestSuite_finalCase ( GblTestSuite pSelf,
GblContext pCtx 
)

Calls the case-level finalization function for the previous test case.

◆ GblTestSuite_runCase()

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.

◆ GblTestSuite_skipCase()

GBL_RESULT GblTestSuite_skipCase ( GblTestSuite pSelf,
GblContext pCtx,
size_t  index 
)

Skips the test case at index within the given suite.