|
PicoTest
A minimalist unit testing framework for C programs
|
Assertion Hooks | |
PicoTest provides a way for client code to intercept assertions events. This can be used for e.g. logging purpose or reporting. | |
| typedef void | PicoTestAssertBeforeProc(const char *type, const char *test) |
| Function signature of assert before hooks. | |
| typedef void | PicoTestAssertAfterProc(const char *type, const char *test, int fail) |
| Function signature of assert after hooks. | |
| #define | PICOTEST_ASSERT_BEFORE_DEFAULT(type, test) |
| Default assert before hook. | |
| #define | PICOTEST_ASSERT_BEFORE |
| Define the assert before hook. | |
| #define | PICOTEST_ASSERT_AFTER_DEFAULT(type, test, fail) |
| Default assert after hook. | |
| #define | PICOTEST_ASSERT_AFTER |
| Define the assert after hook. | |
Assertion Definitions | |
| #define | PICOTEST_ASSERT(x, ...) |
| Hard assertion. | |
| #define | PICOTEST_VERIFY(x, ...) |
| Soft assertion. | |
| #define | PICOTEST_FAILURE(type, test, ...) |
| Generic failure. | |
| #define | PICOTEST_ABORT() |
| Abort a test case. | |
Assertions are the basic building blocks of test cases.
| #define PICOTEST_ASSERT | ( | x, | |
| ... ) |
Hard assertion.
Logs an error if the given value is false, then stops the test with PICOTEST_ABORT().
PICOTEST_FAILURE_LOGGER() is called with the type argument set to "ASSERT".
| x | Value to test. Evaluated once, so it can be an expression with side effects. |
| msg | (optional) Message format string. |
| ... | (optional) Message string arguments. |
| #define PICOTEST_VERIFY | ( | x, | |
| ... ) |
Soft assertion.
Logs an error if the given value is false, but let the test continue.
PICOTEST_FAILURE_LOGGER() is called with the type argument set to "VERIFY".
| x | Value to test. Evaluated once, so it can be an expression with side effects. |
| msg | (optional) Message format string. |
| ... | (optional) Message string arguments. |
| #define PICOTEST_FAILURE | ( | type, | |
| test, | |||
| ... ) |
Generic failure.
PICOTEST_FAILURE_LOGGER() is called with the provided type, test and msg arguments.
This can be used to implement custom testing logic.
| type | Type of test that failed (e.g. "ASSERT"). |
| test | Failed test. |
| msg | (optional) Message format string. |
| ... | (optional) Message string arguments. |
| #define PICOTEST_ABORT | ( | ) |
| #define PICOTEST_ASSERT_BEFORE_DEFAULT | ( | type, | |
| test ) |
| #define PICOTEST_ASSERT_BEFORE |
Define the assert before hook.
The default hook does nothing. Redefine this macro to use a custom hook, which must follow the PicoTestAssertBeforeProc signature.
| #define PICOTEST_ASSERT_AFTER_DEFAULT | ( | type, | |
| test, | |||
| fail ) |
| #define PICOTEST_ASSERT_AFTER |
Define the assert after hook.
The default hook does nothing. Redefine this macro to use a custom hook, which must follow the PicoTestAssertAfterProc signature.
| typedef void PicoTestAssertBeforeProc(const char *type, const char *test) |
Function signature of assert before hooks.
Called before running an assertion.
| type | Type of test (e.g. "ASSERT"). |
| test | Test. |
| typedef void PicoTestAssertAfterProc(const char *type, const char *test, int fail) |
Function signature of assert after hooks.
Called after running an assertion.
| type | Type of test (e.g. "ASSERT"). |
| test | Test. |
| fail | Test result: zero for success, non-zero for failure. |