Example of PicoTest error logging, prints location and info of failed assertions to stdout.
#include <stdio.h>
#undef PICOTEST_FAILURE_LOGGER
#define PICOTEST_FAILURE_LOGGER logFailure
void logFailure(const char *file, int line, const char *type, const char *test, const char *msg, va_list args) {
printf("[%s] ", type);
printf("%s(%d) : ", file, line);
printf("%s", test);
if (msg) {
printf(" | ");
vprintf(msg, args);
}
printf("\n");
}
#undef PICOTEST_CASE_ENTER
#undef PICOTEST_CASE_LEAVE
#define PICOTEST_CASE_ENTER logEnter
#define PICOTEST_CASE_LEAVE logLeave
int level = 0;
void indent(int level) {
while (level--) printf(" ");
}
void logEnter(const char *name) {
indent(level++);
printf("begin %s\n", name);
}
void logLeave(const char *name, int fail) {
level--;
if (!fail) {
indent(level);
printf("end %s\n", name);
}
}
void main() {
mainSuite(NULL);
}
void PicoTestFailureLoggerProc(const char *file, int line, const char *type, const char *test, const char *msg, va_list args)
Function signature of test failure log handlers.
Definition picotest.h:438
void PicoTestCaseEnterProc(const char *testName)
Function signature of test case enter hooks.
Definition picotest.h:633
void PicoTestCaseLeaveProc(const char *testName, int fail)
Function signature of test case leave hooks.
Definition picotest.h:681
Example of a simple PicoTest suite.
This file defines a minimalist unit testing framework for C programs.