| 28 | } |
| 29 | |
| 30 | int main() { |
| 31 | printf("Testing library_int53.js function $convertI32PairToI53Checked():\n\n"); |
| 32 | |
| 33 | printf("Testing positive losslessIntegers:\n"); |
| 34 | for (uint64_t num : losslessIntegers) { |
| 35 | double ret = test(num); |
| 36 | if (ret != num) return 1; |
| 37 | } |
| 38 | |
| 39 | printf("\nTesting negative losslessIntegers:\n"); |
| 40 | for (uint64_t num : losslessIntegers) { |
| 41 | int64_t neg = -(int64_t)num; |
| 42 | double ret = test(neg); |
| 43 | if (ret != neg) return 1; |
| 44 | } |
| 45 | |
| 46 | printf("\nTesting preciseUnsignedIntegers:\n"); |
| 47 | for (uint64_t num : preciseUnsignedIntegers) { |
| 48 | double ret = test(num); |
| 49 | if (!isnan(ret)) return 1; |
| 50 | } |
| 51 | |
| 52 | printf("\nTesting preciseNegativeIntegers:\n"); |
| 53 | for (uint64_t num : preciseNegativeIntegers) { |
| 54 | double ret = test(num); |
| 55 | if (!isnan(ret)) return 1; |
| 56 | } |
| 57 | |
| 58 | printf("\nTesting impreciseUnsignedIntegers:\n"); |
| 59 | for (uint64_t num : impreciseUnsignedIntegers) { |
| 60 | test(num); |
| 61 | } |
| 62 | |
| 63 | printf("\nTesting impreciseNegativeIntegers:\n"); |
| 64 | for (uint64_t num : impreciseNegativeIntegers) { |
| 65 | double ret = test(num); |
| 66 | if (!isnan(ret)) return 1; |
| 67 | } |
| 68 | |
| 69 | printf("\nTesting otherDoubles:\n"); |
| 70 | for (int sign = 0; sign < 2; ++sign) { |
| 71 | for (double d : otherDoubles) { |
| 72 | double num = sign ? -d : d; |
| 73 | uint64_t u = *(uint64_t*)# |
| 74 | printf("Double: %f -> ", num); |
| 75 | test(u); |
| 76 | } |
| 77 | } |
| 78 | printf("All done!\n"); |
| 79 | } |