-
Notifications
You must be signed in to change notification settings - Fork 11
/
.travistest.c
54 lines (40 loc) · 1.05 KB
/
.travistest.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
/* The biggest hack we use is a GCC macro.
* This optional define should be enough to make this work on most compilers.
*/
#ifndef __BASE_FILE__
#define __BASE_FILE__ __FILE__
#endif
#include "cheat.h"
#include "cheat_helpers.h"
GLOBALS(
char *tmp_string;
)
SET_UP({
tmp_string = calloc(1, 50);
})
TEAR_DOWN({
free(tmp_string);
})
TEST(maths_still_work, {
cheat_assert(4 == 2+2);
})
TEST(strcat_makes_sense, {
strcpy(tmp_string, "Hello, ");
strcat(tmp_string, "World!");
cheat_assert(0 == strcmp(tmp_string, "Hello, World!"));
})
TEST_IGNORE(ignored, {
some_invalid.test->code();
})
TEST_WITH_CAPTURED_STDOUT(output_capture, {
printf("Something stupid");
cheat_assert(cheat_stream_contains(stdout, "Something"));
})
TEST_WITH_CAPTURED_STDOUT(large_output_capture, {
printf("%1000s", "Potato");
cheat_assert(cheat_stream_contains(stdout, "Potato"));
})
TEST_WITH_CAPTURED_STDERR(stderr_capture, {
fprintf(stderr, "You can also capture errors!");
cheat_assert(cheat_stream_contains(stderr, "errors"));
})