aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/include_errors.sh
blob: e0f856e24643c74568a3db27b1433e1e0f8a09df (plain)
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
cat <<'EOF' > expected
main.c:1: cannot open include file: "nonexistent.h"
EOF

test_compile_error <<'EOF'
#include "nonexistent.h"

int main() {
    return 0;
}
EOF

cat <<'EOF' > expected
include depth limit exceeded
EOF

# Create circular include files
cat <<'EOF' > a.h
#include "b.h"
int a() { return 1; }
EOF

cat <<'EOF' > b.h
#include "a.h"
int b() { return 2; }
EOF

test_compile_error <<'EOF'
#include "a.h"

int main() {
    a() + b();
    return 0;
}
EOF

cat <<'EOF' > expected
main.c:1: cannot open include file: "hoge.h"
EOF

test_compile_error <<'EOF'
#include "hoge.h"
EOF

cat <<'EOF' > expected
main.c:1: cannot resolve include file name: <hoge.h>
EOF

test_compile_error <<'EOF'
#include <hoge.h>
EOF

cat <<'EOF' > expected
42
EOF

test_exit_code 0 <<'EOF'
#ifdef FOO
#include FOO
#endif

int main() { 1 < 2; }
EOF