diff --git a/test/testautomation_audio.c b/test/testautomation_audio.c index 7c141b3a56..3b1a397edd 100644 --- a/test/testautomation_audio.c +++ b/test/testautomation_audio.c @@ -15,6 +15,16 @@ #include #include "testautomation_suites.h" +static bool test_double_isfinite(double d) +{ + union { + Uint64 u64; + double d; + } d_u; + d_u.d = d; + return (d_u.u64 & 0x7ff0000000000000ULL) != 0x7ff0000000000000ULL; +} + /* ================= Test Case Implementation ================== */ /* Fixture */ @@ -1147,11 +1157,11 @@ static int SDLCALL audio_resampleLoss(void *arg) SDL_DestroyAudioStream(stream); SDL_free(buf_out); signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */ - SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite."); - SDLTest_AssertCheck(ISFINITE(sum_squared_error), "Sum of squared error should be finite."); + SDLTest_AssertCheck(test_double_isfinite(sum_squared_value), "Sum of squared target should be finite."); + SDLTest_AssertCheck(test_double_isfinite(sum_squared_error), "Sum of squared error should be finite."); /* Infinity is theoretically possible when there is very little to no noise */ SDLTest_AssertCheck(!ISNAN(signal_to_noise), "Signal-to-noise ratio should not be NaN."); - SDLTest_AssertCheck(ISFINITE(max_error), "Maximum conversion error should be finite."); + SDLTest_AssertCheck(test_double_isfinite(max_error), "Maximum conversion error should be finite."); SDLTest_AssertCheck(signal_to_noise >= spec->signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.", signal_to_noise, spec->signal_to_noise); 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) } signal_to_noise = 10 * SDL_log10(sum_squared_value / sum_squared_error); /* decibel */ - SDLTest_AssertCheck(ISFINITE(sum_squared_value), "Sum of squared target should be finite."); - SDLTest_AssertCheck(ISFINITE(sum_squared_error), "Sum of squared error should be finite."); + SDLTest_AssertCheck(test_double_isfinite(sum_squared_value), "Sum of squared target should be finite."); + SDLTest_AssertCheck(test_double_isfinite(sum_squared_error), "Sum of squared error should be finite."); /* Infinity is theoretically possible when there is very little to no noise */ SDLTest_AssertCheck(!ISNAN(signal_to_noise), "Signal-to-noise ratio should not be NaN."); - SDLTest_AssertCheck(ISFINITE(max_error), "Maximum conversion error should be finite."); + SDLTest_AssertCheck(test_double_isfinite(max_error), "Maximum conversion error should be finite."); SDLTest_AssertCheck(signal_to_noise >= target_signal_to_noise, "Conversion signal-to-noise ratio %f dB should be no less than %f dB.", signal_to_noise, target_signal_to_noise); SDLTest_AssertCheck(max_error <= target_max_error, "Maximum conversion error %f should be no more than %f.", diff --git a/test/testautomation_suites.h b/test/testautomation_suites.h index 093bb9b69f..e683f79108 100644 --- a/test/testautomation_suites.h +++ b/test/testautomation_suites.h @@ -8,7 +8,6 @@ #include -#define ISFINITE(X) isfinite((float)(X)) #define ISINF(X) isinf((float)(X)) #define ISNAN(X) isnan((float)(X))