chibicc/test/float.c

65 lines
1.6 KiB
C
Raw Normal View History

#include "test.h"
int main() {
ASSERT(35, (float)(char)35);
ASSERT(35, (float)(short)35);
ASSERT(35, (float)(int)35);
ASSERT(35, (float)(long)35);
ASSERT(35, (float)(unsigned char)35);
ASSERT(35, (float)(unsigned short)35);
ASSERT(35, (float)(unsigned int)35);
ASSERT(35, (float)(unsigned long)35);
ASSERT(35, (double)(char)35);
ASSERT(35, (double)(short)35);
ASSERT(35, (double)(int)35);
ASSERT(35, (double)(long)35);
ASSERT(35, (double)(unsigned char)35);
ASSERT(35, (double)(unsigned short)35);
ASSERT(35, (double)(unsigned int)35);
ASSERT(35, (double)(unsigned long)35);
ASSERT(35, (char)(float)35);
ASSERT(35, (short)(float)35);
ASSERT(35, (int)(float)35);
ASSERT(35, (long)(float)35);
ASSERT(35, (unsigned char)(float)35);
ASSERT(35, (unsigned short)(float)35);
ASSERT(35, (unsigned int)(float)35);
ASSERT(35, (unsigned long)(float)35);
ASSERT(35, (char)(double)35);
ASSERT(35, (short)(double)35);
ASSERT(35, (int)(double)35);
ASSERT(35, (long)(double)35);
ASSERT(35, (unsigned char)(double)35);
ASSERT(35, (unsigned short)(double)35);
ASSERT(35, (unsigned int)(double)35);
ASSERT(35, (unsigned long)(double)35);
ASSERT(-2147483648, (double)(unsigned long)(long)-1);
2020-09-22 12:28:37 +03:00
ASSERT(1, 2e3==2e3);
ASSERT(0, 2e3==2e5);
ASSERT(1, 2.0==2);
ASSERT(0, 5.1<5);
ASSERT(0, 5.0<5);
ASSERT(1, 4.9<5);
ASSERT(0, 5.1<=5);
ASSERT(1, 5.0<=5);
ASSERT(1, 4.9<=5);
ASSERT(1, 2e3f==2e3);
ASSERT(0, 2e3f==2e5);
ASSERT(1, 2.0f==2);
ASSERT(0, 5.1f<5);
ASSERT(0, 5.0f<5);
ASSERT(1, 4.9f<5);
ASSERT(0, 5.1f<=5);
ASSERT(1, 5.0f<=5);
ASSERT(1, 4.9f<=5);
printf("OK\n");
return 0;
}