aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/test_string_operations.sh
blob: 0c9a07ea3c6e360bfdf2f5674708c2135025b722 (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
touch expected
test_diff <<'EOF'
int main() {
    "";
    return 0;
}
EOF

touch expected
test_diff <<'EOF'
int main() {
    "abc";
    return 0;
}
EOF

touch expected
test_diff <<'EOF'
int main() {
    "\"foo\"bar\\\n\"";
    return 0;
}
EOF

cat <<'EOF' > expected
h
l
,
EOF

test_diff <<'EOF'
int printf();

int main() {
    char* h = " hello,world" + 1;
    printf("%c\n", *h);
    printf("%c\n", h[2]);
    printf("%c\n", *(h + 5));
}
EOF

cat <<'EOF' > expected
105
0
EOF

test_diff <<'EOF'
int printf();

int main() {
    char* s = "hi";
    while (*s++) {
        printf("%d\n", *s);
    }
}
EOF