SDL: test: Don't accept results that are much less than expected (a7bd1)

From a7bd18c0d53f7de49af195899e7ec9478ea7820c Mon Sep 17 00:00:00 2001
From: Simon McVittie <[EMAIL REDACTED]>
Date: Thu, 1 Feb 2024 20:10:50 +0000
Subject: [PATCH] test: Don't accept results that are much less than expected
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

While looking at the other tests in this file, I noticed that instead
of checking for a result in the range of expected ± FLT_EPSILON as I
would have expected, these tests would accept any result strictly less
than expected + FLT_EPSILON, for example a wrong result that is very
large and negative. This is presumably not what was intended, so add
the SDL_fabs() that I assume was meant to be here.

Fixes: 474c8d00 "testautomation: don't do float equality tests"
Signed-off-by: Simon McVittie <smcv@collabora.com>
---
 test/testautomation_math.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/test/testautomation_math.c b/test/testautomation_math.c
index f2024fd45832..8802ba0f07f8 100644
--- a/test/testautomation_math.c
+++ b/test/testautomation_math.c
@@ -82,7 +82,7 @@ helper_dtod(const char *func_name, d_to_d_func func,
     Uint32 i;
     for (i = 0; i < cases_size; i++) {
         const double result = func(cases[i].input);
-        SDLTest_AssertCheck((result - cases[i].expected) < FLT_EPSILON,
+        SDLTest_AssertCheck(SDL_fabs(result - cases[i].expected) < FLT_EPSILON,
                             "%s(%f), expected %f, got %f",
                             func_name,
                             cases[i].input,
@@ -1161,7 +1161,7 @@ log_baseCases(void *args)
                         1.0, 0.0, result);
 
     result = SDL_log(EULER);
-    SDLTest_AssertCheck((result - 1.) < FLT_EPSILON,
+    SDLTest_AssertCheck(SDL_fabs(result - 1.) < FLT_EPSILON,
                         "Log(%f), expected %f, got %f",
                         EULER, 1.0, result);