forked from Green-Sky/tomato
Merge commit '852f2a6343518919e5ca8d3c1bbcab9f493e3cd8'
This commit is contained in:
46
external/sdl/SDL/test/testautomation_math.c
vendored
46
external/sdl/SDL/test/testautomation_math.c
vendored
@ -62,7 +62,7 @@ typedef double(SDLCALL *d_to_d_func)(double);
|
||||
typedef double(SDLCALL *dd_to_d_func)(double, double);
|
||||
|
||||
/**
|
||||
* \brief Runs all the cases on a given function with a signature double -> double.
|
||||
* Runs all the cases on a given function with a signature double -> double.
|
||||
* The result is expected to be exact.
|
||||
*
|
||||
* \param func_name a printable name for the tested function.
|
||||
@ -77,7 +77,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,
|
||||
SDLTest_AssertCheck((result - cases[i].expected) < FLT_EPSILON,
|
||||
"%s(%f), expected %f, got %f",
|
||||
func_name,
|
||||
cases[i].input,
|
||||
@ -88,7 +88,7 @@ helper_dtod(const char *func_name, d_to_d_func func,
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Runs all the cases on a given function with a signature double -> double.
|
||||
* Runs all the cases on a given function with a signature double -> double.
|
||||
* Checks if the result between expected +/- EPSILON.
|
||||
*
|
||||
* \param func_name a printable name for the tested function.
|
||||
@ -117,7 +117,7 @@ helper_dtod_inexact(const char *func_name, d_to_d_func func,
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Runs all the cases on a given function with a signature
|
||||
* Runs all the cases on a given function with a signature
|
||||
* (double, double) -> double. The result is expected to be exact.
|
||||
*
|
||||
* \param func_name a printable name for the tested function.
|
||||
@ -143,7 +143,7 @@ helper_ddtod(const char *func_name, dd_to_d_func func,
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Runs all the cases on a given function with a signature
|
||||
* Runs all the cases on a given function with a signature
|
||||
* (double, double) -> double. Checks if the result between expected +/- EPSILON.
|
||||
*
|
||||
* \param func_name a printable name for the tested function.
|
||||
@ -172,7 +172,7 @@ helper_ddtod_inexact(const char *func_name, dd_to_d_func func,
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Runs a range of values on a given function with a signature double -> double
|
||||
* Runs a range of values on a given function with a signature double -> double
|
||||
*
|
||||
* This function is only meant to test functions that returns the input value if it is
|
||||
* integral: f(x) -> x for x in N.
|
||||
@ -1139,7 +1139,7 @@ log_baseCases(void *args)
|
||||
1.0, 0.0, result);
|
||||
|
||||
result = SDL_log(EULER);
|
||||
SDLTest_AssertCheck(1.0 == result,
|
||||
SDLTest_AssertCheck((result - 1.) < FLT_EPSILON,
|
||||
"Log(%f), expected %f, got %f",
|
||||
EULER, 1.0, result);
|
||||
|
||||
@ -2275,7 +2275,7 @@ acos_limitCases(void *args)
|
||||
1.0, 0.0, result);
|
||||
|
||||
result = SDL_acos(-1.0);
|
||||
SDLTest_AssertCheck(SDL_PI_D == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D - result) <= EPSILON,
|
||||
"Acos(%f), expected %f, got %f",
|
||||
-1.0, SDL_PI_D, result);
|
||||
|
||||
@ -2362,12 +2362,12 @@ asin_limitCases(void *args)
|
||||
double result;
|
||||
|
||||
result = SDL_asin(1.0);
|
||||
SDLTest_AssertCheck(SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Asin(%f), expected %f, got %f",
|
||||
1.0, SDL_PI_D / 2.0, result);
|
||||
|
||||
result = SDL_asin(-1.0);
|
||||
SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Asin(%f), expected %f, got %f",
|
||||
-1.0, -SDL_PI_D / 2.0, result);
|
||||
|
||||
@ -2554,7 +2554,7 @@ atan2_bothZeroCases(void *args)
|
||||
{ 0.0, -0.0, SDL_PI_D },
|
||||
{ -0.0, -0.0, -SDL_PI_D },
|
||||
};
|
||||
return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
|
||||
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2573,7 +2573,7 @@ atan2_yZeroCases(void *args)
|
||||
{ -0.0, 1.0, -0.0 },
|
||||
{ -0.0, -1.0, -SDL_PI_D }
|
||||
};
|
||||
return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
|
||||
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2589,7 +2589,7 @@ atan2_xZeroCases(void *args)
|
||||
{ 1.0, -0.0, SDL_PI_D / 2.0 },
|
||||
{ -1.0, -0.0, -SDL_PI_D / 2.0 }
|
||||
};
|
||||
return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
|
||||
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
|
||||
}
|
||||
|
||||
/* Infinity cases */
|
||||
@ -2608,22 +2608,22 @@ atan2_bothInfCases(void *args)
|
||||
double result;
|
||||
|
||||
result = SDL_atan2(INFINITY, INFINITY);
|
||||
SDLTest_AssertCheck(SDL_PI_D / 4.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D / 4.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
INFINITY, INFINITY, SDL_PI_D / 4.0, result);
|
||||
|
||||
result = SDL_atan2(INFINITY, -INFINITY);
|
||||
SDLTest_AssertCheck(3.0 * SDL_PI_D / 4.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(3.0 * SDL_PI_D / 4.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
INFINITY, -INFINITY, 3.0 * SDL_PI_D / 4.0, result);
|
||||
|
||||
result = SDL_atan2(-INFINITY, INFINITY);
|
||||
SDLTest_AssertCheck(-SDL_PI_D / 4.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-SDL_PI_D / 4.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
-INFINITY, INFINITY, -SDL_PI_D / 4.0, result);
|
||||
|
||||
result = SDL_atan2(-INFINITY, -INFINITY);
|
||||
SDLTest_AssertCheck(-3.0 * SDL_PI_D / 4.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-3.0 * SDL_PI_D / 4.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
-INFINITY, -INFINITY, -3.0 * SDL_PI_D / 4.0, result);
|
||||
|
||||
@ -2640,22 +2640,22 @@ atan2_yInfCases(void *args)
|
||||
double result;
|
||||
|
||||
result = SDL_atan2(INFINITY, 1.0);
|
||||
SDLTest_AssertCheck(SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
INFINITY, 1.0, SDL_PI_D / 2.0, result);
|
||||
|
||||
result = SDL_atan2(INFINITY, -1.0);
|
||||
SDLTest_AssertCheck(SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
INFINITY, -1.0, SDL_PI_D / 2.0, result);
|
||||
|
||||
result = SDL_atan2(-INFINITY, 1.0);
|
||||
SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
-INFINITY, 1.0, -SDL_PI_D / 2.0, result);
|
||||
|
||||
result = SDL_atan2(-INFINITY, -1.0);
|
||||
SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-SDL_PI_D / 2.0 - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
-INFINITY, -1.0, -SDL_PI_D / 2.0, result);
|
||||
|
||||
@ -2684,12 +2684,12 @@ atan2_xInfCases(void *args)
|
||||
-1.0, INFINITY, -0.0, result);
|
||||
|
||||
result = SDL_atan2(1.0, -INFINITY);
|
||||
SDLTest_AssertCheck(SDL_PI_D == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(SDL_PI_D - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
1.0, -INFINITY, SDL_PI_D, result);
|
||||
|
||||
result = SDL_atan2(-1.0, -INFINITY);
|
||||
SDLTest_AssertCheck(-SDL_PI_D == result,
|
||||
SDLTest_AssertCheck(SDL_fabs(-SDL_PI_D - result) <= EPSILON,
|
||||
"Atan2(%f,%f), expected %f, got %f",
|
||||
-1.0, -INFINITY, -SDL_PI_D, result);
|
||||
|
||||
|
Reference in New Issue
Block a user