]> git.sur5r.net Git - cc65/blob - test/ref/cvt.c
fixed up the rest of the tests, added rudimentary makefile(s)
[cc65] / test / ref / cvt.c
1 /*
2   !!DESCRIPTION!! type conversion
3   !!ORIGIN!!      LCC 4.1 Testsuite
4   !!LICENCE!!     own, freely distributeable for non-profit. read CPYRIGHT.LCC
5 */
6
7 #include "common.h"
8 #include <stdio.h>
9
10 signed char c;
11 signed short s;
12 signed int i;
13 signed long int l;
14 unsigned char C;
15 unsigned short S;
16 unsigned int I;
17 unsigned long int L;
18
19 #ifdef NO_FLOATS
20 signed long f;
21 signed long d;
22 signed long D;
23 #else
24 float f;
25 double d;
26 long double D;
27 #endif
28
29 void *p;
30 void (*P)(void);
31
32 void print(void) {
33         #ifdef NO_FLOATS
34         printf("%d %d %d %ld %u %u %u %lu %ld.000000 %ld.000000 %ld.000000\n",c,s,i,l,C,S,I,L,f,d,D);
35         #else
36         printf("%d %d %d %ld %u %u %u %lu %f %f %lf \n",c,s,i,l,C,S,I,L,f,d,D );
37         #endif
38 }
39
40 main() {
41         c= 1;     s=c;i=c;l=c;C=c;S=c;I=c;L=c; f=c;d=c;D=c;  print();
42         s= 2; c=s;    i=s;l=s;C=s;S=s;I=s;L=s; f=s;d=s;D=s;  print();
43         i= 3; c=i;s=i;    l=i;C=i;S=i;I=i;L=i; f=i;d=i;D=i;  print();
44         l= 4; c=l;s=l;i=l;    C=l;S=l;I=l;L=l; f=l;d=l;D=l;  print();
45         C= 5; c=C;s=C;i=C;l=C;    S=C;I=C;L=C; f=C;d=C;D=C;  print();
46         S= 6; c=S;s=S;i=S;l=S;C=S;    I=S;L=S; f=S;d=S;D=S;  print();
47         I= 7; c=I;s=I;i=I;l=I;C=I;S=I;    L=I; f=I;d=I;D=I;  print();
48         L= 8; c=L;s=L;i=L;l=L;C=L;S=L;I=S;     f=L;d=L;D=L;  print();
49         f= 9; c=f;s=f;i=f;l=f;C=f;S=f;I=f;L=f;     d=f;D=f;  print();
50         d=10; c=d;s=d;i=d;l=d;C=d;S=d;I=d;L=d;f=d;     D=d;  print();
51         D=11; c=D;s=D;i=D;l=D;C=D;S=D;I=D;L=D;f=D;d=D;     print();
52
53         p=0; p=0L; p=0U; p=0UL; p=P;
54         P=0; P=0L; P=0U; P=0UL; P=p;
55         return 0;
56 }