NAME
KS_expect_true,
KS_expect_false,
KS_expect_int,
KS_expect_str,
KS_expect_str_n,
KS_expect_ptr,
KS_expect_scope —
unit test macros
SYNOPSIS
#include
<libks/expect.h>
KS_expect_true(expression);
KS_expect_false(expression);
KS_expect_int(expect,
actual);
KS_expect_str(const
char *expect, const char
*actual);
KS_expect_str_n(const char
*expect, const char *actual,
size_t actual_len);
KS_expect_ptr(void
*expect, void
*actual);
KS_expect_scope(const
char *func, int
lno, varname);
DESCRIPTION
The expect macros are intended to be used to construct unit tests. All macros causes the current process to exit non-zero if any unexpected outcome is encountered.
The
KS_expect_true()
macro expects expression to be non-zero.
The
KS_expect_false()
macro expects expression to be zero.
The
KS_expect_int()
macro expects the two integers expect and
actual to be equal. Note that
expect and actual are not
required to be of the same type.
The
KS_expect_str()
macro expects expect and actual
to be identical as determined using
strcmp(3).
The
KS_expect_str_n()
macro behaves like KS_expect_str() but allows the
length of actual to be specified using
actual_len. Intended to be used with strings lacking
NUL-terminators.
The
KS_expect_ptr()
expects the two pointers expect and
actual to be equal.
The
KS_expect_scope()
allows the function and line
used in expect error messages to be overridden, effectively taking higher
precedence than the defaults __func__ and
__LINE__. The override remains active until
varname goes out of lexical scope.
AUTHORS
Anton Lindqvist <anton@basename.se>