/
test.c
68 lines (59 loc) · 1.4 KB
/
test.c
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
#include <stdio.h>
#include "cu.h"
/**
* Test suite from imported from other file.
*/
#include "test2.h"
/**
* Definition of test function
*/
TEST(testFunction)
{
printf("Hello, world!\n");
assertTrue(0);
}
TEST(testFunction2)
{
assertEquals(1, 1);
assertNotEquals(1, 0);
}
TEST(testFunction3)
{
assertEquals(0, 1);
assertNotEquals(1, 0);
}
/**
* Composition of tests into testsuite
*/
TEST_SUITE(testSuiteName)
{
TEST_ADD(testFunction), /* Add test to testsuite */
TEST_ADD(testFunction2),
TEST_ADD(testFunction3),
TEST_SUITE_CLOSURE /* By this must end all lists of tests */
};
/**
* Another testsuite.
*/
TEST_SUITE(testSuiteName2)
{
TEST_ADD(testFunction2),
TEST_SUITE_CLOSURE
};
TEST_SUITES{
TEST_SUITE_ADD(testSuiteName),
TEST_SUITE_ADD(testSuiteName2),
TEST_SUITE_ADD(testSuiteTest2),
TEST_SUITES_CLOSURE
};
int main(int argc, char *argv[])
{
CU_SET_OUT_PREFIX("regressions/"); /* define prefix for files written
by testsuites */
CU_RUN(argc, argv); /* Run testsuites defined by TEST_SUITES macro
in its own process and stdout is redirected to
regressions/tmp.testSuiteName.out
and stderr to regressions/tmp.testSuiteName.err
according to CU_SET_OUT_PREFIX called before */
return 0;
}