]> git.sur5r.net Git - cc65/blob - test/val/casttochar.c
goto.c warning fix for implicit truncation
[cc65] / test / val / casttochar.c
1
2 /*
3   !!DESCRIPTION!! Cast to char
4   !!ORIGIN!!      Piotr Fusik
5   !!LICENCE!!     PD
6 */
7
8 #include <stdio.h>
9 #include <stdlib.h>
10
11 static unsigned int failures = 0;
12
13 int f1(int i, int j) {
14     return (signed char) (i + 1) == j;
15 }
16
17 int f2(int i, int j) {
18     return (unsigned char) (i + 1) == j;
19 }
20
21 int f3(int i, int j) {
22     return (char) (i + 1) == j;
23 }
24
25 int main(void)
26 {
27     printf("f1: got :%04x ", f1(0x1234, 0x35));
28     if(f1(0x1234, 0x35) == 0) {
29         printf("- failed");
30         failures++;
31     }
32     printf("\n");
33
34     printf("f2: got :%04x ", f2(0x1234, 0x35));
35     if(f2(0x1234, 0x35) == 0) {
36         printf("- failed");
37         failures++;
38     }
39     printf("\n");
40
41     printf("f3: got :%04x ", f3(0x1234, 0x35));
42     if(f3(0x1234, 0x35) == 0) {
43         printf("- failed");
44         failures++;
45     }
46     printf("\n");
47
48     return failures;
49 }