aboutsummaryrefslogtreecommitdiffstats
path: root/example/tests.c
blob: 1f2c68c09aaf58831734b216486899ff217c2ad8 (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
#include "../mtest.h"

#include "add-tests.h"
#include "sub-tests.h"
#include "named-tests.h"
#include "param-tests.h"
#include "quick-tests.h"

#include "calc.h"

/*
 * define global variables needed for whole mtest framework
 */

mt_defs();


static void sub_test(void)
{
    mt_assert(sub(5, 4) == 1);
}


int main(void)
{
    /*
     * we can execute test group from another file
     */

    add_tests();

    /*
     * or we can call tests directly from another file
     */

    mt_run(sub_test_valid);
    mt_run(sub_test_invalid);

    /*
     * we can also run tests from this very file
     */

    mt_run(sub_test);

    /*
     * run named tests
     */

    named_test_in_loop();

    /*
     * run tests with parameters and named parameters
     */

    param_test_in_loop();
    named_param_test_in_loop();

    /*
     * run multiple, one check, quick tests
     */

    quick_tests();

    /*
     * and at the end we call mt_return, which will print clousure information
     * and will exit test program with apropriate return code
     */

    mt_return();
}