diff options
| author | Thomas Preud'homme <robotux@celest.fr> | 2014-02-05 15:26:46 +0800 |
|---|---|---|
| committer | Thomas Preud'homme <robotux@celest.fr> | 2014-02-05 15:26:46 +0800 |
| commit | 02d2ca8ac77e8deaa494199f79624176df6a2b6c (patch) | |
| tree | 26a7da43dc130845b2fadfbe43a3a609b028b9af /tests/tcctest.c | |
| parent | 17314a1fb316eb712ae0c539ccea64fe1aeb5c93 (diff) | |
| download | tinycc-02d2ca8ac77e8deaa494199f79624176df6a2b6c.tar.gz tinycc-02d2ca8ac77e8deaa494199f79624176df6a2b6c.tar.bz2 | |
Fix and extend *FCAST test in tcctest.c
Result of float to unsigned integer conversion is undefined if float is
negative. This commit take the absolute value of the float before doing
the conversion to unsigned integer and add more float to integer
conversion test.
Diffstat (limited to 'tests/tcctest.c')
| -rw-r--r-- | tests/tcctest.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/tests/tcctest.c b/tests/tcctest.c index d185111..1653927 100644 --- a/tests/tcctest.c +++ b/tests/tcctest.c @@ -1670,7 +1670,7 @@ void prefix ## fcast(type a)\ double da;\ LONG_DOUBLE la;\ int ia;\ - long long lla;\ + long long llia;\ unsigned int ua;\ unsigned long long llua;\ type b;\ @@ -1679,18 +1679,21 @@ void prefix ## fcast(type a)\ la = a;\ printf("ftof: %f %f %Lf\n", fa, da, la);\ ia = (int)a;\ - lla = (long long)a;\ + llia = (long long)a;\ + a = (a >= 0) ? a : -a;\ ua = (unsigned int)a;\ llua = (unsigned long long)a;\ - printf("ftoi: %d %u\n", ia, ua);\ + printf("ftoi: %d %u %lld %llu\n", ia, ua, llia, llua);\ ia = -1234;\ ua = 0x81234500;\ + llia = -0x123456789012345LL;\ + llua = 0xf123456789012345LLU;\ b = ia;\ printf("itof: " fmt "\n", b);\ - b = lla;\ - printf("lltof: " fmt "\n", b);\ b = ua;\ printf("utof: " fmt "\n", b);\ + b = llia;\ + printf("lltof: " fmt "\n", b);\ b = llua;\ printf("ulltof: " fmt "\n", b);\ }\ |
