Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
criterion.h File Reference

Include this to use criterion. More...

#include "types.h"
#include "assert.h"
#include "alloc.h"
#include "internal/test.h"

Go to the source code of this file.

Macros

#define Test(Suite, Name, ...)   internal
 
#define TestSuite(Name, ...)   internal
 

Functions

CR_BEGIN_C_API CR_API struct criterion_test_setcriterion_initialize (void)
 
CR_API void criterion_finalize (struct criterion_test_set *tests)
 
CR_API int criterion_run_all_tests (struct criterion_test_set *tests)
 
CR_API int criterion_handle_args (int argc, char *argv[], bool handle_unknown_arg)
 
CR_API void criterion_register_test (struct criterion_test_set *tests, struct criterion_test *test)
 

Variables

CR_API const struct criterion_test *const criterion_current_test
 
CR_API const struct criterion_suite *const criterion_current_suite
 

Detailed Description

Include this to use criterion.

Definition in file criterion.h.

Macro Definition Documentation

◆ Test

#define Test ( Suite,
Name,
... )   internal

Defines a new test.

Parameters
SuiteThe name of the test suite containing this test.
NameThe name of the test.
...An optional sequence of designated initializer key/value pairs as described in the criterion_test_extra_data structure (see criterion/types.h).
Example: .exit_code = 1

Definition at line 45 of file criterion.h.

◆ TestSuite

#define TestSuite ( Name,
... )   internal

Explicitely defines a test suite and its options.

Parameters
NameThe name of the test suite.
...An optional sequence of designated initializer key/value pairs as described in the criterion_test_extra_data structure (see criterion/types.h). These options will provide the defaults for each test.

Definition at line 56 of file criterion.h.

Function Documentation

◆ criterion_finalize()

CR_API void criterion_finalize ( struct criterion_test_set * tests)

Release all resources allocated by criterion.

Using any of the functions and macros provided by criterion except criterion_initialize after this function is called results in undefined behaviour.

◆ criterion_handle_args()

CR_API int criterion_handle_args ( int argc,
char * argv[],
bool handle_unknown_arg )

Handles all default command-line parameters, as documented in: http://criterion.readthedocs.org/en/latest/env.html, and appropriately sets criterion_options.

Parameters
[in]argcThe number of arguments in argv.
[in]argvA null-terminated array of strings representing the arguments.
[in]handle_unknown_argWhether the function should print a message and exit when an unknown parameter is encountered. Use false if you want to handle additional parameters yourself.
Returns
0 if the process should exit immediately after, for instance after printing the help message.

◆ criterion_initialize()

CR_BEGIN_C_API CR_API struct criterion_test_set * criterion_initialize ( void )

Initializes criterion and builds a set of all discovered tests.

Using any of the functions and macros provided by criterion before calling this results in undefined behaviour.

Returns
the set of tests

◆ criterion_register_test()

CR_API void criterion_register_test ( struct criterion_test_set * tests,
struct criterion_test * test )

Manually registers a new test within the specified test set.

Parameters
[in]testsThe set of tests you want to insert the test in.
[in]testThe newly created test.

◆ criterion_run_all_tests()

CR_API int criterion_run_all_tests ( struct criterion_test_set * tests)

Run all the tests in the test set.

Parameters
[in]testsThe set of tests that are to be executed.
Returns
1 if all tests succeeded or criterion_options.always_succeed is true, 0 otherwise.

Variable Documentation

◆ criterion_current_suite

CR_API const struct criterion_suite* const criterion_current_suite
extern

◆ criterion_current_test

CR_API const struct criterion_test* const criterion_current_test
extern