mt_defs_ext(3)
bofc manual pages
mt_defs_ext(3)
NAME
mt_defs, mt_defs_ext - defines variables for test framework
SYNOPSIS
#include <mtest.h>
DESCRIPTION
mt_defs(3) defines all variables needed by the test framework. This must be called exactly once in a global scope, before calling any of the mtest function. Calling this macro in two places will lead to 'double definition' linker error. As a rule of thumb, it is good to call this macro in test-main.c file after #include.
If all tests are in a single file (like test-main.c) calling mt_defs(3) is sufficient, but if tests are splitted into more .c files, you should also call mt_defs_ext(3) in all .c files that uses mtest functions. As with mt_defs(3), it should be called before any call to mtest function.
Note, don't call mt_defs_ext(3) if mt_defs (3) has already been called in a single file.
EXAMPLE
/* test-main.c */
#include <mtest.h>
#include "t1.h"
#include "t2.h"
#include "library-under-test.h"
mt_defs();
static void test_zero(void)
{
mt_assert(foo() == 0);
}
int main(void)
{
mt_run(test_zero);
mt_run(test_one);
test_group();
mt_return();
}
/* t1.c */
#include <mtest.h>
#include "t1.h"
#include "library-under-test.h"
mt_defs_ext();
void test_one(void)
{
mt_assert(bar() == 0);
}
/* t2.c */
#include <mtest.h>
#include "t2.h"
#include "library-under-test.h"
mt_defs_ext();
static void test_two(void)
{
mt_assert(baz() == 0);
}
static void test_three(void)
{
mt_assert(qux() == 0);
}
void test_group(void)
{
mt_run(test_two);
mt_run(test_three);
}
SEE ALSO
mt_run(3), mt_run_named(3), mt_assert(3), mt_fail(3), mt_fok(3), mt_ferr(3), mt_return(3) mtest_overview(7)
3 September 2018 (1.1.3)
mt_defs_ext(3)