| 195 | } |
| 196 | |
| 197 | int main() { |
| 198 | printf("Testing positive losslessIntegers:\n"); |
| 199 | for (int i = 0; i < sizeof(losslessIntegers) / sizeof(losslessIntegers[0]); ++i) { |
| 200 | uint64_t num = losslessIntegers[i]; |
| 201 | printf("%llu (0x%llx):\n", num, num); |
| 202 | printf(" convertI32PairToI53: 0x%llx\n", testconvertI32PairToI53(num)); |
| 203 | if (num != testconvertI32PairToI53(num)) return 1; |
| 204 | printf(" convertU32PairToI53: 0x%llx\n", testconvertU32PairToI53(num)); |
| 205 | if (num != testconvertU32PairToI53(num)) return 1; |
| 206 | printf(" writeI53ToI64: 0x%llx\n", testWriteI64AsI53(num)); |
| 207 | if (num != testWriteI64AsI53(num)) return 1; |
| 208 | printf(" readI53FromI64: 0x%llx\n", testReadWriteI64AsI53(num)); |
| 209 | if (num != testReadWriteI64AsI53(num)) return 1; |
| 210 | printf(" readI53FromU64: 0x%llx\n", testReadWriteU64AsI53(num)); |
| 211 | if (num != testReadWriteU64AsI53(num)) return 1; |
| 212 | printf("\n"); |
| 213 | } |
| 214 | |
| 215 | printf("Testing negative losslessIntegers:\n"); |
| 216 | for (int i = 0; i < sizeof(losslessIntegers) / sizeof(losslessIntegers[0]); ++i) { |
| 217 | // Test negative: |
| 218 | int64_t neg = -(int64_t)losslessIntegers[i]; |
| 219 | printf("%lld (0x%llx):\n", neg, neg); |
| 220 | printf(" convertI32PairToI53: 0x%llx\n", testconvertI32PairToI53(neg)); |
| 221 | if (neg != testconvertI32PairToI53(neg)) return 1; |
| 222 | printf(" writeI53ToI64: 0x%llx\n", testWriteI64AsI53(neg)); |
| 223 | if (neg != testWriteI64AsI53(neg)) return 1; |
| 224 | printf(" readI53FromI64: 0x%llx\n", testReadWriteI64AsI53(neg)); |
| 225 | if (neg != testReadWriteI64AsI53(neg)) return 1; |
| 226 | printf("\n"); |
| 227 | } |
| 228 | |
| 229 | printf("Testing preciseUnsignedIntegers:\n"); |
| 230 | for (int i = 0; i < sizeof(preciseUnsignedIntegers) / sizeof(preciseUnsignedIntegers[0]); ++i) { |
| 231 | uint64_t num = preciseUnsignedIntegers[i]; |
| 232 | printf("%llu (0x%llx):\n", num, num); |
| 233 | printf(" convertU32PairToI53: 0x%llx: error difference: %lld\n", testconvertU32PairToI53(num), testconvertU32PairToI53(num) - num); |
| 234 | printf(" readI53FromU64: 0x%llx: error difference: %lld\n", testReadWriteU64AsI53(num), testReadWriteU64AsI53(num) - num); |
| 235 | printf("\n"); |
| 236 | } |
| 237 | |
| 238 | printf("Testing preciseNegativeIntegers:\n"); |
| 239 | for (int i = 0; i < sizeof(preciseNegativeIntegers) / sizeof(preciseNegativeIntegers[0]); ++i) { |
| 240 | uint64_t num = preciseNegativeIntegers[i]; |
| 241 | printf("%llu (0x%llx):\n", num, num); |
| 242 | printf(" convertI32PairToI53: 0x%llx: error difference: %lld\n", testconvertI32PairToI53(num), testconvertI32PairToI53(num) - num); |
| 243 | printf(" readI53FromI64: 0x%llx: error difference: %lld\n", testReadWriteI64AsI53(num), testReadWriteI64AsI53(num) - num); |
| 244 | printf("\n"); |
| 245 | } |
| 246 | |
| 247 | printf("Testing impreciseUnsignedIntegers:\n"); |
| 248 | for (int i = 0; i < sizeof(impreciseUnsignedIntegers) / sizeof(impreciseUnsignedIntegers[0]); ++i) { |
| 249 | double num = impreciseUnsignedIntegers[i]; |
| 250 | printf("%f:\n", num); |
| 251 | uint64_t u; |
| 252 | writeI53ToI64_double((int64_t*)&u, num); |
| 253 | printf(" writeI53ToI64: 0x%llx (%llu): error difference: %g\n", u, u, u - num); |
| 254 | printf("\n"); |
nothing calls this directly
no test coverage detected