-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
51 lines (43 loc) · 1.1 KB
/
main.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
/* main.c
* Scott Bronson
* 28 Feb 2007
*
* Specifies a main routine so that ctest can be compiled standalone.
* Requires all_tests(), a routine that runs all tests for the
* current project, to be defined in another file.
*
* Copyright (C) 2007 Scott Bronson
* This file is released under the MIT License.
* See http://www.opensource.org/licenses/mit-license.php
*/
#include "ctest.h"
#include "ctassert.h"
#include <string.h>
int main(int argc, char **argv)
{
if(ctest_read_args(argc, argv)) {
printf("ctest_read_args returned true!\n");
}
/* Check for special-purpose tests */
for(;*argv;argv++) {
if(strcmp(*argv,"--fail-assert") == 0) {
/* intentionally fail an assert */
AssertEQ(1,0);
}
if(strcmp(*argv,"--fail-test") == 0) {
/* intentionally fail a test */
ctest_start("FailTest") {
AssertEQ(1,0);
}
ctest_exit();
return 0;
}
}
/* Ensure that we can hit asserts without first calling ctest_start. */
AssertEQ(1,1);
/* Run unit tests for all assert files we know about */
run_ctassert_tests();
ctest_exit();
/* this will never be reached */
return 0;
}