aboutsummaryrefslogtreecommitdiffstats
path: root/man/mt_assert.3
blob: dd3a3580df400eaa29ef6357abe80a88b38dc019 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
.TH "MT_ASSERT" "3" " 2 December 2019 (v9999)" "bofc.pl"
.SH NAME
.PP
.BR mt_assert ,
.B mt_fail
- test checks macros
.SH SYNOPSIS
.PP
c/c++
.PP
.B #include <mtest.h>
.PP
.BI "mt_assert(" expression ")"
.br
.BI "mt_fail(" expression ")"
.PP
shell
.PP
.BI "mt_fail <" expression ">"
.br
.BI "mt_dfail <" command "> [" argumnet "] ..."
.SH DESCRIPTION
.PP
Macro
.BR mt_assert (3)
evaluates
.I expression
and if it evaluates to false, test will be marked as failed and information
about assert will be printed.
Information contains
.BR function_name ,
line where assert occured, and
.I expression
that caused test to fail.
Also macro forces function it was called in to immediately return.
.PP
.BR mt_fail (3)
works just as
.BR mt_assert (3)
but function is not forced to exit and can continue execution.
This is good when test allocates some memory and we need to clean up before
returning.
.PP
For shell scripting,
.BR mt_fail (3)
passed
.I expression
to eval.
.I expression
must be single argument, so it should be closed in "" to preserve spaces.
If
.I expression
is easy and does not required
.B eval
to process, one can use
.BR mt_dfail (3)
which passes all arguments directly to if statement
.B """if ! ${@}"""
.SH EXAMPLE
.PP
Proper example can be found in
.BR mtest_overview (7).
.SH "SEE ALSO"
.PP
.BR mt_defs (3),
.BR mt_defs_ext (3),
.BR mt_run (3),
.BR mt_run_named (3),
.BR mt_run_param (3),
.BR mt_run_param_named (3),
.BR mt_fok (3),
.BR mt_ferr (3),
.BR mt_return (3),
.BR mtest_overview (7)