OlinCoin
Test
minunit.h
1/* minunit.h
2
3From: http://www.jera.com/techinfo/jtns/jtn002.html
4
5License: "You may use the code in this tech note for any purpose,
6with the understanding that it comes with NO WARRANTY."
7
8Note on why the macros are wrapped in a do..while statement:
9http://www.eskimo.com/~scs/C-faq/q10.4.html
10
11*/
12
13/* mu_assert: If test is false, returns message.
14
15Note that because this is a macro, it returns from whatever
16function it is used in.
17*/
18 #define mu_assert(message, test) do { if (!(test)) return message; } while (0)
19
20
21/* mu_run_test: Runs the given test function.
22
23If the function returns a non-null message, mu_run_test returns
24the same message.
25
26*/
27 #define mu_run_test(test) do { char *message = test(); tests_run++; \
28 if (message) return message; } while (0)
29
30/* Note from Allen: I'm not sure why this is here.
31 `tests_run` is only used in the testing module, and I
32 don't see a reason it should be accessible from the
33 unit under test.
34
35extern int tests_run;
36
37*/