summaryrefslogtreecommitdiffstats
path: root/libacc/tests/data/film.c
blob: 00c2d3604a5cb306e35e7d70b44c128e612d6a81 (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
// Test logical and bitwise AND and OR

int test(int x, int y) {
    int v = x || y;
    return v;
}

int test2(int x, int y) {
    if(x | y) {
        return 1;
    } else {
        return 0;
    }
}

int test3(int x, int y) {
    int v = x && y;
    return v;
}

int test4(int x, int y) {
    if(x & y) {
        return 1;
    } else {
        return 0;
    }
}

int main(int index)
{
    int x,y;
    printf("testing...\n");
    int totalBad = 0;
    for(y = 0; y < 2; y++) {
        for(x = 0; x < 2; x++) {
            int a = test(x,y);
            int b = test2(x,y);
            if (a != b) {
                printf("Results differ: OR x=%d y=%d a=%d b=%d\n", x, y, a, b);
                totalBad++;
            }
            a = test3(x,y);
            b = test4(x,y);
            if (a != b) {
                printf("Results differ: AND x=%d y=%d a=%d b=%d\n", x, y, a, b);
                totalBad++;
            }
        }
    }
    printf("Total bad: %d\n", totalBad);
    return 0;
}