mt_fok(3)
bofc manual pages
mt_fok(3)
NAME
mt_fok, mt_ferr - shortcut macro to test if function executed as expected.
SYNOPSIS
#include <mtest.h>
mt_fok(function_call)
mt_ferr(function_call, errno_value)
DESCRIPTION
Macros are a simple shortcuts to perform test on functions that return either -1 or 0. By convention 0 means success and -1 means error and error reason is stored in errno variable. If function returns different values than 0 or -1, ordinary mt_fail(3) should be used instead.
mt_fok(3) simply expects that function returns 0.
mt_ferr(3) expects function to return -1, and sets errno value to errno_value.
Both functions uses mt_fail(3) under the hood.
EXAMPLE
#include <mtest.h>
#include <errno.h>
mt_defs();
static int f1(void)
{
return 0;
}
static int f2(void)
{
errno = ENOSYS;
return -1;
}
static void t1(void)
{
mt_fok(f1());
mt_ferr(f2(), ENOSYS);
}
int main(void)
{
mt_run(t1);
mt_return();
}
SEE ALSO
mt_defs(3), mt_defs_ext(3), mt_run(3), mt_run_named(3), mt_assert(3), mt_fail(3), mt_return(3) mtest_overview(7),
3 September 2018 (1.1.3)
mt_fok(3)