-
Notifications
You must be signed in to change notification settings - Fork 1
/
example.c
45 lines (35 loc) · 900 Bytes
/
example.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
/*
example.c - Chul-Woong Yang ([email protected])
example code to demonstrate c2unit
*/
#include <stdio.h>
#include <unistd.h>
#define C2UNIT_TEST_PATH "sample"
#include "c2unit.h"
FUNC_BEGIN(foo, NORMAL)
int foo (int bar)
{
return bar;
}
FUNC_END(foo)
FUNC_BEGIN(baz, NORMAL)
int baz (int bar)
{
return bar + 1;
}
FUNC_END(baz)
main(int argc, char *argv[])
{
extern void foo_test(void);
int c;
// if -t then do unit tests
while ((c = getopt(argc, argv, "t")) != -1)
switch (c) {
case 't': test_run(argc, argv);
exit(0);
}
// otherwise do normal tasks
printf("C2UNIT test program\n by Chul-Woong Yang ([email protected])\n\n");
printf("run as '%s -t' or '%s -tv' to see demo\n", argv[0], argv[0]);
}
#include "example_test.c"