|
15 | 15 | #include <SDL3/SDL_test.h> |
16 | 16 | #include "testautomation_suites.h" |
17 | 17 |
|
| 18 | +static bool test_double_isfinite(double d) |
| 19 | +{ |
| 20 | + union { |
| 21 | + Uint64 u64; |
| 22 | + double d; |
| 23 | + } d_u; |
| 24 | + d_u.d = d; |
| 25 | + return (d_u.u64 & 0x7ff0000000000000ULL) != 0x7ff0000000000000ULL; |
| 26 | +} |
| 27 | + |
18 | 28 | /* ================= Test Case Implementation ================== */ |
19 | 29 |
|
20 | 30 | /* Fixture */ |
@@ -1147,11 +1157,11 @@ static int SDLCALL audio_resampleLoss(void *arg) |
1147 | 1157 | SDL_DestroyAudioStream(stream); |
1148 | 1158 | SDL_free(buf_out); |
1149 | 1159 | signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */ |
1150 | | - SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite."); |
1151 | | - SDLTest_AssertCheck(ISFINITE(sum_squared_error), "Sum of squared error should be finite."); |
| 1160 | + SDLTest_AssertCheck(test_double_isfinite(sum_squared_value), "Sum of squared target should be finite."); |
| 1161 | + SDLTest_AssertCheck(test_double_isfinite(sum_squared_error), "Sum of squared error should be finite."); |
1152 | 1162 | /* Infinity is theoretically possible when there is very little to no noise */ |
1153 | 1163 | SDLTest_AssertCheck(!ISNAN(signal_to_noise), "Signal-to-noise ratio should not be NaN."); |
1154 | | - SDLTest_AssertCheck(ISFINITE(max_error), "Maximum conversion error should be finite."); |
| 1164 | + SDLTest_AssertCheck(test_double_isfinite(max_error), "Maximum conversion error should be finite."); |
1155 | 1165 | SDLTest_AssertCheck(signal_to_noise >= spec->signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.", |
1156 | 1166 | signal_to_noise, spec->signal_to_noise); |
1157 | 1167 | SDLTest_AssertCheck(max_error <= spec->max_error, "Maximum conversion error %f should be no more than %f.", |
@@ -1440,11 +1450,11 @@ static int SDLCALL audio_formatChange(void *arg) |
1440 | 1450 | } |
1441 | 1451 |
|
1442 | 1452 | signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */ |
1443 | | - SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite."); |
1444 | | - SDLTest_AssertCheck(ISFINITE(sum_squared_error), "Sum of squared error should be finite."); |
| 1453 | + SDLTest_AssertCheck(test_double_isfinite(sum_squared_value), "Sum of squared target should be finite."); |
| 1454 | + SDLTest_AssertCheck(test_double_isfinite(sum_squared_error), "Sum of squared error should be finite."); |
1445 | 1455 | /* Infinity is theoretically possible when there is very little to no noise */ |
1446 | 1456 | SDLTest_AssertCheck(!ISNAN(signal_to_noise), "Signal-to-noise ratio should not be NaN."); |
1447 | | - SDLTest_AssertCheck(ISFINITE(max_error), "Maximum conversion error should be finite."); |
| 1457 | + SDLTest_AssertCheck(test_double_isfinite(max_error), "Maximum conversion error should be finite."); |
1448 | 1458 | SDLTest_AssertCheck(signal_to_noise >= target_signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.", |
1449 | 1459 | signal_to_noise, target_signal_to_noise); |
1450 | 1460 | SDLTest_AssertCheck(max_error <= target_max_error, "Maximum conversion error %f should be no more than %f.", |
|
0 commit comments