Lumiera  0.pre.03
»edit your freedom«
test.h File Reference

Go to the source code of this file.

Description

Helpers and support macros for defining test executables in C.

These macros provide some building blocks to assemble a main() function, which checks a test name parameter and invokes the matching embedded code block.

See also
test-mpool.c C test example
HelloWorld_test C++ test example

Definition in file test.h.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <nobug.h>

Macros

#define PLANNED_TEST(name)
 
#define TEST(name)
 
#define TESTS_BEGIN
 
#define TESTS_END
 

Macro Definition Documentation

◆ TESTS_BEGIN

#define TESTS_BEGIN
Value:
main (int argc, const char** argv) \
{ \
NOBUG_INIT; \
unsigned testcnt=0; \
int ret = 0; \
\
if (argc == 1) \
fprintf (stderr, "supported tests:\n");
int main(int argc, const char *argv[])
run all tests or any single test specified in the first command line argument.
Definition: testrunner.cpp:47

Definition at line 43 of file test.h.

◆ TEST

#define TEST (   name)
Value:
if (argc == 1) \
fprintf (stderr, " "#name"\n"); \
else if (!strcmp(argv[1], #name) && ++testcnt)
ElementBoxWidget::Config::Qualifier name(string id)
define the name-ID displayed in the caption

Definition at line 54 of file test.h.

◆ PLANNED_TEST

#define PLANNED_TEST (   name)
Value:
if (argc == 1) \
fprintf (stderr, " "#name" (planned)\n"); \
else if (!++testcnt)
ElementBoxWidget::Config::Qualifier name(string id)
define the name-ID displayed in the caption

Definition at line 59 of file test.h.

◆ TESTS_END

#define TESTS_END
Value:
if (!testcnt && argc !=1) \
fprintf (stderr,"no such test: %s\n", argv[1]); \
return ret; \
}

Definition at line 64 of file test.h.