mirror of
https://github.com/cc65/cc65.git
synced 2024-10-16 11:23:57 +00:00
76 lines
1.4 KiB
C
76 lines
1.4 KiB
C
|
|
||
|
// test comparison operations
|
||
|
// WIP WIP WIP
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
#include <stdio.h>
|
||
|
#include <stdint.h>
|
||
|
|
||
|
#include <_float.h>
|
||
|
|
||
|
#ifdef CONIO
|
||
|
#include <conio.h>
|
||
|
#define WAIT() cgetc()
|
||
|
#else
|
||
|
#define WAIT()
|
||
|
#endif
|
||
|
|
||
|
float fp1, fp2, fp3, fp4;
|
||
|
|
||
|
char buf[0x30];
|
||
|
char buf2[0x30];
|
||
|
char buf3[0x30];
|
||
|
|
||
|
signed char var_schar;
|
||
|
unsigned char var_uchar;
|
||
|
signed int var_sint;
|
||
|
unsigned int var_uint;
|
||
|
signed long var_slong;
|
||
|
unsigned long var_ulong;
|
||
|
|
||
|
int result = 0;
|
||
|
|
||
|
#define expect(msg, exp, val) \
|
||
|
printf("%s %s%s (is:%d want:%d)\n", \
|
||
|
msg, \
|
||
|
val ? "true" : "false", \
|
||
|
(exp != val) ? " (failed)" : "", \
|
||
|
exp, val \
|
||
|
); \
|
||
|
if (exp != val) { \
|
||
|
result++; \
|
||
|
}
|
||
|
|
||
|
//-------------------------------------------------------------------------
|
||
|
|
||
|
void varintconst(void)
|
||
|
{
|
||
|
printf("var vs int const\n");
|
||
|
|
||
|
fp1 = 10.0f;
|
||
|
fp2 = 20.0f;
|
||
|
|
||
|
expect("20 < 10 is", 1, (fp2 < 10));
|
||
|
expect("10 < 20 is", 0, (fp1 < 20));
|
||
|
|
||
|
expect("20 > 10 is", 0, (fp2 > 10));
|
||
|
expect("10 > 20 is", 1, (fp1 > 20));
|
||
|
|
||
|
expect("20 <= 10 is", 1, (fp2 <= 10));
|
||
|
expect("10 <= 20 is", 0, (fp1 <= 20));
|
||
|
|
||
|
expect("20 >= 10 is", 0, (fp2 >= 10));
|
||
|
expect("10 >= 20 is", 1, (fp1 >= 20));
|
||
|
|
||
|
}
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
printf("float-cmp-var-intconst\n");
|
||
|
|
||
|
varintconst();
|
||
|
|
||
|
printf("float-cmp-var-intconst (res: %d)\n", result);
|
||
|
return (result == 8) ? EXIT_FAILURE : EXIT_SUCCESS;
|
||
|
}
|