Mbed OS Reference
Loading...
Searching...
No Matches
run_tests.h File Reference

Go to the source code of this file.

Typedefs

typedef void(* OutputStringCB) (const char *szString, void *pOutCtx, int bNewline)
 Type for function to output a text string. More...
 

Functions

int RunTests (const char *szTestNames[], OutputStringCB pfOutput, void *pOutCtx, int *pNumTestsRun)
 Runs the QCBOR tests. More...
 
void PrintSizes (OutputStringCB pfOutput, void *pOutCtx)
 Print sizes of encoder / decoder contexts. More...
 

Typedef Documentation

◆ OutputStringCB

typedef void(* OutputStringCB) (const char *szString, void *pOutCtx, int bNewline)

Type for function to output a text string.

Parameters
[in]szStringThe string to output
[in]pOutCtxA context pointer; NULL if not needed
[in]bNewlineIf non-zero, output a newline after the string

This is a prototype of a function to be passed to RunTests() to output text strings.

This can be implemented with stdio (if available) using a straight call to fputs() where the FILE * is passed as the pOutCtx as shown in the example code below. This code is for Linux where the newline is a \n. Windows usually prefers \r\n.

static void fputs_wrapper(const char *szString, void *pOutCtx, int bNewLine)
{
fputs(szString, (FILE *)pOutCtx);
if(bNewLine) {
fputs("\n", pOutCtx);
}
}

Definition at line 42 of file run_tests.h.

Function Documentation

◆ RunTests()

int RunTests ( const char *  szTestNames[],
OutputStringCB  pfOutput,
void *  pOutCtx,
int *  pNumTestsRun 
)

Runs the QCBOR tests.

Parameters
[in]szTestNamesAn argv-style list of test names to run. If empty, all are run.
[in]pfOutputFunction that is called to output text strings.
[in]pOutCtxContext pointer passed to output function.
[out]pNumTestsRunReturns the number of tests run. May be NULL.
Returns
The number of tests that failed. Zero means overall success.

◆ PrintSizes()

void PrintSizes ( OutputStringCB  pfOutput,
void *  pOutCtx 
)

Print sizes of encoder / decoder contexts.

Parameters
[in]pfOutputFunction that is called to output text strings.
[in]pOutCtxContext pointer passed to output function.