| 1 |
/** |
| 2 |
* Math test suite |
| 3 |
*/ |
| 4 |
|
| 5 |
#include <float.h> |
| 6 |
#include <math.h> |
| 7 |
|
| 8 |
#include "SDL.h" |
| 9 |
#include "SDL_test.h" |
| 10 |
|
| 11 |
/* ================= Test Constants ================== */ |
| 12 |
|
| 13 |
/* Range tests parameters */ |
| 14 |
#define RANGE_TEST_ITERATIONS 10000000 |
| 15 |
#define RANGE_TEST_STEP ((Uint32)(SDL_MAX_UINT32 / RANGE_TEST_ITERATIONS)) |
| 16 |
|
| 17 |
/* Margin of error for imprecise tests */ |
| 18 |
#define EPSILON 1.0E-10 |
| 19 |
|
| 20 |
/* Euler constant (used in exp/log) */ |
| 21 |
#ifndef M_E |
| 22 |
#define EULER 2.7182818284590450907955982984276488423347473144531250 |
| 23 |
#else |
| 24 |
#define EULER M_E |
| 25 |
#endif |
| 26 |
|
| 27 |
#define IS_INFINITY(V) fpclassify(V) == FP_INFINITE |
| 28 |
|
| 29 |
/* Square root of 3 (used in atan2) */ |
| 30 |
#define SQRT3 1.7320508075688771931766041234368458390235900878906250 |
| 31 |
|
| 32 |
/* ================= Test Structs ================== */ |
| 33 |
|
| 34 |
/** |
| 35 |
* Stores a single input and the expected result |
| 36 |
*/ |
| 37 |
typedef struct |
| 38 |
{ |
| 39 |
double input; |
| 40 |
double expected; |
| 41 |
} d_to_d; |
| 42 |
|
| 43 |
/** |
| 44 |
* Stores a pair of inputs and the expected result |
| 45 |
*/ |
| 46 |
typedef struct |
| 47 |
{ |
| 48 |
double x_input, y_input; |
| 49 |
double expected; |
| 50 |
} dd_to_d; |
| 51 |
|
| 52 |
#define DD_TO_D_CASE(IDX, X, Y, E) do { \ |
| 53 |
cases[IDX].x_input = (X); \ |
| 54 |
cases[IDX].y_input = (Y); \ |
| 55 |
cases[IDX].expected = (E); \ |
| 56 |
} while (0) |
| 57 |
|
| 58 |
/* |
| 59 |
NB: You cannot create an array of these structures containing INFINITY or NAN. |
| 60 |
On platforms such as OS/2, they are defined as 'extern const double' making them |
| 61 |
not compile-time constant. |
| 62 |
*/ |
| 63 |
|
| 64 |
/* ================= Test Helpers ================== */ |
| 65 |
|
| 66 |
typedef double(SDLCALL *d_to_d_func)(double); |
| 67 |
typedef double(SDLCALL *dd_to_d_func)(double, double); |
| 68 |
|
| 69 |
/** |
| 70 |
* \brief Runs all the cases on a given function with a signature double -> double. |
| 71 |
* The result is expected to be exact. |
| 72 |
* |
| 73 |
* \param func_name a printable name for the tested function. |
| 74 |
* \param func the function to call. |
| 75 |
* \param cases an array of all the cases. |
| 76 |
* \param cases_size the size of the cases array. |
| 77 |
*/ |
| 78 |
static int |
| 79 |
helper_dtod(const char *func_name, d_to_d_func func, |
| 80 |
const d_to_d *cases, const size_t cases_size) |
| 81 |
{ |
| 82 |
Uint32 i; |
| 83 |
for (i = 0; i < cases_size; i++) { |
| 84 |
const double result = func(cases[i].input); |
| 85 |
SDLTest_AssertCheck(SDL_fabs(result - cases[i].expected) < FLT_EPSILON, |
| 86 |
"%s(%f), expected %f, got %f", |
| 87 |
func_name, |
| 88 |
cases[i].input, |
| 89 |
cases[i].expected, result); |
| 90 |
} |
| 91 |
|
| 92 |
return TEST_COMPLETED; |
| 93 |
} |
| 94 |
|
| 95 |
/** |
| 96 |
* \brief Runs all the cases on a given function with a signature double -> double. |
| 97 |
* Checks if the result between expected +/- EPSILON. |
| 98 |
* |
| 99 |
* \param func_name a printable name for the tested function. |
| 100 |
* \param func the function to call. |
| 101 |
* \param cases an array of all the cases. |
| 102 |
* \param cases_size the size of the cases array. |
| 103 |
*/ |
| 104 |
static int |
| 105 |
helper_dtod_inexact(const char *func_name, d_to_d_func func, |
| 106 |
const d_to_d *cases, const size_t cases_size) |
| 107 |
{ |
| 108 |
Uint32 i; |
| 109 |
for (i = 0; i < cases_size; i++) { |
| 110 |
const double result = func(cases[i].input); |
| 111 |
double diff = result - cases[i].expected; |
| 112 |
double max_err = (cases[i].expected + 1.) * EPSILON; |
| 113 |
if (diff < 0) { |
| 114 |
diff = -diff; |
| 115 |
} |
| 116 |
if (max_err < 0) { |
| 117 |
max_err = -max_err; |
| 118 |
} |
| 119 |
SDLTest_AssertCheck(diff <= max_err, |
| 120 |
"%s(%f), expected %f +/- %g, got %f", |
| 121 |
func_name, |
| 122 |
cases[i].input, |
| 123 |
cases[i].expected, max_err, |
| 124 |
result); |
| 125 |
} |
| 126 |
|
| 127 |
return TEST_COMPLETED; |
| 128 |
} |
| 129 |
|
| 130 |
/** |
| 131 |
* \brief Runs all the cases on a given function with a signature |
| 132 |
* (double, double) -> double. The result is expected to be exact. |
| 133 |
* |
| 134 |
* \param func_name a printable name for the tested function. |
| 135 |
* \param func the function to call. |
| 136 |
* \param cases an array of all the cases. |
| 137 |
* \param cases_size the size of the cases array. |
| 138 |
*/ |
| 139 |
static int |
| 140 |
helper_ddtod(const char *func_name, dd_to_d_func func, |
| 141 |
const dd_to_d *cases, const size_t cases_size) |
| 142 |
{ |
| 143 |
Uint32 i; |
| 144 |
for (i = 0; i < cases_size; i++) { |
| 145 |
const double result = func(cases[i].x_input, cases[i].y_input); |
| 146 |
/* By using the result as input, the compiler is less likely to use higher precision floating point number */ |
| 147 |
(void)SDL_sin(result); |
| 148 |
SDLTest_AssertCheck(result == cases[i].expected, |
| 149 |
"%s(%f,%f), expected %f, got %f", |
| 150 |
func_name, |
| 151 |
cases[i].x_input, cases[i].y_input, |
| 152 |
cases[i].expected, result); |
| 153 |
} |
| 154 |
|
| 155 |
return TEST_COMPLETED; |
| 156 |
} |
| 157 |
|
| 158 |
/** |
| 159 |
* \brief Runs all the cases on a given function with a signature |
| 160 |
* (double, double) -> double. Checks if the result between expected +/- EPSILON. |
| 161 |
* |
| 162 |
* \param func_name a printable name for the tested function. |
| 163 |
* \param func the function to call. |
| 164 |
* \param cases an array of all the cases. |
| 165 |
* \param cases_size the size of the cases array. |
| 166 |
*/ |
| 167 |
static int |
| 168 |
helper_ddtod_inexact(const char *func_name, dd_to_d_func func, |
| 169 |
const dd_to_d *cases, const size_t cases_size) |
| 170 |
{ |
| 171 |
Uint32 i; |
| 172 |
for (i = 0; i < cases_size; i++) { |
| 173 |
const double result = func(cases[i].x_input, cases[i].y_input); |
| 174 |
double diff = result - cases[i].expected; |
| 175 |
double max_err = (cases[i].expected + 1.) * EPSILON; |
| 176 |
if (diff < 0) { |
| 177 |
diff = -diff; |
| 178 |
} |
| 179 |
if (max_err < 0) { |
| 180 |
max_err = -max_err; |
| 181 |
} |
| 182 |
|
| 183 |
SDLTest_AssertCheck(diff <= max_err, |
| 184 |
"%s(%f,%f), expected %f +/- %g, got %f", |
| 185 |
func_name, |
| 186 |
cases[i].x_input, cases[i].y_input, |
| 187 |
cases[i].expected, max_err, |
| 188 |
result); |
| 189 |
} |
| 190 |
|
| 191 |
return TEST_COMPLETED; |
| 192 |
} |
| 193 |
|
| 194 |
/** |
| 195 |
* \brief Runs a range of values on a given function with a signature double -> double |
| 196 |
* |
| 197 |
* This function is only meant to test functions that returns the input value if it is |
| 198 |
* integral: f(x) -> x for x in N. |
| 199 |
* |
| 200 |
* \param func_name a printable name for the tested function. |
| 201 |
* \param func the function to call. |
| 202 |
*/ |
| 203 |
static int |
| 204 |
helper_range(const char *func_name, d_to_d_func func) |
| 205 |
{ |
| 206 |
Uint32 i; |
| 207 |
double test_value = 0.0; |
| 208 |
|
| 209 |
SDLTest_AssertPass("%s: Testing a range of %u values with steps of %" SDL_PRIu32, |
| 210 |
func_name, |
| 211 |
RANGE_TEST_ITERATIONS, |
| 212 |
RANGE_TEST_STEP); |
| 213 |
|
| 214 |
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { |
| 215 |
double result; |
| 216 |
/* These are tested elsewhere */ |
| 217 |
if (isnan(test_value) || isinf(test_value)) { |
| 218 |
continue; |
| 219 |
} |
| 220 |
|
| 221 |
result = func(test_value); |
| 222 |
if (result != test_value) { /* Only log failures to save performances */ |
| 223 |
SDLTest_AssertCheck(SDL_FALSE, |
| 224 |
"%s(%.1f), expected %.1f, got %.1f", |
| 225 |
func_name, test_value, |
| 226 |
test_value, result); |
| 227 |
return TEST_ABORTED; |
| 228 |
} |
| 229 |
} |
| 230 |
|
| 231 |
return TEST_COMPLETED; |
| 232 |
} |
| 233 |
|
| 234 |
/* ================= Test Case Implementation ================== */ |
| 235 |
|
| 236 |
/* SDL_floor tests functions */ |
| 237 |
|
| 238 |
/** |
| 239 |
* Inputs: +/-Infinity. |
| 240 |
* Expected: Infinity is returned as-is. |
| 241 |
*/ |
| 242 |
static int |
| 243 |
floor_infCases(void *args) |
| 244 |
{ |
| 245 |
double result; |
| 246 |
|
| 247 |
result = SDL_floor(INFINITY); |
| 248 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 249 |
"Floor(%f), expected %f, got %f", |
| 250 |
INFINITY, INFINITY, result); |
| 251 |
|
| 252 |
result = SDL_floor(-INFINITY); |
| 253 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 254 |
"Floor(%f), expected %f, got %f", |
| 255 |
-INFINITY, -INFINITY, result); |
| 256 |
|
| 257 |
return TEST_COMPLETED; |
| 258 |
} |
| 259 |
|
| 260 |
/** |
| 261 |
* Inputs: +/-0.0. |
| 262 |
* Expected: Zero is returned as-is. |
| 263 |
*/ |
| 264 |
static int |
| 265 |
floor_zeroCases(void *args) |
| 266 |
{ |
| 267 |
const d_to_d zero_cases[] = { |
| 268 |
{ 0.0, 0.0 }, |
| 269 |
{ -0.0, -0.0 } |
| 270 |
}; |
| 271 |
return helper_dtod("Floor", SDL_floor, zero_cases, SDL_arraysize(zero_cases)); |
| 272 |
} |
| 273 |
|
| 274 |
/** |
| 275 |
* Input: NAN. |
| 276 |
* Expected: NAN is returned. |
| 277 |
*/ |
| 278 |
static int |
| 279 |
floor_nanCase(void *args) |
| 280 |
{ |
| 281 |
const double result = SDL_floor(NAN); |
| 282 |
SDLTest_AssertCheck(isnan(result), |
| 283 |
"Floor(nan), expected nan, got %f", |
| 284 |
result); |
| 285 |
return TEST_COMPLETED; |
| 286 |
} |
| 287 |
|
| 288 |
/** |
| 289 |
* Inputs: integral values. |
| 290 |
* Expected: the input value is returned as-is. |
| 291 |
*/ |
| 292 |
static int |
| 293 |
floor_roundNumbersCases(void *args) |
| 294 |
{ |
| 295 |
const d_to_d round_cases[] = { |
| 296 |
{ 1.0, 1.0 }, |
| 297 |
{ -1.0, -1.0 }, |
| 298 |
{ 15.0, 15.0 }, |
| 299 |
{ -15.0, -15.0 }, |
| 300 |
{ 125.0, 125.0 }, |
| 301 |
{ -125.0, -125.0 }, |
| 302 |
{ 1024.0, 1024.0 }, |
| 303 |
{ -1024.0, -1024.0 } |
| 304 |
}; |
| 305 |
return helper_dtod("Floor", SDL_floor, round_cases, SDL_arraysize(round_cases)); |
| 306 |
} |
| 307 |
|
| 308 |
/** |
| 309 |
* Inputs: fractional values. |
| 310 |
* Expected: the lower integral value is returned. |
| 311 |
*/ |
| 312 |
static int |
| 313 |
floor_fractionCases(void *args) |
| 314 |
{ |
| 315 |
const d_to_d frac_cases[] = { |
| 316 |
{ 1.0 / 2.0, 0.0 }, |
| 317 |
{ -1.0 / 2.0, -1.0 }, |
| 318 |
{ 4.0 / 3.0, 1.0 }, |
| 319 |
{ -4.0 / 3.0, -2.0 }, |
| 320 |
{ 76.0 / 7.0, 10.0 }, |
| 321 |
{ -76.0 / 7.0, -11.0 }, |
| 322 |
{ 535.0 / 8.0, 66.0 }, |
| 323 |
{ -535.0 / 8.0, -67.0 }, |
| 324 |
{ 19357.0 / 53.0, 365.0 }, |
| 325 |
{ -19357.0 / 53.0, -366.0 } |
| 326 |
}; |
| 327 |
return helper_dtod("Floor", SDL_floor, frac_cases, SDL_arraysize(frac_cases)); |
| 328 |
} |
| 329 |
|
| 330 |
/** |
| 331 |
* Inputs: values in the range [0, UINT32_MAX]. |
| 332 |
* Expected: the input value is returned as-is. |
| 333 |
*/ |
| 334 |
static int |
| 335 |
floor_rangeTest(void *args) |
| 336 |
{ |
| 337 |
return helper_range("Floor", SDL_floor); |
| 338 |
} |
| 339 |
|
| 340 |
/* SDL_ceil tests functions */ |
| 341 |
|
| 342 |
/** |
| 343 |
* Inputs: +/-Infinity. |
| 344 |
* Expected: Infinity is returned as-is. |
| 345 |
*/ |
| 346 |
static int |
| 347 |
ceil_infCases(void *args) |
| 348 |
{ |
| 349 |
double result; |
| 350 |
|
| 351 |
result = SDL_ceil(INFINITY); |
| 352 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 353 |
"Ceil(%f), expected %f, got %f", |
| 354 |
INFINITY, INFINITY, result); |
| 355 |
|
| 356 |
result = SDL_ceil(-INFINITY); |
| 357 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 358 |
"Ceil(%f), expected %f, got %f", |
| 359 |
-INFINITY, -INFINITY, result); |
| 360 |
|
| 361 |
return TEST_COMPLETED; |
| 362 |
} |
| 363 |
|
| 364 |
/** |
| 365 |
* Inputs: +/-0.0. |
| 366 |
* Expected: Zero is returned as-is. |
| 367 |
*/ |
| 368 |
static int |
| 369 |
ceil_zeroCases(void *args) |
| 370 |
{ |
| 371 |
const d_to_d zero_cases[] = { |
| 372 |
{ 0.0, 0.0 }, |
| 373 |
{ -0.0, -0.0 } |
| 374 |
}; |
| 375 |
return helper_dtod("Ceil", SDL_ceil, zero_cases, SDL_arraysize(zero_cases)); |
| 376 |
} |
| 377 |
|
| 378 |
/** |
| 379 |
* Input: NAN. |
| 380 |
* Expected: NAN is returned. |
| 381 |
*/ |
| 382 |
static int |
| 383 |
ceil_nanCase(void *args) |
| 384 |
{ |
| 385 |
const double result = SDL_ceil(NAN); |
| 386 |
SDLTest_AssertCheck(isnan(result), |
| 387 |
"Ceil(nan), expected nan, got %f", |
| 388 |
result); |
| 389 |
return TEST_COMPLETED; |
| 390 |
} |
| 391 |
|
| 392 |
/** |
| 393 |
* Inputs: integral values. |
| 394 |
* Expected: the input value is returned as-is. |
| 395 |
*/ |
| 396 |
static int |
| 397 |
ceil_roundNumbersCases(void *args) |
| 398 |
{ |
| 399 |
const d_to_d round_cases[] = { |
| 400 |
{ 1.0, 1.0 }, |
| 401 |
{ -1.0, -1.0 }, |
| 402 |
{ 15.0, 15.0 }, |
| 403 |
{ -15.0, -15.0 }, |
| 404 |
{ 125.0, 125.0 }, |
| 405 |
{ -125.0, -125.0 }, |
| 406 |
{ 1024.0, 1024.0 }, |
| 407 |
{ -1024.0, -1024.0 } |
| 408 |
}; |
| 409 |
return helper_dtod("Ceil", SDL_ceil, round_cases, SDL_arraysize(round_cases)); |
| 410 |
} |
| 411 |
|
| 412 |
/** |
| 413 |
* Inputs: fractional values. |
| 414 |
* Expected: the higher integral value is returned. |
| 415 |
*/ |
| 416 |
static int |
| 417 |
ceil_fractionCases(void *args) |
| 418 |
{ |
| 419 |
const d_to_d frac_cases[] = { |
| 420 |
{ 1.0 / 2.0, 1.0 }, |
| 421 |
{ -1.0 / 2.0, -0.0 }, |
| 422 |
{ 4.0 / 3.0, 2.0 }, |
| 423 |
{ -4.0 / 3.0, -1.0 }, |
| 424 |
{ 76.0 / 7.0, 11.0 }, |
| 425 |
{ -76.0 / 7.0, -10.0 }, |
| 426 |
{ 535.0 / 8.0, 67.0 }, |
| 427 |
{ -535.0 / 8.0, -66.0 }, |
| 428 |
{ 19357.0 / 53.0, 366.0 }, |
| 429 |
{ -19357.0 / 53.0, -365.0 } |
| 430 |
}; |
| 431 |
return helper_dtod("Ceil", SDL_ceil, frac_cases, SDL_arraysize(frac_cases)); |
| 432 |
} |
| 433 |
|
| 434 |
/** |
| 435 |
* Inputs: values in the range [0, UINT32_MAX]. |
| 436 |
* Expected: the input value is returned as-is. |
| 437 |
*/ |
| 438 |
static int |
| 439 |
ceil_rangeTest(void *args) |
| 440 |
{ |
| 441 |
return helper_range("Ceil", SDL_ceil); |
| 442 |
} |
| 443 |
|
| 444 |
/* SDL_trunc tests functions */ |
| 445 |
|
| 446 |
/** |
| 447 |
* Inputs: +/-Infinity. |
| 448 |
* Expected: Infinity is returned as-is. |
| 449 |
*/ |
| 450 |
static int |
| 451 |
trunc_infCases(void *args) |
| 452 |
{ |
| 453 |
double result; |
| 454 |
|
| 455 |
result = SDL_trunc(INFINITY); |
| 456 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 457 |
"Trunc(%f), expected %f, got %f", |
| 458 |
INFINITY, INFINITY, result); |
| 459 |
|
| 460 |
result = SDL_trunc(-INFINITY); |
| 461 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 462 |
"Trunc(%f), expected %f, got %f", |
| 463 |
-INFINITY, -INFINITY, result); |
| 464 |
|
| 465 |
return TEST_COMPLETED; |
| 466 |
} |
| 467 |
|
| 468 |
/** |
| 469 |
* Inputs: +/-0.0. |
| 470 |
* Expected: Zero is returned as-is. |
| 471 |
*/ |
| 472 |
static int |
| 473 |
trunc_zeroCases(void *args) |
| 474 |
{ |
| 475 |
const d_to_d zero_cases[] = { |
| 476 |
{ 0.0, 0.0 }, |
| 477 |
{ -0.0, -0.0 } |
| 478 |
}; |
| 479 |
return helper_dtod("Trunc", SDL_trunc, zero_cases, SDL_arraysize(zero_cases)); |
| 480 |
} |
| 481 |
|
| 482 |
/** |
| 483 |
* Input: NAN. |
| 484 |
* Expected: NAN is returned. |
| 485 |
*/ |
| 486 |
static int |
| 487 |
trunc_nanCase(void *args) |
| 488 |
{ |
| 489 |
const double result = SDL_trunc(NAN); |
| 490 |
SDLTest_AssertCheck(isnan(result), |
| 491 |
"Trunc(nan), expected nan, got %f", |
| 492 |
result); |
| 493 |
return TEST_COMPLETED; |
| 494 |
} |
| 495 |
|
| 496 |
/** |
| 497 |
* Inputs: integral values. |
| 498 |
* Expected: the input value is returned as-is. |
| 499 |
*/ |
| 500 |
static int |
| 501 |
trunc_roundNumbersCases(void *args) |
| 502 |
{ |
| 503 |
const d_to_d round_cases[] = { |
| 504 |
{ 1.0, 1.0 }, |
| 505 |
{ -1.0, -1.0 }, |
| 506 |
{ 15.0, 15.0 }, |
| 507 |
{ -15.0, -15.0 }, |
| 508 |
{ 125.0, 125.0 }, |
| 509 |
{ -125.0, -125.0 }, |
| 510 |
{ 1024.0, 1024.0 }, |
| 511 |
{ -1024.0, -1024.0 } |
| 512 |
}; |
| 513 |
return helper_dtod("Trunc", SDL_trunc, round_cases, SDL_arraysize(round_cases)); |
| 514 |
} |
| 515 |
|
| 516 |
/** |
| 517 |
* Inputs: fractional values. |
| 518 |
* Expected: the integral part is returned. |
| 519 |
*/ |
| 520 |
static int |
| 521 |
trunc_fractionCases(void *args) |
| 522 |
{ |
| 523 |
const d_to_d frac_cases[] = { |
| 524 |
{ 1.0 / 2.0, 0.0 }, |
| 525 |
{ -1.0 / 2.0, -0.0 }, |
| 526 |
{ 4.0 / 3.0, 1.0 }, |
| 527 |
{ -4.0 / 3.0, -1.0 }, |
| 528 |
{ 76.0 / 7.0, 10.0 }, |
| 529 |
{ -76.0 / 7.0, -10.0 }, |
| 530 |
{ 535.0 / 8.0, 66.0 }, |
| 531 |
{ -535.0 / 8.0, -66.0 }, |
| 532 |
{ 19357.0 / 53.0, 365.0 }, |
| 533 |
{ -19357.0 / 53.0, -365.0 } |
| 534 |
}; |
| 535 |
return helper_dtod("Trunc", SDL_trunc, frac_cases, SDL_arraysize(frac_cases)); |
| 536 |
} |
| 537 |
|
| 538 |
/** |
| 539 |
* Inputs: values in the range [0, UINT32_MAX]. |
| 540 |
* Expected: the input value is returned as-is. |
| 541 |
*/ |
| 542 |
static int |
| 543 |
trunc_rangeTest(void *args) |
| 544 |
{ |
| 545 |
return helper_range("Trunc", SDL_trunc); |
| 546 |
} |
| 547 |
|
| 548 |
/* SDL_round tests functions */ |
| 549 |
|
| 550 |
/** |
| 551 |
* Inputs: +/-Infinity. |
| 552 |
* Expected: Infinity is returned as-is. |
| 553 |
*/ |
| 554 |
static int |
| 555 |
round_infCases(void *args) |
| 556 |
{ |
| 557 |
double result; |
| 558 |
|
| 559 |
result = SDL_round(INFINITY); |
| 560 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 561 |
"Round(%f), expected %f, got %f", |
| 562 |
INFINITY, INFINITY, result); |
| 563 |
|
| 564 |
result = SDL_round(-INFINITY); |
| 565 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 566 |
"Round(%f), expected %f, got %f", |
| 567 |
-INFINITY, -INFINITY, result); |
| 568 |
|
| 569 |
return TEST_COMPLETED; |
| 570 |
} |
| 571 |
|
| 572 |
/** |
| 573 |
* Inputs: +/-0.0. |
| 574 |
* Expected: Zero is returned as-is. |
| 575 |
*/ |
| 576 |
static int |
| 577 |
round_zeroCases(void *args) |
| 578 |
{ |
| 579 |
const d_to_d zero_cases[] = { |
| 580 |
{ 0.0, 0.0 }, |
| 581 |
{ -0.0, -0.0 } |
| 582 |
}; |
| 583 |
return helper_dtod("Round", SDL_round, zero_cases, SDL_arraysize(zero_cases)); |
| 584 |
} |
| 585 |
|
| 586 |
/** |
| 587 |
* Input: NAN. |
| 588 |
* Expected: NAN is returned. |
| 589 |
*/ |
| 590 |
static int |
| 591 |
round_nanCase(void *args) |
| 592 |
{ |
| 593 |
const double result = SDL_round(NAN); |
| 594 |
SDLTest_AssertCheck(isnan(result), |
| 595 |
"Round(nan), expected nan, got %f", |
| 596 |
result); |
| 597 |
return TEST_COMPLETED; |
| 598 |
} |
| 599 |
|
| 600 |
/** |
| 601 |
* Inputs: integral values. |
| 602 |
* Expected: the input value is returned as-is. |
| 603 |
*/ |
| 604 |
static int |
| 605 |
round_roundNumbersCases(void *args) |
| 606 |
{ |
| 607 |
const d_to_d round_cases[] = { |
| 608 |
{ 1.0, 1.0 }, |
| 609 |
{ -1.0, -1.0 }, |
| 610 |
{ 15.0, 15.0 }, |
| 611 |
{ -15.0, -15.0 }, |
| 612 |
{ 125.0, 125.0 }, |
| 613 |
{ -125.0, -125.0 }, |
| 614 |
{ 1024.0, 1024.0 }, |
| 615 |
{ -1024.0, -1024.0 } |
| 616 |
}; |
| 617 |
return helper_dtod("Round", SDL_round, round_cases, SDL_arraysize(round_cases)); |
| 618 |
} |
| 619 |
|
| 620 |
/** |
| 621 |
* Inputs: fractional values. |
| 622 |
* Expected: the nearest integral value is returned. |
| 623 |
*/ |
| 624 |
static int |
| 625 |
round_fractionCases(void *args) |
| 626 |
{ |
| 627 |
const d_to_d frac_cases[] = { |
| 628 |
{ 1.0 / 2.0, 1.0 }, |
| 629 |
{ -1.0 / 2.0, -1.0 }, |
| 630 |
{ 4.0 / 3.0, 1.0 }, |
| 631 |
{ -4.0 / 3.0, -1.0 }, |
| 632 |
{ 76.0 / 7.0, 11.0 }, |
| 633 |
{ -76.0 / 7.0, -11.0 }, |
| 634 |
{ 535.0 / 8.0, 67.0 }, |
| 635 |
{ -535.0 / 8.0, -67.0 }, |
| 636 |
{ 19357.0 / 53.0, 365.0 }, |
| 637 |
{ -19357.0 / 53.0, -365.0 } |
| 638 |
}; |
| 639 |
return helper_dtod("Round", SDL_round, frac_cases, SDL_arraysize(frac_cases)); |
| 640 |
} |
| 641 |
|
| 642 |
/** |
| 643 |
* Inputs: values in the range [0, UINT32_MAX]. |
| 644 |
* Expected: the input value is returned as-is. |
| 645 |
*/ |
| 646 |
static int |
| 647 |
round_rangeTest(void *args) |
| 648 |
{ |
| 649 |
return helper_range("Round", SDL_round); |
| 650 |
} |
| 651 |
|
| 652 |
/* SDL_fabs tests functions */ |
| 653 |
|
| 654 |
/** |
| 655 |
* Inputs: +/-Infinity. |
| 656 |
* Expected: Positive Infinity is returned. |
| 657 |
*/ |
| 658 |
static int |
| 659 |
fabs_infCases(void *args) |
| 660 |
{ |
| 661 |
double result; |
| 662 |
|
| 663 |
result = SDL_fabs(INFINITY); |
| 664 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 665 |
"Fabs(%f), expected %f, got %f", |
| 666 |
INFINITY, INFINITY, result); |
| 667 |
|
| 668 |
result = SDL_fabs(-INFINITY); |
| 669 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 670 |
"Fabs(%f), expected %f, got %f", |
| 671 |
-INFINITY, INFINITY, result); |
| 672 |
|
| 673 |
return TEST_COMPLETED; |
| 674 |
} |
| 675 |
|
| 676 |
/** |
| 677 |
* Inputs: +/-0.0. |
| 678 |
* Expected: Positive zero is returned. |
| 679 |
*/ |
| 680 |
static int |
| 681 |
fabs_zeroCases(void *args) |
| 682 |
{ |
| 683 |
const d_to_d zero_cases[] = { |
| 684 |
{ 0.0, 0.0 }, |
| 685 |
{ -0.0, 0.0 } |
| 686 |
}; |
| 687 |
return helper_dtod("Fabs", SDL_fabs, zero_cases, SDL_arraysize(zero_cases)); |
| 688 |
} |
| 689 |
|
| 690 |
/** |
| 691 |
* Input: NAN. |
| 692 |
* Expected: NAN is returned. |
| 693 |
*/ |
| 694 |
static int |
| 695 |
fabs_nanCase(void *args) |
| 696 |
{ |
| 697 |
const double result = SDL_fabs(NAN); |
| 698 |
SDLTest_AssertCheck(isnan(result), |
| 699 |
"Fabs(nan), expected nan, got %f", |
| 700 |
result); |
| 701 |
return TEST_COMPLETED; |
| 702 |
} |
| 703 |
|
| 704 |
/** |
| 705 |
* Inputs: values in the range [0, UINT32_MAX]. |
| 706 |
* Expected: the input value is returned as-is. |
| 707 |
*/ |
| 708 |
static int |
| 709 |
fabs_rangeTest(void *args) |
| 710 |
{ |
| 711 |
return helper_range("Fabs", SDL_fabs); |
| 712 |
} |
| 713 |
|
| 714 |
/* SDL_copysign tests functions */ |
| 715 |
|
| 716 |
/** |
| 717 |
* Inputs: (+/-Infinity, +/-1.0). |
| 718 |
* Expected: Infinity with the sign of 1.0 is returned. |
| 719 |
*/ |
| 720 |
static int |
| 721 |
copysign_infCases(void *args) |
| 722 |
{ |
| 723 |
double result; |
| 724 |
|
| 725 |
result = SDL_copysign(INFINITY, -1.0); |
| 726 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 727 |
"Copysign(%f,%.1f), expected %f, got %f", |
| 728 |
INFINITY, -1.0, -INFINITY, result); |
| 729 |
|
| 730 |
result = SDL_copysign(INFINITY, 1.0); |
| 731 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 732 |
"Copysign(%f,%.1f), expected %f, got %f", |
| 733 |
INFINITY, 1.0, INFINITY, result); |
| 734 |
|
| 735 |
result = SDL_copysign(-INFINITY, -1.0); |
| 736 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 737 |
"Copysign(%f,%.1f), expected %f, got %f", |
| 738 |
-INFINITY, -1.0, -INFINITY, result); |
| 739 |
|
| 740 |
result = SDL_copysign(-INFINITY, 1.0); |
| 741 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 742 |
"Copysign(%f,%.1f), expected %f, got %f", |
| 743 |
-INFINITY, 1.0, INFINITY, result); |
| 744 |
|
| 745 |
return TEST_COMPLETED; |
| 746 |
} |
| 747 |
|
| 748 |
/** |
| 749 |
* Inputs: (+/-0.0, +/-1.0). |
| 750 |
* Expected: 0.0 with the sign of 1.0 is returned. |
| 751 |
*/ |
| 752 |
static int |
| 753 |
copysign_zeroCases(void *args) |
| 754 |
{ |
| 755 |
const dd_to_d zero_cases[] = { |
| 756 |
{ 0.0, 1.0, 0.0 }, |
| 757 |
{ 0.0, -1.0, -0.0 }, |
| 758 |
{ -0.0, 1.0, 0.0 }, |
| 759 |
{ -0.0, -1.0, -0.0 } |
| 760 |
}; |
| 761 |
return helper_ddtod("Copysign", SDL_copysign, zero_cases, SDL_arraysize(zero_cases)); |
| 762 |
} |
| 763 |
|
| 764 |
/** |
| 765 |
* Inputs: (NAN, +/-1.0). |
| 766 |
* Expected: NAN with the sign of 1.0 is returned. |
| 767 |
* NOTE: On some platforms signed NAN is not supported, so we only check if the result is still NAN. |
| 768 |
*/ |
| 769 |
static int |
| 770 |
copysign_nanCases(void *args) |
| 771 |
{ |
| 772 |
double result; |
| 773 |
|
| 774 |
result = SDL_copysign(NAN, 1.0); |
| 775 |
SDLTest_AssertCheck(isnan(result), |
| 776 |
"Copysign(nan,1.0), expected nan, got %f", |
| 777 |
result); |
| 778 |
|
| 779 |
result = SDL_copysign(NAN, -1.0); |
| 780 |
SDLTest_AssertCheck(isnan(result), |
| 781 |
"Copysign(nan,-1.0), expected nan, got %f", |
| 782 |
result); |
| 783 |
return TEST_COMPLETED; |
| 784 |
} |
| 785 |
|
| 786 |
/** |
| 787 |
* Inputs: values in the range [0, UINT32_MAX], +/-1.0. |
| 788 |
* Expected: the input value with the sign of 1.0 is returned. |
| 789 |
*/ |
| 790 |
static int |
| 791 |
copysign_rangeTest(void *args) |
| 792 |
{ |
| 793 |
Uint32 i; |
| 794 |
double test_value = 0.0; |
| 795 |
|
| 796 |
SDLTest_AssertPass("Copysign: Testing a range of %u values with steps of %" SDL_PRIu32, |
| 797 |
RANGE_TEST_ITERATIONS, |
| 798 |
RANGE_TEST_STEP); |
| 799 |
|
| 800 |
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { |
| 801 |
double result; |
| 802 |
/* These are tested elsewhere */ |
| 803 |
if (isnan(test_value) || isinf(test_value)) { |
| 804 |
continue; |
| 805 |
} |
| 806 |
|
| 807 |
/* Only log failures to save performances */ |
| 808 |
result = SDL_copysign(test_value, 1.0); |
| 809 |
if (result != test_value) { |
| 810 |
SDLTest_AssertCheck(SDL_FALSE, |
| 811 |
"Copysign(%.1f,%.1f), expected %.1f, got %.1f", |
| 812 |
test_value, 1.0, test_value, result); |
| 813 |
return TEST_ABORTED; |
| 814 |
} |
| 815 |
|
| 816 |
result = SDL_copysign(test_value, -1.0); |
| 817 |
if (result != -test_value) { |
| 818 |
SDLTest_AssertCheck(SDL_FALSE, |
| 819 |
"Copysign(%.1f,%.1f), expected %.1f, got %.1f", |
| 820 |
test_value, -1.0, -test_value, result); |
| 821 |
return TEST_ABORTED; |
| 822 |
} |
| 823 |
} |
| 824 |
return TEST_COMPLETED; |
| 825 |
} |
| 826 |
|
| 827 |
/* SDL_fmod tests functions */ |
| 828 |
|
| 829 |
/** |
| 830 |
* Inputs: (+/-Infinity, +/-1.0). |
| 831 |
* Expected: NAN is returned. |
| 832 |
*/ |
| 833 |
static int |
| 834 |
fmod_divOfInfCases(void *args) |
| 835 |
{ |
| 836 |
double result; |
| 837 |
|
| 838 |
result = SDL_fmod(INFINITY, -1.0); |
| 839 |
SDLTest_AssertCheck(isnan(result), |
| 840 |
"Fmod(%f,%.1f), expected %f, got %f", |
| 841 |
INFINITY, -1.0, NAN, result); |
| 842 |
|
| 843 |
result = SDL_fmod(INFINITY, 1.0); |
| 844 |
SDLTest_AssertCheck(isnan(result), |
| 845 |
"Fmod(%f,%.1f), expected %f, got %f", |
| 846 |
INFINITY, 1.0, NAN, result); |
| 847 |
|
| 848 |
result = SDL_fmod(-INFINITY, -1.0); |
| 849 |
SDLTest_AssertCheck(isnan(result), |
| 850 |
"Fmod(%f,%.1f), expected %f, got %f", |
| 851 |
-INFINITY, -1.0, NAN, result); |
| 852 |
|
| 853 |
result = SDL_fmod(-INFINITY, 1.0); |
| 854 |
SDLTest_AssertCheck(isnan(result), |
| 855 |
"Fmod(%f,%.1f), expected %f, got %f", |
| 856 |
-INFINITY, 1.0, NAN, result); |
| 857 |
|
| 858 |
return TEST_COMPLETED; |
| 859 |
} |
| 860 |
|
| 861 |
/** |
| 862 |
* Inputs: (+/-1.0, +/-Infinity). |
| 863 |
* Expected: 1.0 is returned as-is. |
| 864 |
*/ |
| 865 |
static int |
| 866 |
fmod_divByInfCases(void *args) |
| 867 |
{ |
| 868 |
double result; |
| 869 |
|
| 870 |
result = SDL_fmod(1.0, INFINITY); |
| 871 |
SDLTest_AssertCheck(1.0 == result, |
| 872 |
"Fmod(%.1f,%f), expected %f, got %f", |
| 873 |
1.0, INFINITY, 1.0, result); |
| 874 |
|
| 875 |
result = SDL_fmod(-1.0, INFINITY); |
| 876 |
SDLTest_AssertCheck(-1.0 == result, |
| 877 |
"Fmod(%.1f,%f), expected %f, got %f", |
| 878 |
-1.0, INFINITY, -1.0, result); |
| 879 |
|
| 880 |
result = SDL_fmod(1.0, -INFINITY); |
| 881 |
SDLTest_AssertCheck(1.0 == result, |
| 882 |
"Fmod(%.1f,%f), expected %f, got %f", |
| 883 |
1.0, -INFINITY, 1.0, result); |
| 884 |
|
| 885 |
result = SDL_fmod(-1.0, -INFINITY); |
| 886 |
SDLTest_AssertCheck(-1.0 == result, |
| 887 |
"Fmod(%.1f,%f), expected %f, got %f", |
| 888 |
-1.0, -INFINITY, -1.0, result); |
| 889 |
|
| 890 |
return TEST_COMPLETED; |
| 891 |
} |
| 892 |
|
| 893 |
/** |
| 894 |
* Inputs: (+/-0.0, +/-1.0). |
| 895 |
* Expected: Zero is returned as-is. |
| 896 |
*/ |
| 897 |
static int |
| 898 |
fmod_divOfZeroCases(void *args) |
| 899 |
{ |
| 900 |
const dd_to_d zero_cases[] = { |
| 901 |
{ 0.0, 1.0, 0.0 }, |
| 902 |
{ 0.0, -1.0, 0.0 }, |
| 903 |
{ -0.0, 1.0, -0.0 }, |
| 904 |
{ -0.0, -1.0, -0.0 } |
| 905 |
}; |
| 906 |
return helper_ddtod("Fmod", SDL_fmod, zero_cases, SDL_arraysize(zero_cases)); |
| 907 |
} |
| 908 |
|
| 909 |
/** |
| 910 |
* Inputs: (+/-1.0, +/-0.0). |
| 911 |
* Expected: NAN is returned. |
| 912 |
*/ |
| 913 |
static int |
| 914 |
fmod_divByZeroCases(void *args) |
| 915 |
{ |
| 916 |
double result; |
| 917 |
|
| 918 |
result = SDL_fmod(1.0, 0.0); |
| 919 |
SDLTest_AssertCheck(isnan(result), |
| 920 |
"Fmod(1.0,0.0), expected nan, got %f", |
| 921 |
result); |
| 922 |
|
| 923 |
result = SDL_fmod(-1.0, 0.0); |
| 924 |
SDLTest_AssertCheck(isnan(result), |
| 925 |
"Fmod(-1.0,0.0), expected nan, got %f", |
| 926 |
result); |
| 927 |
|
| 928 |
result = SDL_fmod(1.0, -0.0); |
| 929 |
SDLTest_AssertCheck(isnan(result), |
| 930 |
"Fmod(1.0,-0.0), expected nan, got %f", |
| 931 |
result); |
| 932 |
|
| 933 |
result = SDL_fmod(-1.0, -0.0); |
| 934 |
SDLTest_AssertCheck(isnan(result), |
| 935 |
"Fmod(-1.0,-0.0), expected nan, got %f", |
| 936 |
result); |
| 937 |
|
| 938 |
return TEST_COMPLETED; |
| 939 |
} |
| 940 |
|
| 941 |
/** |
| 942 |
* Inputs: all permutation of NAN and +/-1.0. |
| 943 |
* Expected: NAN is returned. |
| 944 |
*/ |
| 945 |
static int |
| 946 |
fmod_nanCases(void *args) |
| 947 |
{ |
| 948 |
double result; |
| 949 |
|
| 950 |
result = SDL_fmod(NAN, 1.0); |
| 951 |
SDLTest_AssertCheck(isnan(result), |
| 952 |
"Fmod(nan,1.0), expected nan, got %f", |
| 953 |
result); |
| 954 |
|
| 955 |
result = SDL_fmod(NAN, -1.0); |
| 956 |
SDLTest_AssertCheck(isnan(result), |
| 957 |
"Fmod(nan,-1.0), expected nan, got %f", |
| 958 |
result); |
| 959 |
|
| 960 |
result = SDL_fmod(1.0, NAN); |
| 961 |
SDLTest_AssertCheck(isnan(result), |
| 962 |
"Fmod(1.0,nan), expected nan, got %f", |
| 963 |
result); |
| 964 |
|
| 965 |
result = SDL_fmod(-1.0, NAN); |
| 966 |
SDLTest_AssertCheck(isnan(result), |
| 967 |
"Fmod(-1.0,nan), expected nan, got %f", |
| 968 |
result); |
| 969 |
|
| 970 |
return TEST_COMPLETED; |
| 971 |
} |
| 972 |
|
| 973 |
/** |
| 974 |
* Inputs: values within the domain of the function. |
| 975 |
* Expected: the correct result is returned. |
| 976 |
*/ |
| 977 |
static int |
| 978 |
fmod_regularCases(void *args) |
| 979 |
{ |
| 980 |
const dd_to_d regular_cases[] = { |
| 981 |
{ 3.5, 2.0, 1.5 }, |
| 982 |
{ -6.25, 3.0, -0.25 }, |
| 983 |
{ 7.5, 2.5, 0.0 }, |
| 984 |
{ 2.0 / 3.0, -1.0 / 3.0, 0.0 } |
| 985 |
}; |
| 986 |
return helper_ddtod("Fmod", SDL_fmod, regular_cases, SDL_arraysize(regular_cases)); |
| 987 |
} |
| 988 |
|
| 989 |
/** |
| 990 |
* Inputs: values in the range [0, UINT32_MAX] divided by 1.0. |
| 991 |
* Expected: Positive zero is always returned. |
| 992 |
*/ |
| 993 |
static int |
| 994 |
fmod_rangeTest(void *args) |
| 995 |
{ |
| 996 |
Uint32 i; |
| 997 |
double test_value = 0.0; |
| 998 |
|
| 999 |
SDLTest_AssertPass("Fmod: Testing a range of %u values with steps of %" SDL_PRIu32, |
| 1000 |
RANGE_TEST_ITERATIONS, |
| 1001 |
RANGE_TEST_STEP); |
| 1002 |
|
| 1003 |
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { |
| 1004 |
double result; |
| 1005 |
/* These are tested elsewhere */ |
| 1006 |
if (isnan(test_value) || isinf(test_value)) { |
| 1007 |
continue; |
| 1008 |
} |
| 1009 |
|
| 1010 |
/* Only log failures to save performances */ |
| 1011 |
result = SDL_fmod(test_value, 1.0); |
| 1012 |
if (0.0 != result) { |
| 1013 |
SDLTest_AssertCheck(SDL_FALSE, |
| 1014 |
"Fmod(%.1f,%.1f), expected %.1f, got %.1f", |
| 1015 |
test_value, 1.0, 0.0, result); |
| 1016 |
return TEST_ABORTED; |
| 1017 |
} |
| 1018 |
} |
| 1019 |
return TEST_COMPLETED; |
| 1020 |
} |
| 1021 |
|
| 1022 |
/* SDL_exp tests functions */ |
| 1023 |
|
| 1024 |
/** |
| 1025 |
* Inputs: +/-Infinity. |
| 1026 |
* Expected: Infinity is returned as-is. |
| 1027 |
*/ |
| 1028 |
static int |
| 1029 |
exp_infCases(void *args) |
| 1030 |
{ |
| 1031 |
double result; |
| 1032 |
|
| 1033 |
result = SDL_exp(INFINITY); |
| 1034 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1035 |
"Exp(%f), expected %f, got %f", |
| 1036 |
INFINITY, INFINITY, result); |
| 1037 |
|
| 1038 |
result = SDL_exp(-INFINITY); |
| 1039 |
SDLTest_AssertCheck(0.0 == result, |
| 1040 |
"Exp(%f), expected %f, got %f", |
| 1041 |
-INFINITY, 0.0, result); |
| 1042 |
|
| 1043 |
return TEST_COMPLETED; |
| 1044 |
} |
| 1045 |
|
| 1046 |
/** |
| 1047 |
* Inputs: +/-0.0. |
| 1048 |
* Expected: 1.0 is returned. |
| 1049 |
*/ |
| 1050 |
static int |
| 1051 |
exp_zeroCases(void *args) |
| 1052 |
{ |
| 1053 |
const d_to_d zero_cases[] = { |
| 1054 |
{ 0.0, 1.0 }, |
| 1055 |
{ -0.0, 1.0 } |
| 1056 |
}; |
| 1057 |
return helper_dtod("Exp", SDL_exp, zero_cases, SDL_arraysize(zero_cases)); |
| 1058 |
} |
| 1059 |
|
| 1060 |
/** |
| 1061 |
* Input: 710.0 (overflows for 64bits double). |
| 1062 |
* Expected: Infinity is returned. |
| 1063 |
* NOTE: This test is skipped for double types larger than 64 bits. |
| 1064 |
*/ |
| 1065 |
static int |
| 1066 |
exp_overflowCase(void *args) |
| 1067 |
{ |
| 1068 |
double result; |
| 1069 |
|
| 1070 |
if (sizeof(double) > 8) { |
| 1071 |
return TEST_SKIPPED; |
| 1072 |
} |
| 1073 |
|
| 1074 |
result = SDL_exp(710.0); |
| 1075 |
SDLTest_AssertCheck(isinf(result), |
| 1076 |
"Exp(%f), expected %f, got %f", |
| 1077 |
710.0, INFINITY, result); |
| 1078 |
return TEST_COMPLETED; |
| 1079 |
} |
| 1080 |
|
| 1081 |
/** |
| 1082 |
* Input: 1.0 |
| 1083 |
* Expected: The euler constant. |
| 1084 |
*/ |
| 1085 |
static int |
| 1086 |
exp_baseCase(void *args) |
| 1087 |
{ |
| 1088 |
const double result = SDL_exp(1.0); |
| 1089 |
SDLTest_AssertCheck(result >= EULER - EPSILON && |
| 1090 |
result <= EULER + EPSILON, |
| 1091 |
"Exp(%f), expected [%f,%f], got %f", |
| 1092 |
1.0, EULER - EPSILON, EULER + EPSILON, result); |
| 1093 |
return TEST_COMPLETED; |
| 1094 |
} |
| 1095 |
|
| 1096 |
/** |
| 1097 |
* Inputs: values within the domain of the function. |
| 1098 |
* Expected: the correct result is returned. |
| 1099 |
*/ |
| 1100 |
static int |
| 1101 |
exp_regularCases(void *args) |
| 1102 |
{ |
| 1103 |
/* Hexadecimal floating constants are not supported on C89 compilers */ |
| 1104 |
const d_to_d regular_cases[] = { |
| 1105 |
{ -101.0, 1.36853947117385291381565719268793547578002532127613087E-44 }, |
| 1106 |
{ -15.73, 0.00000014741707833928422931856502906683425990763681 }, |
| 1107 |
{ -1.0, 0.36787944117144233402427744294982403516769409179688 }, |
| 1108 |
{ -0.5, 0.60653065971263342426311737654032185673713684082031 }, |
| 1109 |
{ 0.5, 1.64872127070012819416433558217249810695648193359375 }, |
| 1110 |
{ 2.25, 9.48773583635852624240669683786109089851379394531250 }, |
| 1111 |
{ 34.125, 661148770968660.375 }, |
| 1112 |
{ 112.89, 10653788283588960962604279261058893737879589093376.0 }, |
| 1113 |
{ 539.483, 1970107755334319939701129934673541628417235942656909222826926175622435588279443011110464355295725187195188154768877850257012251677751742837992843520967922303961718983154427294786640886286983037548604937796221048661733679844353544028160.0 }, |
| 1114 |
}; |
| 1115 |
return helper_dtod_inexact("Exp", SDL_exp, regular_cases, SDL_arraysize(regular_cases)); |
| 1116 |
} |
| 1117 |
|
| 1118 |
/* SDL_log tests functions */ |
| 1119 |
|
| 1120 |
/** |
| 1121 |
* Inputs: Positive Infinity and +/-0.0. |
| 1122 |
* Expected: Positive and negative Infinity respectively. |
| 1123 |
*/ |
| 1124 |
static int |
| 1125 |
log_limitCases(void *args) |
| 1126 |
{ |
| 1127 |
double result; |
| 1128 |
|
| 1129 |
result = SDL_log(INFINITY); |
| 1130 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1131 |
"Log(%f), expected %f, got %f", |
| 1132 |
INFINITY, INFINITY, result); |
| 1133 |
|
| 1134 |
result = SDL_log(0.0); |
| 1135 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 1136 |
"Log(%f), expected %f, got %f", |
| 1137 |
0.0, -INFINITY, result); |
| 1138 |
|
| 1139 |
result = SDL_log(-0.0); |
| 1140 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 1141 |
"Log(%f), expected %f, got %f", |
| 1142 |
-0.0, -INFINITY, result); |
| 1143 |
|
| 1144 |
return TEST_COMPLETED; |
| 1145 |
} |
| 1146 |
|
| 1147 |
/** |
| 1148 |
* Inputs: 1.0 and the Euler constant. |
| 1149 |
* Expected: 0.0 and 1.0 respectively. |
| 1150 |
*/ |
| 1151 |
static int |
| 1152 |
log_baseCases(void *args) |
| 1153 |
{ |
| 1154 |
double result; |
| 1155 |
|
| 1156 |
result = SDL_log(1.0); |
| 1157 |
SDLTest_AssertCheck(0.0 == result, |
| 1158 |
"Log(%f), expected %f, got %f", |
| 1159 |
1.0, 0.0, result); |
| 1160 |
|
| 1161 |
result = SDL_log(EULER); |
| 1162 |
SDLTest_AssertCheck(SDL_fabs(result - 1.) < FLT_EPSILON, |
| 1163 |
"Log(%f), expected %f, got %f", |
| 1164 |
EULER, 1.0, result); |
| 1165 |
|
| 1166 |
return TEST_COMPLETED; |
| 1167 |
} |
| 1168 |
|
| 1169 |
/** |
| 1170 |
* Inputs: NAN and a negative value. |
| 1171 |
* Expected: NAN is returned. |
| 1172 |
*/ |
| 1173 |
static int |
| 1174 |
log_nanCases(void *args) |
| 1175 |
{ |
| 1176 |
double result; |
| 1177 |
|
| 1178 |
result = SDL_log(NAN); |
| 1179 |
SDLTest_AssertCheck(isnan(result), |
| 1180 |
"Log(%f), expected %f, got %f", |
| 1181 |
NAN, NAN, result); |
| 1182 |
|
| 1183 |
result = SDL_log(-1234.5678); |
| 1184 |
SDLTest_AssertCheck(isnan(result), |
| 1185 |
"Log(%f), expected %f, got %f", |
| 1186 |
-1234.5678, NAN, result); |
| 1187 |
|
| 1188 |
return TEST_COMPLETED; |
| 1189 |
} |
| 1190 |
|
| 1191 |
/** |
| 1192 |
* Inputs: values within the domain of the function. |
| 1193 |
* Expected: the correct result is returned. |
| 1194 |
*/ |
| 1195 |
static int |
| 1196 |
log_regularCases(void *args) |
| 1197 |
{ |
| 1198 |
const d_to_d regular_cases[] = { |
| 1199 |
{ 5.0, 1.60943791243410028179994242236716672778129577636718750 }, |
| 1200 |
{ 10.0, 2.302585092994045901093613792909309267997741699218750 }, |
| 1201 |
{ 56.32, 4.031049711849786554296315443934872746467590332031250 }, |
| 1202 |
{ 789.123, 6.670922202231861497523368598194792866706848144531250 }, |
| 1203 |
{ 2734.876324, 7.91384149408957959792587644187733530998229980468750 } |
| 1204 |
}; |
| 1205 |
return helper_dtod("Log", SDL_log, regular_cases, SDL_arraysize(regular_cases)); |
| 1206 |
} |
| 1207 |
|
| 1208 |
/* SDL_log10 tests functions */ |
| 1209 |
|
| 1210 |
/** |
| 1211 |
* Inputs: Positive Infinity and +/-0.0. |
| 1212 |
* Expected: Positive and negative Infinity respectively. |
| 1213 |
*/ |
| 1214 |
static int |
| 1215 |
log10_limitCases(void *args) |
| 1216 |
{ |
| 1217 |
double result; |
| 1218 |
|
| 1219 |
result = SDL_log10(INFINITY); |
| 1220 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1221 |
"Log10(%f), expected %f, got %f", |
| 1222 |
INFINITY, INFINITY, result); |
| 1223 |
|
| 1224 |
result = SDL_log10(0.0); |
| 1225 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 1226 |
"Log10(%f), expected %f, got %f", |
| 1227 |
0.0, -INFINITY, result); |
| 1228 |
|
| 1229 |
result = SDL_log10(-0.0); |
| 1230 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 1231 |
"Log10(%f), expected %f, got %f", |
| 1232 |
-0.0, -INFINITY, result); |
| 1233 |
|
| 1234 |
return TEST_COMPLETED; |
| 1235 |
} |
| 1236 |
|
| 1237 |
/** |
| 1238 |
* Inputs: Powers of ten from 0 to 9. |
| 1239 |
* Expected: the exact power of ten is returned. |
| 1240 |
*/ |
| 1241 |
static int |
| 1242 |
log10_baseCases(void *args) |
| 1243 |
{ |
| 1244 |
const d_to_d base_cases[] = { |
| 1245 |
{ 1.0, 0.0 }, |
| 1246 |
{ 10.0, 1.0 }, |
| 1247 |
{ 100.0, 2.0 }, |
| 1248 |
{ 1000.0, 3.0 }, |
| 1249 |
{ 10000.0, 4.0 }, |
| 1250 |
{ 100000.0, 5.0 }, |
| 1251 |
{ 1000000.0, 6.0 }, |
| 1252 |
{ 10000000.0, 7.0 }, |
| 1253 |
{ 100000000.0, 8.0 }, |
| 1254 |
{ 1000000000.0, 9.0 }, |
| 1255 |
}; |
| 1256 |
return helper_dtod("Log10", SDL_log10, base_cases, SDL_arraysize(base_cases)); |
| 1257 |
} |
| 1258 |
|
| 1259 |
/** |
| 1260 |
* Inputs: NAN and a negative value. |
| 1261 |
* Expected: NAN is returned. |
| 1262 |
*/ |
| 1263 |
static int |
| 1264 |
log10_nanCases(void *args) |
| 1265 |
{ |
| 1266 |
double result; |
| 1267 |
|
| 1268 |
result = SDL_log10(NAN); |
| 1269 |
SDLTest_AssertCheck(isnan(result), |
| 1270 |
"Log10(%f), expected %f, got %f", |
| 1271 |
NAN, NAN, result); |
| 1272 |
|
| 1273 |
result = SDL_log10(-1234.5678); |
| 1274 |
SDLTest_AssertCheck(isnan(result), |
| 1275 |
"Log10(%f), expected %f, got %f", |
| 1276 |
-1234.5678, NAN, result); |
| 1277 |
|
| 1278 |
return TEST_COMPLETED; |
| 1279 |
} |
| 1280 |
|
| 1281 |
/** |
| 1282 |
* Inputs: values within the domain of the function. |
| 1283 |
* Expected: the correct result is returned. |
| 1284 |
*/ |
| 1285 |
static int |
| 1286 |
log10_regularCases(void *args) |
| 1287 |
{ |
| 1288 |
const d_to_d regular_cases[] = { |
| 1289 |
{ 5.0, 0.698970004336018857493684208748163655400276184082031250 }, |
| 1290 |
{ 12.5, 1.09691001300805646145875016372883692383766174316406250 }, |
| 1291 |
{ 56.32, 1.750662646134055755453573510749265551567077636718750 }, |
| 1292 |
{ 789.123, 2.8971447016351858927407647570362314581871032714843750 }, |
| 1293 |
{ 2734.876324, 3.436937691540090433761633903486654162406921386718750 } |
| 1294 |
}; |
| 1295 |
return helper_dtod_inexact("Log10", SDL_log10, regular_cases, SDL_arraysize(regular_cases)); |
| 1296 |
} |
| 1297 |
|
| 1298 |
/* SDL_pow tests functions */ |
| 1299 |
|
| 1300 |
/* Tests with positive and negative infinities as exponents */ |
| 1301 |
|
| 1302 |
/** |
| 1303 |
* Inputs: (-1.0, +/-Infinity). |
| 1304 |
* Expected: 1.0 is returned. |
| 1305 |
*/ |
| 1306 |
static int |
| 1307 |
pow_baseNOneExpInfCases(void *args) |
| 1308 |
{ |
| 1309 |
double result; |
| 1310 |
|
| 1311 |
result = SDL_pow(-1.0, INFINITY); |
| 1312 |
SDLTest_AssertCheck(1.0 == result, |
| 1313 |
"Pow(%f,%f), expected %f, got %f", |
| 1314 |
-1.0, INFINITY, 1.0, result); |
| 1315 |
|
| 1316 |
result = SDL_pow(-1.0, -INFINITY); |
| 1317 |
SDLTest_AssertCheck(1.0 == result, |
| 1318 |
"Pow(%f,%f), expected %f, got %f", |
| 1319 |
-1.0, -INFINITY, 1.0, result); |
| 1320 |
|
| 1321 |
return TEST_COMPLETED; |
| 1322 |
} |
| 1323 |
/** |
| 1324 |
* Inputs: (+/-0.0, -Infinity). |
| 1325 |
* Expected: Infinity is returned. |
| 1326 |
*/ |
| 1327 |
static int |
| 1328 |
pow_baseZeroExpNInfCases(void *args) |
| 1329 |
{ |
| 1330 |
double result; |
| 1331 |
|
| 1332 |
result = SDL_pow(0.0, -INFINITY); |
| 1333 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1334 |
"Pow(%f,%f), expected %f, got %f", |
| 1335 |
0.0, -INFINITY, INFINITY, result); |
| 1336 |
|
| 1337 |
result = SDL_pow(-0.0, -INFINITY); |
| 1338 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1339 |
"Pow(%f,%f), expected %f, got %f", |
| 1340 |
-0.0, -INFINITY, INFINITY, result); |
| 1341 |
|
| 1342 |
return TEST_COMPLETED; |
| 1343 |
} |
| 1344 |
|
| 1345 |
/** |
| 1346 |
* Inputs: (x, +/-Infinity) where x is not +/-0.0. |
| 1347 |
* Expected: 0.0 when x < 1, Infinity when x > 1. |
| 1348 |
*/ |
| 1349 |
static int |
| 1350 |
pow_expInfCases(void *args) |
| 1351 |
{ |
| 1352 |
double result; |
| 1353 |
|
| 1354 |
result = SDL_pow(0.5, INFINITY); |
| 1355 |
SDLTest_AssertCheck(0.0 == result, |
| 1356 |
"Pow(%f,%f), expected %f, got %f", |
| 1357 |
0.5, INFINITY, 0.0, result); |
| 1358 |
|
| 1359 |
result = SDL_pow(1.5, INFINITY); |
| 1360 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1361 |
"Pow(%f,%f), expected %f, got %f", |
| 1362 |
1.5, INFINITY, INFINITY, result); |
| 1363 |
|
| 1364 |
result = SDL_pow(0.5, -INFINITY); |
| 1365 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1366 |
"Pow(%f,%f), expected %f, got %f", |
| 1367 |
0.5, INFINITY, INFINITY, result); |
| 1368 |
|
| 1369 |
result = SDL_pow(1.5, -INFINITY); |
| 1370 |
SDLTest_AssertCheck(0.0 == result, |
| 1371 |
"Pow(%f,%f), expected %f, got %f", |
| 1372 |
1.5, -INFINITY, 0.0, result); |
| 1373 |
|
| 1374 |
return TEST_COMPLETED; |
| 1375 |
} |
| 1376 |
|
| 1377 |
/* Tests with positive and negative infinities as base */ |
| 1378 |
|
| 1379 |
/** |
| 1380 |
* Inputs: (Positive Infinity, x) where x is not +/-0.0. |
| 1381 |
* Expected: 0.0 when x is < 0, positive Infinity when x > 0. |
| 1382 |
*/ |
| 1383 |
static int |
| 1384 |
pow_basePInfCases(void *args) |
| 1385 |
{ |
| 1386 |
double result; |
| 1387 |
|
| 1388 |
result = SDL_pow(INFINITY, -3.0); |
| 1389 |
SDLTest_AssertCheck(0.0 == result, |
| 1390 |
"Pow(%f,%f), expected %f, got %f", |
| 1391 |
INFINITY, -3.0, 0.0, result); |
| 1392 |
|
| 1393 |
result = SDL_pow(INFINITY, 2.0); |
| 1394 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1395 |
"Pow(%f,%f), expected %f, got %f", |
| 1396 |
INFINITY, 2.0, INFINITY, result); |
| 1397 |
|
| 1398 |
result = SDL_pow(INFINITY, -2.12345); |
| 1399 |
SDLTest_AssertCheck(0.0 == result, |
| 1400 |
"Pow(%f,%f), expected %f, got %f", |
| 1401 |
INFINITY, -2.12345, 0.0, result); |
| 1402 |
|
| 1403 |
result = SDL_pow(INFINITY, 3.1345); |
| 1404 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1405 |
"Pow(%f,%f), expected %f, got %f", |
| 1406 |
INFINITY, 3.12345, INFINITY, result); |
| 1407 |
|
| 1408 |
return TEST_COMPLETED; |
| 1409 |
} |
| 1410 |
|
| 1411 |
/** |
| 1412 |
* Inputs: (Negative Infinity, x) where x is not +/-0.0. |
| 1413 |
* Expected: |
| 1414 |
* - -0.0 when x is a negative odd integer, |
| 1415 |
* - 0.0 when x is a negative even integer or negative non-integer, |
| 1416 |
* - Negative Infinity when x is a positive odd integer, |
| 1417 |
* - Positive Infinity when x is a positive even integer or positive non-integer. |
| 1418 |
*/ |
| 1419 |
static int |
| 1420 |
pow_baseNInfCases(void *args) |
| 1421 |
{ |
| 1422 |
double result; |
| 1423 |
|
| 1424 |
result = SDL_pow(-INFINITY, -3.0); |
| 1425 |
SDLTest_AssertCheck(-0.0 == result, |
| 1426 |
"Pow(%f,%f), expected %f, got %f", |
| 1427 |
-INFINITY, -3.0, -0.0, result); |
| 1428 |
|
| 1429 |
result = SDL_pow(-INFINITY, -2.0); |
| 1430 |
SDLTest_AssertCheck(0.0 == result, |
| 1431 |
"Pow(%f,%f), expected %f, got %f", |
| 1432 |
-INFINITY, -2.0, 0.0, result); |
| 1433 |
|
| 1434 |
result = SDL_pow(-INFINITY, -5.5); |
| 1435 |
SDLTest_AssertCheck(0.0 == result, |
| 1436 |
"Pow(%f,%f), expected %f, got %f", |
| 1437 |
-INFINITY, -5.5, 0.0, result); |
| 1438 |
|
| 1439 |
result = SDL_pow(-INFINITY, 3.0); |
| 1440 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 1441 |
"Pow(%f,%f), expected %f, got %f", |
| 1442 |
-INFINITY, 3.0, -INFINITY, result); |
| 1443 |
|
| 1444 |
result = SDL_pow(-INFINITY, 2.0); |
| 1445 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1446 |
"Pow(%f,%f), expected %f, got %f", |
| 1447 |
-INFINITY, 2.0, INFINITY, result); |
| 1448 |
|
| 1449 |
result = SDL_pow(-INFINITY, 5.5); |
| 1450 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1451 |
"Pow(%f,%f), expected %f, got %f", |
| 1452 |
-INFINITY, 5.5, INFINITY, result); |
| 1453 |
|
| 1454 |
return TEST_COMPLETED; |
| 1455 |
} |
| 1456 |
|
| 1457 |
/* Tests related to NAN */ |
| 1458 |
|
| 1459 |
/** |
| 1460 |
* Inputs: |
| 1461 |
* - finite and negative base, |
| 1462 |
* - finite and non-integer exponent. |
| 1463 |
* Expected: NAN is returned. |
| 1464 |
*/ |
| 1465 |
static int |
| 1466 |
pow_badOperationCase(void *args) |
| 1467 |
{ |
| 1468 |
const double result = SDL_pow(-2.0, 4.2); |
| 1469 |
SDLTest_AssertCheck(isnan(result), |
| 1470 |
"Pow(%f,%f), expected %f, got %f", |
| 1471 |
-2.0, 4.2, NAN, result); |
| 1472 |
return TEST_COMPLETED; |
| 1473 |
} |
| 1474 |
|
| 1475 |
/** |
| 1476 |
* Inputs: (1.0, NAN) |
| 1477 |
* Expected: 1.0 is returned. |
| 1478 |
*/ |
| 1479 |
static int |
| 1480 |
pow_base1ExpNanCase(void *args) |
| 1481 |
{ |
| 1482 |
const double result = SDL_pow(1.0, NAN); |
| 1483 |
SDLTest_AssertCheck(1.0 == result, |
| 1484 |
"Pow(%f,%f), expected %f, got %f", |
| 1485 |
1.0, NAN, 1.0, result); |
| 1486 |
return TEST_COMPLETED; |
| 1487 |
} |
| 1488 |
|
| 1489 |
/** |
| 1490 |
* Inputs: (NAN, +/-0.0) |
| 1491 |
* Expected: 1.0 is returned. |
| 1492 |
*/ |
| 1493 |
static int |
| 1494 |
pow_baseNanExp0Cases(void *args) |
| 1495 |
{ |
| 1496 |
double result; |
| 1497 |
|
| 1498 |
result = SDL_pow(NAN, 0.0); |
| 1499 |
SDLTest_AssertCheck(1.0 == result, |
| 1500 |
"Pow(%f,%f), expected %f, got %f", |
| 1501 |
NAN, 0.0, 1.0, result); |
| 1502 |
|
| 1503 |
result = SDL_pow(NAN, -0.0); |
| 1504 |
SDLTest_AssertCheck(1.0 == result, |
| 1505 |
"Pow(%f,%f), expected %f, got %f", |
| 1506 |
NAN, -0.0, 1.0, result); |
| 1507 |
|
| 1508 |
return TEST_COMPLETED; |
| 1509 |
} |
| 1510 |
|
| 1511 |
/** |
| 1512 |
* Inputs: NAN as base, exponent or both. |
| 1513 |
* Expected: NAN is returned. |
| 1514 |
*/ |
| 1515 |
static int |
| 1516 |
pow_nanArgsCases(void *args) |
| 1517 |
{ |
| 1518 |
double result; |
| 1519 |
|
| 1520 |
result = SDL_pow(7.8, NAN); |
| 1521 |
SDLTest_AssertCheck(isnan(result), |
| 1522 |
"Pow(%f,%f), expected %f, got %f", |
| 1523 |
7.8, NAN, NAN, result); |
| 1524 |
|
| 1525 |
result = SDL_pow(NAN, 10.0); |
| 1526 |
SDLTest_AssertCheck(isnan(result), |
| 1527 |
"Pow(%f,%f), expected %f, got %f", |
| 1528 |
NAN, 10.0, NAN, result); |
| 1529 |
|
| 1530 |
result = SDL_pow(NAN, NAN); |
| 1531 |
SDLTest_AssertCheck(isnan(result), |
| 1532 |
"Pow(%f,%f), expected %f, got %f", |
| 1533 |
NAN, NAN, NAN, result); |
| 1534 |
|
| 1535 |
return TEST_COMPLETED; |
| 1536 |
} |
| 1537 |
|
| 1538 |
/* Tests with positive and negative zeros as base */ |
| 1539 |
|
| 1540 |
/** |
| 1541 |
* Inputs: (-0.0, x) where x is an odd integer. |
| 1542 |
* Expected: |
| 1543 |
* - Negative Infinity with a negative exponent, |
| 1544 |
* - -0.0 with a positive exponent. |
| 1545 |
*/ |
| 1546 |
static int |
| 1547 |
pow_baseNZeroExpOddCases(void *args) |
| 1548 |
{ |
| 1549 |
double result; |
| 1550 |
|
| 1551 |
result = SDL_pow(-0.0, -3.0); |
| 1552 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 1553 |
"Pow(%f,%f), expected %f, got %f", |
| 1554 |
-0.0, -3.0, -INFINITY, result); |
| 1555 |
|
| 1556 |
result = SDL_pow(-0.0, 3.0); |
| 1557 |
SDLTest_AssertCheck(-0.0 == result, |
| 1558 |
"Pow(%f,%f), expected %f, got %f", |
| 1559 |
-0.0, 3.0, -0.0, result); |
| 1560 |
|
| 1561 |
return TEST_COMPLETED; |
| 1562 |
} |
| 1563 |
|
| 1564 |
/** |
| 1565 |
* Inputs: (0.0, x) where x is an odd integer. |
| 1566 |
* Expected: |
| 1567 |
* - 0.0 with a positive exponent, |
| 1568 |
* - Positive Infinity with a negative exponent. |
| 1569 |
*/ |
| 1570 |
static int |
| 1571 |
pow_basePZeroExpOddCases(void *args) |
| 1572 |
{ |
| 1573 |
double result; |
| 1574 |
|
| 1575 |
result = SDL_pow(0.0, -5.0); |
| 1576 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1577 |
"Pow(%f,%f), expected %f, got %f", |
| 1578 |
0.0, -5.0, INFINITY, result); |
| 1579 |
|
| 1580 |
result = SDL_pow(0.0, 5.0); |
| 1581 |
SDLTest_AssertCheck(0.0 == result, |
| 1582 |
"Pow(%f,%f), expected %f, got %f", |
| 1583 |
0.0, 5.0, 0.0, result); |
| 1584 |
|
| 1585 |
return TEST_COMPLETED; |
| 1586 |
} |
| 1587 |
|
| 1588 |
/** |
| 1589 |
* Inputs: (-0.0, x), with x either: |
| 1590 |
* - finite and even, |
| 1591 |
* - finite and non-integer. |
| 1592 |
* Expected: |
| 1593 |
* - Positive Infinity if the exponent is negative, |
| 1594 |
* - 0.0 if the exponent is positive. |
| 1595 |
*/ |
| 1596 |
static int |
| 1597 |
pow_baseNZeroCases(void *args) |
| 1598 |
{ |
| 1599 |
double result; |
| 1600 |
|
| 1601 |
result = SDL_pow(-0.0, -3.5); |
| 1602 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1603 |
"Pow(%f,%f), expected %f, got %f", |
| 1604 |
-0.0, -3.5, INFINITY, result); |
| 1605 |
|
| 1606 |
result = SDL_pow(-0.0, -4.0); |
| 1607 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1608 |
"Pow(%f,%f), expected %f, got %f", |
| 1609 |
-0.0, -4.0, INFINITY, result); |
| 1610 |
|
| 1611 |
result = SDL_pow(-0.0, 3.5); |
| 1612 |
SDLTest_AssertCheck(0.0 == result, |
| 1613 |
"Pow(%f,%f), expected %f, got %f", |
| 1614 |
-0.0, 3.5, 0.0, result); |
| 1615 |
|
| 1616 |
result = SDL_pow(-0.0, 4.0); |
| 1617 |
SDLTest_AssertCheck(0.0 == result, |
| 1618 |
"Pow(%f,%f), expected %f, got %f", |
| 1619 |
-0.0, 4.0, 0.0, result); |
| 1620 |
|
| 1621 |
return TEST_COMPLETED; |
| 1622 |
} |
| 1623 |
|
| 1624 |
/** |
| 1625 |
* Inputs: (0.0, x), with x either: |
| 1626 |
* - finite and even, |
| 1627 |
* - finite and non-integer. |
| 1628 |
* Expected: |
| 1629 |
* - Positive Infinity if the exponent is negative, |
| 1630 |
* - 0.0 if the exponent is positive. |
| 1631 |
*/ |
| 1632 |
static int |
| 1633 |
pow_basePZeroCases(void *args) |
| 1634 |
{ |
| 1635 |
double result; |
| 1636 |
|
| 1637 |
result = SDL_pow(0.0, -3.5); |
| 1638 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1639 |
"Pow(%f,%f), expected %f, got %f", |
| 1640 |
0.0, -3.5, INFINITY, result); |
| 1641 |
|
| 1642 |
result = SDL_pow(0.0, -4.0); |
| 1643 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1644 |
"Pow(%f,%f), expected %f, got %f", |
| 1645 |
0.0, -4.0, INFINITY, result); |
| 1646 |
|
| 1647 |
result = SDL_pow(0.0, 3.5); |
| 1648 |
SDLTest_AssertCheck(0.0 == result, |
| 1649 |
"Pow(%f,%f), expected %f, got %f", |
| 1650 |
0.0, 3.5, 0.0, result); |
| 1651 |
|
| 1652 |
result = SDL_pow(0.0, 4.0); |
| 1653 |
SDLTest_AssertCheck(0.0 == result, |
| 1654 |
"Pow(%f,%f), expected %f, got %f", |
| 1655 |
0.0, 4.0, 0.0, result); |
| 1656 |
|
| 1657 |
return TEST_COMPLETED; |
| 1658 |
} |
| 1659 |
|
| 1660 |
/* Remaining tests */ |
| 1661 |
|
| 1662 |
/** |
| 1663 |
* Inputs: values within the domain of the function. |
| 1664 |
* Expected: the correct result is returned. |
| 1665 |
*/ |
| 1666 |
static int |
| 1667 |
pow_regularCases(void *args) |
| 1668 |
{ |
| 1669 |
const dd_to_d regular_cases[] = { |
| 1670 |
#if 0 /* These tests fail when using the Mingw C runtime, we'll disable them for now */ |
| 1671 |
{ -391.25, -2.0, 0.00000653267870448815438463212659780943170062528224661946296691894531250 }, |
| 1672 |
{ -72.3, 12.0, 20401381050275984310272.0 }, |
| 1673 |
#endif |
| 1674 |
{ -5.0, 3.0, -125.0 }, |
| 1675 |
{ 3.0, 2.5, 15.58845726811989607085706666111946105957031250 }, |
| 1676 |
{ 39.23, -1.5, 0.0040697950366865498147972424192175822099670767784118652343750 }, |
| 1677 |
{ 478.972, 12.125, 315326359630449587856007411793920.0 } |
| 1678 |
}; |
| 1679 |
return helper_ddtod_inexact("Pow", SDL_pow, regular_cases, SDL_arraysize(regular_cases)); |
| 1680 |
} |
| 1681 |
|
| 1682 |
/** |
| 1683 |
* Inputs: (2.0, x), with x in range [0, 8]. |
| 1684 |
* Expected: the correct result is returned. |
| 1685 |
*/ |
| 1686 |
static int |
| 1687 |
pow_powerOfTwo(void *args) |
| 1688 |
{ |
| 1689 |
const dd_to_d power_of_two_cases[] = { |
| 1690 |
{ 2.0, 1.0, 2.0 }, |
| 1691 |
{ 2.0, 2.0, 4.0 }, |
| 1692 |
{ 2.0, 3.0, 8.0 }, |
| 1693 |
{ 2.0, 4.0, 16.0 }, |
| 1694 |
{ 2.0, 5.0, 32.0 }, |
| 1695 |
{ 2.0, 6.0, 64.0 }, |
| 1696 |
{ 2.0, 7.0, 128.0 }, |
| 1697 |
{ 2.0, 8.0, 256.0 }, |
| 1698 |
}; |
| 1699 |
return helper_ddtod("Pow", SDL_pow, power_of_two_cases, SDL_arraysize(power_of_two_cases)); |
| 1700 |
} |
| 1701 |
|
| 1702 |
/** |
| 1703 |
* Inputs: values in the range [0, UINT32_MAX] to the power of +/-0.0. |
| 1704 |
* Expected: 1.0 is always returned. |
| 1705 |
*/ |
| 1706 |
static int |
| 1707 |
pow_rangeTest(void *args) |
| 1708 |
{ |
| 1709 |
Uint32 i; |
| 1710 |
double test_value = 0.0; |
| 1711 |
|
| 1712 |
SDLTest_AssertPass("Pow: Testing a range of %u values with steps of %" SDL_PRIu32, |
| 1713 |
RANGE_TEST_ITERATIONS, |
| 1714 |
RANGE_TEST_STEP); |
| 1715 |
|
| 1716 |
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { |
| 1717 |
double result; |
| 1718 |
/* These are tested elsewhere */ |
| 1719 |
if (isnan(test_value) || isinf(test_value)) { |
| 1720 |
continue; |
| 1721 |
} |
| 1722 |
|
| 1723 |
/* Only log failures to save performances */ |
| 1724 |
result = SDL_pow(test_value, 0.0); |
| 1725 |
if (result != 1.0) { |
| 1726 |
SDLTest_AssertCheck(SDL_FALSE, |
| 1727 |
"Pow(%.1f,%.1f), expected %.1f, got %.1f", |
| 1728 |
test_value, 1.0, 1.0, result); |
| 1729 |
return TEST_ABORTED; |
| 1730 |
} |
| 1731 |
|
| 1732 |
result = SDL_pow(test_value, -0.0); |
| 1733 |
if (result != 1.0) { |
| 1734 |
SDLTest_AssertCheck(SDL_FALSE, |
| 1735 |
"Pow(%.1f,%.1f), expected %.1f, got %.1f", |
| 1736 |
test_value, -0.0, 1.0, result); |
| 1737 |
return TEST_ABORTED; |
| 1738 |
} |
| 1739 |
} |
| 1740 |
return TEST_COMPLETED; |
| 1741 |
} |
| 1742 |
|
| 1743 |
/* SDL_sqrt tests functions */ |
| 1744 |
|
| 1745 |
/** |
| 1746 |
* Input: Positive Infinity. |
| 1747 |
* Expected: Positive Infinity is returned. |
| 1748 |
*/ |
| 1749 |
static int |
| 1750 |
sqrt_infCase(void *args) |
| 1751 |
{ |
| 1752 |
const double result = SDL_sqrt(INFINITY); |
| 1753 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1754 |
"Sqrt(%f), expected %f, got %f", |
| 1755 |
INFINITY, INFINITY, result); |
| 1756 |
return TEST_COMPLETED; |
| 1757 |
} |
| 1758 |
|
| 1759 |
/** |
| 1760 |
* Input: NAN. |
| 1761 |
* Expected: NAN is returned. |
| 1762 |
*/ |
| 1763 |
static int |
| 1764 |
sqrt_nanCase(void *args) |
| 1765 |
{ |
| 1766 |
const double result = SDL_sqrt(NAN); |
| 1767 |
SDLTest_AssertCheck(isnan(result), |
| 1768 |
"Sqrt(%f), expected %f, got %f", |
| 1769 |
NAN, NAN, result); |
| 1770 |
return TEST_COMPLETED; |
| 1771 |
} |
| 1772 |
|
| 1773 |
/** |
| 1774 |
* Inputs: values outside the domain of the function. |
| 1775 |
* Expected: NAN is returned. |
| 1776 |
*/ |
| 1777 |
static int |
| 1778 |
sqrt_outOfDomainCases(void *args) |
| 1779 |
{ |
| 1780 |
double result; |
| 1781 |
|
| 1782 |
result = SDL_sqrt(-1.0); |
| 1783 |
SDLTest_AssertCheck(isnan(result), |
| 1784 |
"Sqrt(%f), expected %f, got %f", |
| 1785 |
-1.0, NAN, result); |
| 1786 |
|
| 1787 |
result = SDL_sqrt(-12345.6789); |
| 1788 |
SDLTest_AssertCheck(isnan(result), |
| 1789 |
"Sqrt(%f), expected %f, got %f", |
| 1790 |
-12345.6789, NAN, result); |
| 1791 |
|
| 1792 |
result = SDL_sqrt(-INFINITY); |
| 1793 |
SDLTest_AssertCheck(isnan(result), |
| 1794 |
"Sqrt(%f), expected %f, got %f", |
| 1795 |
-INFINITY, NAN, result); |
| 1796 |
|
| 1797 |
return TEST_COMPLETED; |
| 1798 |
} |
| 1799 |
|
| 1800 |
/** |
| 1801 |
* Inputs: +/-0.0 and 1.0. |
| 1802 |
* Expected: the input value is returned as-is. |
| 1803 |
*/ |
| 1804 |
static int |
| 1805 |
sqrt_baseCases(void *args) |
| 1806 |
{ |
| 1807 |
const d_to_d base_cases[] = { |
| 1808 |
{ -0.0, -0.0 }, |
| 1809 |
{ 0.0, 0.0 }, |
| 1810 |
{ 1.0, 1.0 } |
| 1811 |
}; |
| 1812 |
return helper_dtod("Sqrt", SDL_sqrt, base_cases, SDL_arraysize(base_cases)); |
| 1813 |
} |
| 1814 |
|
| 1815 |
/** |
| 1816 |
* Inputs: values within the domain of the function. |
| 1817 |
* Expected: the correct result is returned. |
| 1818 |
*/ |
| 1819 |
static int |
| 1820 |
sqrt_regularCases(void *args) |
| 1821 |
{ |
| 1822 |
const d_to_d regular_cases[] = { |
| 1823 |
{ 4.0, 2.0 }, |
| 1824 |
{ 9.0, 3.0 }, |
| 1825 |
{ 27.2, 5.21536192416211896727418206864967942237854003906250 }, |
| 1826 |
{ 240.250, 15.5 }, |
| 1827 |
{ 1337.0, 36.565010597564445049556525191292166709899902343750 }, |
| 1828 |
{ 2887.12782400000014604302123188972473144531250, 53.732 }, |
| 1829 |
{ 65600.0156250, 256.125 } |
| 1830 |
}; |
| 1831 |
return helper_dtod_inexact("Sqrt", SDL_sqrt, regular_cases, SDL_arraysize(regular_cases)); |
| 1832 |
} |
| 1833 |
|
| 1834 |
/* SDL_scalbn tests functions */ |
| 1835 |
|
| 1836 |
/** |
| 1837 |
* Input: (+/-Infinity, 1). |
| 1838 |
* Expected: Infinity is returned as-is. |
| 1839 |
*/ |
| 1840 |
static int |
| 1841 |
scalbn_infCases(void *args) |
| 1842 |
{ |
| 1843 |
double result; |
| 1844 |
|
| 1845 |
result = SDL_scalbn(INFINITY, 1); |
| 1846 |
SDLTest_AssertCheck(IS_INFINITY(result) && result > 0, |
| 1847 |
"Scalbn(%f,%d), expected %f, got %f", |
| 1848 |
INFINITY, 1, INFINITY, result); |
| 1849 |
|
| 1850 |
result = SDL_scalbn(-INFINITY, 1); |
| 1851 |
SDLTest_AssertCheck(IS_INFINITY(result) && result < 0, |
| 1852 |
"Scalbn(%f,%d), expected %f, got %f", |
| 1853 |
-INFINITY, 1, -INFINITY, result); |
| 1854 |
|
| 1855 |
return TEST_COMPLETED; |
| 1856 |
} |
| 1857 |
|
| 1858 |
/** |
| 1859 |
* Inputs: (+/-0.0, 1). |
| 1860 |
* Expected: Zero is returned as-is. |
| 1861 |
*/ |
| 1862 |
static int |
| 1863 |
scalbn_baseZeroCases(void *args) |
| 1864 |
{ |
| 1865 |
double result; |
| 1866 |
|
| 1867 |
result = SDL_scalbn(0.0, 1); |
| 1868 |
SDLTest_AssertCheck(0.0 == result, |
| 1869 |
"Scalbn(%f,%d), expected %f, got %f", |
| 1870 |
0.0, 1, 0.0, result); |
| 1871 |
|
| 1872 |
result = SDL_scalbn(-0.0, 1); |
| 1873 |
SDLTest_AssertCheck(-0.0 == result, |
| 1874 |
"Scalbn(%f,%d), expected %f, got %f", |
| 1875 |
-0.0, 1, -0.0, result); |
| 1876 |
|
| 1877 |
return TEST_COMPLETED; |
| 1878 |
} |
| 1879 |
|
| 1880 |
/** |
| 1881 |
* Input: (x, 0) |
| 1882 |
* Expected: x is returned as-is. |
| 1883 |
*/ |
| 1884 |
static int |
| 1885 |
scalbn_expZeroCase(void *args) |
| 1886 |
{ |
| 1887 |
const double result = SDL_scalbn(42.0, 0); |
| 1888 |
SDLTest_AssertCheck(42.0 == result, |
| 1889 |
"Scalbn(%f,%d), expected %f, got %f", |
| 1890 |
42.0, 0, 42.0, result); |
| 1891 |
return TEST_COMPLETED; |
| 1892 |
} |
| 1893 |
|
| 1894 |
/** |
| 1895 |
* Input: (NAN, x). |
| 1896 |
* Expected: NAN is returned. |
| 1897 |
*/ |
| 1898 |
static int |
| 1899 |
scalbn_nanCase(void *args) |
| 1900 |
{ |
| 1901 |
const double result = SDL_scalbn(NAN, 2); |
| 1902 |
SDLTest_AssertCheck(isnan(result), |
| 1903 |
"Scalbn(%f,%d), expected %f, got %f", |
| 1904 |
NAN, 2, NAN, result); |
| 1905 |
return TEST_COMPLETED; |
| 1906 |
} |
| 1907 |
|
| 1908 |
/** |
| 1909 |
* Inputs: values inside the domain of the function. |
| 1910 |
* Expected: the correct result is returned. |
| 1911 |
* NOTE: This test depends on SDL_pow and FLT_RADIX. |
| 1912 |
*/ |
| 1913 |
static int |
| 1914 |
scalbn_regularCases(void *args) |
| 1915 |
{ |
| 1916 |
double result, expected; |
| 1917 |
|
| 1918 |
result = SDL_scalbn(2.0, 2); |
| 1919 |
expected = 2.0 * SDL_pow(FLT_RADIX, 2); |
| 1920 |
SDLTest_AssertCheck(result == expected, |
| 1921 |
"Scalbn(%f,%d), expected %f, got %f", |
| 1922 |
2.0, 2, expected, result); |
| 1923 |
|
| 1924 |
result = SDL_scalbn(1.0, 13); |
| 1925 |
expected = 1.0 * SDL_pow(FLT_RADIX, 13); |
| 1926 |
SDLTest_AssertCheck(result == expected, |
| 1927 |
"Scalbn(%f,%d), expected %f, got %f", |
| 1928 |
1.0, 13, expected, result); |
| 1929 |
|
| 1930 |
result = SDL_scalbn(2.0, -5); |
| 1931 |
expected = 2.0 * SDL_pow(FLT_RADIX, -5); |
| 1932 |
SDLTest_AssertCheck(result == expected, |
| 1933 |
"Scalbn(%f,%d), expected %f, got %f", |
| 1934 |
2.0, -5, expected, result); |
| 1935 |
|
| 1936 |
result = SDL_scalbn(-1.0, -13); |
| 1937 |
expected = -1.0 * SDL_pow(FLT_RADIX, -13); |
| 1938 |
SDLTest_AssertCheck(result == expected, |
| 1939 |
"Scalbn(%f,%d), expected %f, got %f", |
| 1940 |
-1.0, -13, expected, result); |
| 1941 |
|
| 1942 |
return TEST_COMPLETED; |
| 1943 |
} |
| 1944 |
|
| 1945 |
/* SDL_cos tests functions */ |
| 1946 |
|
| 1947 |
/** |
| 1948 |
* Inputs: +/-Infinity. |
| 1949 |
* Expected: NAN is returned. |
| 1950 |
*/ |
| 1951 |
static int |
| 1952 |
cos_infCases(void *args) |
| 1953 |
{ |
| 1954 |
double result; |
| 1955 |
|
| 1956 |
result = SDL_cos(INFINITY); |
| 1957 |
SDLTest_AssertCheck(isnan(result), |
| 1958 |
"Cos(%f), expected %f, got %f", |
| 1959 |
INFINITY, NAN, result); |
| 1960 |
|
| 1961 |
result = SDL_cos(-INFINITY); |
| 1962 |
SDLTest_AssertCheck(isnan(result), |
| 1963 |
"Cos(%f), expected %f, got %f", |
| 1964 |
-INFINITY, NAN, result); |
| 1965 |
|
| 1966 |
return TEST_COMPLETED; |
| 1967 |
} |
| 1968 |
|
| 1969 |
/** |
| 1970 |
* Input: NAN. |
| 1971 |
* Expected: NAN is returned. |
| 1972 |
*/ |
| 1973 |
static int |
| 1974 |
cos_nanCase(void *args) |
| 1975 |
{ |
| 1976 |
const double result = SDL_cos(NAN); |
| 1977 |
SDLTest_AssertCheck(isnan(result), |
| 1978 |
"Cos(%f), expected %f, got %f", |
| 1979 |
NAN, NAN, result); |
| 1980 |
return TEST_COMPLETED; |
| 1981 |
} |
| 1982 |
|
| 1983 |
/** |
| 1984 |
* Inputs: +/-0.0 and +/-Pi. |
| 1985 |
* Expected: +1.0 and -1.0 respectively. |
| 1986 |
*/ |
| 1987 |
static int |
| 1988 |
cos_regularCases(void *args) |
| 1989 |
{ |
| 1990 |
const d_to_d regular_cases[] = { |
| 1991 |
{ -M_PI, -1.0 }, |
| 1992 |
{ -0.0, 1.0 }, |
| 1993 |
{ 0.0, 1.0 }, |
| 1994 |
{ M_PI, -1.0 } |
| 1995 |
}; |
| 1996 |
return helper_dtod("Cos", SDL_cos, regular_cases, SDL_arraysize(regular_cases)); |
| 1997 |
} |
| 1998 |
|
| 1999 |
/** |
| 2000 |
* Inputs: Angles between 1/10 and 9/10 of Pi (positive and negative). |
| 2001 |
* Expected: The correct result is returned (+/-EPSILON). |
| 2002 |
*/ |
| 2003 |
static int |
| 2004 |
cos_precisionTest(void *args) |
| 2005 |
{ |
| 2006 |
const d_to_d precision_cases[] = { |
| 2007 |
{ M_PI * 1.0 / 10.0, 0.9510565162951535 }, |
| 2008 |
{ M_PI * 2.0 / 10.0, 0.8090169943749475 }, |
| 2009 |
{ M_PI * 3.0 / 10.0, 0.5877852522924731 }, |
| 2010 |
{ M_PI * 4.0 / 10.0, 0.30901699437494745 }, |
| 2011 |
{ M_PI * 5.0 / 10.0, 0.0 }, |
| 2012 |
{ M_PI * 6.0 / 10.0, -0.30901699437494734 }, |
| 2013 |
{ M_PI * 7.0 / 10.0, -0.587785252292473 }, |
| 2014 |
{ M_PI * 8.0 / 10.0, -0.8090169943749473 }, |
| 2015 |
{ M_PI * 9.0 / 10.0, -0.9510565162951535 }, |
| 2016 |
{ M_PI * -1.0 / 10.0, 0.9510565162951535 }, |
| 2017 |
{ M_PI * -2.0 / 10.0, 0.8090169943749475 }, |
| 2018 |
{ M_PI * -3.0 / 10.0, 0.5877852522924731 }, |
| 2019 |
{ M_PI * -4.0 / 10.0, 0.30901699437494745 }, |
| 2020 |
{ M_PI * -5.0 / 10.0, 0.0 }, |
| 2021 |
{ M_PI * -6.0 / 10.0, -0.30901699437494734 }, |
| 2022 |
{ M_PI * -7.0 / 10.0, -0.587785252292473 }, |
| 2023 |
{ M_PI * -8.0 / 10.0, -0.8090169943749473 }, |
| 2024 |
{ M_PI * -9.0 / 10.0, -0.9510565162951535 } |
| 2025 |
}; |
| 2026 |
return helper_dtod_inexact("Cos", SDL_cos, precision_cases, SDL_arraysize(precision_cases)); |
| 2027 |
} |
| 2028 |
|
| 2029 |
/** |
| 2030 |
* Inputs: Values in the range [0, UINT32_MAX]. |
| 2031 |
* Expected: A value between 0 and 1 is returned. |
| 2032 |
*/ |
| 2033 |
static int |
| 2034 |
cos_rangeTest(void *args) |
| 2035 |
{ |
| 2036 |
Uint32 i; |
| 2037 |
double test_value = 0.0; |
| 2038 |
|
| 2039 |
SDLTest_AssertPass("Cos: Testing a range of %u values with steps of %" SDL_PRIu32, |
| 2040 |
RANGE_TEST_ITERATIONS, |
| 2041 |
RANGE_TEST_STEP); |
| 2042 |
|
| 2043 |
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { |
| 2044 |
double result; |
| 2045 |
/* These are tested elsewhere */ |
| 2046 |
if (isnan(test_value) || isinf(test_value)) { |
| 2047 |
continue; |
| 2048 |
} |
| 2049 |
|
| 2050 |
/* Only log failures to save performances */ |
| 2051 |
result = SDL_cos(test_value); |
| 2052 |
if (result < -1.0 || result > 1.0) { |
| 2053 |
SDLTest_AssertCheck(SDL_FALSE, |
| 2054 |
"Cos(%.1f), expected [%.1f,%.1f], got %.1f", |
| 2055 |
test_value, -1.0, 1.0, result); |
| 2056 |
return TEST_ABORTED; |
| 2057 |
} |
| 2058 |
} |
| 2059 |
return TEST_COMPLETED; |
| 2060 |
} |
| 2061 |
|
| 2062 |
/* SDL_sin tests functions */ |
| 2063 |
|
| 2064 |
/** |
| 2065 |
* Inputs: +/-Infinity. |
| 2066 |
* Expected: NAN is returned. |
| 2067 |
*/ |
| 2068 |
static int |
| 2069 |
sin_infCases(void *args) |
| 2070 |
{ |
| 2071 |
double result; |
| 2072 |
|
| 2073 |
result = SDL_sin(INFINITY); |
| 2074 |
SDLTest_AssertCheck(isnan(result), |
| 2075 |
"Sin(%f), expected %f, got %f", |
| 2076 |
INFINITY, NAN, result); |
| 2077 |
|
| 2078 |
result = SDL_sin(-INFINITY); |
| 2079 |
SDLTest_AssertCheck(isnan(result), |
| 2080 |
"Sin(%f), expected %f, got %f", |
| 2081 |
-INFINITY, NAN, result); |
| 2082 |
|
| 2083 |
return TEST_COMPLETED; |
| 2084 |
} |
| 2085 |
|
| 2086 |
/** |
| 2087 |
* Input: NAN. |
| 2088 |
* Expected: NAN is returned. |
| 2089 |
*/ |
| 2090 |
static int |
| 2091 |
sin_nanCase(void *args) |
| 2092 |
{ |
| 2093 |
const double result = SDL_sin(NAN); |
| 2094 |
SDLTest_AssertCheck(isnan(result), |
| 2095 |
"Sin(%f), expected %f, got %f", |
| 2096 |
NAN, NAN, result); |
| 2097 |
return TEST_COMPLETED; |
| 2098 |
} |
| 2099 |
|
| 2100 |
/** |
| 2101 |
* Inputs: +/-0.0 and +/-Pi/2. |
| 2102 |
* Expected: +/-0.0 and +/-1.0 respectively. |
| 2103 |
*/ |
| 2104 |
static int |
| 2105 |
sin_regularCases(void *args) |
| 2106 |
{ |
| 2107 |
const d_to_d regular_cases[] = { |
| 2108 |
{ -M_PI / 2, -1.0 }, |
| 2109 |
{ -0.0, -0.0 }, |
| 2110 |
{ 0.0, 0.0 }, |
| 2111 |
{ M_PI / 2, 1.0 } |
| 2112 |
}; |
| 2113 |
return helper_dtod("Sin", SDL_sin, regular_cases, SDL_arraysize(regular_cases)); |
| 2114 |
} |
| 2115 |
|
| 2116 |
/** |
| 2117 |
* Inputs: Angles between 1/10 and 10/10 of Pi (positive and negative). |
| 2118 |
* Expected: The correct result is returned (+/-EPSILON). |
| 2119 |
* NOTE: +/-Pi/2 is tested in the regular cases. |
| 2120 |
*/ |
| 2121 |
static int |
| 2122 |
sin_precisionTest(void *args) |
| 2123 |
{ |
| 2124 |
const d_to_d precision_cases[] = { |
| 2125 |
{ M_PI * 1.0 / 10.0, 0.3090169943749474 }, |
| 2126 |
{ M_PI * 2.0 / 10.0, 0.5877852522924731 }, |
| 2127 |
{ M_PI * 3.0 / 10.0, 0.8090169943749475 }, |
| 2128 |
{ M_PI * 4.0 / 10.0, 0.9510565162951535 }, |
| 2129 |
{ M_PI * 6.0 / 10.0, 0.9510565162951536 }, |
| 2130 |
{ M_PI * 7.0 / 10.0, 0.8090169943749475 }, |
| 2131 |
{ M_PI * 8.0 / 10.0, 0.5877852522924732 }, |
| 2132 |
{ M_PI * 9.0 / 10.0, 0.3090169943749475 }, |
| 2133 |
{ M_PI, 0.0 }, |
| 2134 |
{ M_PI * -1.0 / 10.0, -0.3090169943749474 }, |
| 2135 |
{ M_PI * -2.0 / 10.0, -0.5877852522924731 }, |
| 2136 |
{ M_PI * -3.0 / 10.0, -0.8090169943749475 }, |
| 2137 |
{ M_PI * -4.0 / 10.0, -0.9510565162951535 }, |
| 2138 |
{ M_PI * -6.0 / 10.0, -0.9510565162951536 }, |
| 2139 |
{ M_PI * -7.0 / 10.0, -0.8090169943749475 }, |
| 2140 |
{ M_PI * -8.0 / 10.0, -0.5877852522924732 }, |
| 2141 |
{ M_PI * -9.0 / 10.0, -0.3090169943749475 }, |
| 2142 |
{ -M_PI, 0.0 }, |
| 2143 |
}; |
| 2144 |
return helper_dtod_inexact("Sin", SDL_sin, precision_cases, SDL_arraysize(precision_cases)); |
| 2145 |
} |
| 2146 |
|
| 2147 |
/** |
| 2148 |
* Inputs: Values in the range [0, UINT32_MAX]. |
| 2149 |
* Expected: A value between 0 and 1 is returned. |
| 2150 |
*/ |
| 2151 |
static int |
| 2152 |
sin_rangeTest(void *args) |
| 2153 |
{ |
| 2154 |
Uint32 i; |
| 2155 |
double test_value = 0.0; |
| 2156 |
|
| 2157 |
SDLTest_AssertPass("Sin: Testing a range of %u values with steps of %" SDL_PRIu32, |
| 2158 |
RANGE_TEST_ITERATIONS, |
| 2159 |
RANGE_TEST_STEP); |
| 2160 |
|
| 2161 |
for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) { |
| 2162 |
double result; |
| 2163 |
/* These are tested elsewhere */ |
| 2164 |
if (isnan(test_value) || isinf(test_value)) { |
| 2165 |
continue; |
| 2166 |
} |
| 2167 |
|
| 2168 |
/* Only log failures to save performances */ |
| 2169 |
result = SDL_sin(test_value); |
| 2170 |
if (result < -1.0 || result > 1.0) { |
| 2171 |
SDLTest_AssertCheck(SDL_FALSE, |
| 2172 |
"Sin(%.1f), expected [%.1f,%.1f], got %.1f", |
| 2173 |
test_value, -1.0, 1.0, result); |
| 2174 |
return TEST_ABORTED; |
| 2175 |
} |
| 2176 |
} |
| 2177 |
return TEST_COMPLETED; |
| 2178 |
} |
| 2179 |
|
| 2180 |
/* SDL_tan tests functions */ |
| 2181 |
|
| 2182 |
/** |
| 2183 |
* Inputs: +/-Infinity. |
| 2184 |
* Expected: NAN is returned. |
| 2185 |
*/ |
| 2186 |
static int |
| 2187 |
tan_infCases(void *args) |
| 2188 |
{ |
| 2189 |
double result; |
| 2190 |
|
| 2191 |
result = SDL_tan(INFINITY); |
| 2192 |
SDLTest_AssertCheck(isnan(result), |
| 2193 |
"Tan(%f), expected %f, got %f", |
| 2194 |
INFINITY, NAN, result); |
| 2195 |
|
| 2196 |
result = SDL_tan(-INFINITY); |
| 2197 |
SDLTest_AssertCheck(isnan(result), |
| 2198 |
"Tan(%f), expected %f, got %f", |
| 2199 |
-INFINITY, NAN, result); |
| 2200 |
|
| 2201 |
return TEST_COMPLETED; |
| 2202 |
} |
| 2203 |
|
| 2204 |
/** |
| 2205 |
* Input: NAN. |
| 2206 |
* Expected: NAN is returned. |
| 2207 |
*/ |
| 2208 |
static int |
| 2209 |
tan_nanCase(void *args) |
| 2210 |
{ |
| 2211 |
const double result = SDL_tan(NAN); |
| 2212 |
SDLTest_AssertCheck(isnan(result), |
| 2213 |
"Tan(%f), expected %f, got %f", |
| 2214 |
NAN, NAN, result); |
| 2215 |
return TEST_COMPLETED; |
| 2216 |
} |
| 2217 |
|
| 2218 |
/** |
| 2219 |
* Inputs: +/-0.0. |
| 2220 |
* Expected: Zero is returned as-is. |
| 2221 |
*/ |
| 2222 |
static int |
| 2223 |
tan_zeroCases(void *args) |
| 2224 |
{ |
| 2225 |
const d_to_d regular_cases[] = { |
| 2226 |
{ -0.0, -0.0 }, |
| 2227 |
{ 0.0, 0.0 } |
| 2228 |
}; |
| 2229 |
return helper_dtod("Tan", SDL_tan, regular_cases, SDL_arraysize(regular_cases)); |
| 2230 |
} |
| 2231 |
|
| 2232 |
/** |
| 2233 |
* Inputs: Angles between 1/11 and 10/11 of Pi (positive and negative). |
| 2234 |
* Expected: The correct result is returned (+/-EPSILON). |
| 2235 |
* NOTE: +/-Pi/2 is intentionally avoided as it returns garbage values. |
| 2236 |
*/ |
| 2237 |
static int |
| 2238 |
tan_precisionTest(void *args) |
| 2239 |
{ |
| 2240 |
const d_to_d precision_cases[] = { |
| 2241 |
{ M_PI * 1.0 / 11.0, 0.29362649293836673 }, |
| 2242 |
{ M_PI * 2.0 / 11.0, 0.642660977168331 }, |
| 2243 |
{ M_PI * 3.0 / 11.0, 1.1540615205330094 }, |
| 2244 |
{ M_PI * 4.0 / 11.0, 2.189694562989681 }, |
| 2245 |
{ M_PI * 5.0 / 11.0, 6.9551527717734745 }, |
| 2246 |
{ M_PI * 6.0 / 11.0, -6.955152771773481 }, |
| 2247 |
{ M_PI * 7.0 / 11.0, -2.189694562989682 }, |
| 2248 |
{ M_PI * 8.0 / 11.0, -1.1540615205330096 }, |
| 2249 |
{ M_PI * 9.0 / 11.0, -0.6426609771683314 }, |
| 2250 |
{ M_PI * 10.0 / 11.0, -0.2936264929383667 }, |
| 2251 |
{ M_PI * -1.0 / 11.0, -0.29362649293836673 }, |
| 2252 |
{ M_PI * -2.0 / 11.0, -0.642660977168331 }, |
| 2253 |
{ M_PI * -3.0 / 11.0, -1.1540615205330094 }, |
| 2254 |
{ M_PI * -4.0 / 11.0, -2.189694562989681 }, |
| 2255 |
{ M_PI * -5.0 / 11.0, -6.9551527717734745 }, |
| 2256 |
{ M_PI * -6.0 / 11.0, 6.955152771773481 }, |
| 2257 |
{ M_PI * -7.0 / 11.0, 2.189694562989682 }, |
| 2258 |
{ M_PI * -8.0 / 11.0, 1.1540615205330096 }, |
| 2259 |
{ M_PI * -9.0 / 11.0, 0.6426609771683314 }, |
| 2260 |
{ M_PI * -10.0 / 11.0, 0.2936264929383667 } |
| 2261 |
}; |
| 2262 |
return helper_dtod_inexact("Tan", SDL_tan, precision_cases, SDL_arraysize(precision_cases)); |
| 2263 |
} |
| 2264 |
|
| 2265 |
/* SDL_acos tests functions */ |
| 2266 |
|
| 2267 |
/** |
| 2268 |
* Inputs: +/-1.0. |
| 2269 |
* Expected: 0.0 and Pi respectively. |
| 2270 |
*/ |
| 2271 |
static int |
| 2272 |
acos_limitCases(void *args) |
| 2273 |
{ |
| 2274 |
double result; |
| 2275 |
|
| 2276 |
result = SDL_acos(1.0); |
| 2277 |
SDLTest_AssertCheck(0.0 == result, |
| 2278 |
"Acos(%f), expected %f, got %f", |
| 2279 |
1.0, 0.0, result); |
| 2280 |
|
| 2281 |
result = SDL_acos(-1.0); |
| 2282 |
SDLTest_AssertCheck(SDL_fabs(M_PI - result) <= EPSILON, |
| 2283 |
"Acos(%f), expected %f, got %f", |
| 2284 |
-1.0, M_PI, result); |
| 2285 |
|
| 2286 |
return TEST_COMPLETED; |
| 2287 |
} |
| 2288 |
|
| 2289 |
/** |
| 2290 |
* Inputs: Values outside the domain of [-1, 1]. |
| 2291 |
* Expected: NAN is returned. |
| 2292 |
*/ |
| 2293 |
static int |
| 2294 |
acos_outOfDomainCases(void *args) |
| 2295 |
{ |
| 2296 |
double result; |
| 2297 |
|
| 2298 |
result = SDL_acos(1.1); |
| 2299 |
SDLTest_AssertCheck(isnan(result), |
| 2300 |
"Acos(%f), expected %f, got %f", |
| 2301 |
1.1, NAN, result); |
| 2302 |
|
| 2303 |
result = SDL_acos(-1.1); |
| 2304 |
SDLTest_AssertCheck(isnan(result), |
| 2305 |
"Acos(%f), expected %f, got %f", |
| 2306 |
-1.1, NAN, result); |
| 2307 |
|
| 2308 |
return TEST_COMPLETED; |
| 2309 |
} |
| 2310 |
|
| 2311 |
/** |
| 2312 |
* Input: NAN. |
| 2313 |
* Expected: NAN is returned. |
| 2314 |
*/ |
| 2315 |
static int |
| 2316 |
acos_nanCase(void *args) |
| 2317 |
{ |
| 2318 |
const double result = SDL_acos(NAN); |
| 2319 |
SDLTest_AssertCheck(isnan(result), |
| 2320 |
"Acos(%f), expected %f, got %f", |
| 2321 |
NAN, NAN, result); |
| 2322 |
return TEST_COMPLETED; |
| 2323 |
} |
| 2324 |
|
| 2325 |
/** |
| 2326 |
* Inputs: Values between -0.9 and 0.9 with steps of 0.1. |
| 2327 |
* Expected: The correct result is returned (+/-EPSILON). |
| 2328 |
*/ |
| 2329 |
static int |
| 2330 |
acos_precisionTest(void *args) |
| 2331 |
{ |
| 2332 |
const d_to_d precision_cases[] = { |
| 2333 |
{ 0.9, 0.4510268117 }, |
| 2334 |
{ 0.8, 0.6435011087 }, |
| 2335 |
{ 0.7, 0.7953988301 }, |
| 2336 |
{ 0.6, 0.9272952180 }, |
| 2337 |
{ 0.5, 1.0471975511 }, |
| 2338 |
{ 0.4, 1.1592794807 }, |
| 2339 |
{ 0.3, 1.2661036727 }, |
| 2340 |
{ 0.2, 1.3694384060 }, |
| 2341 |
{ 0.1, 1.4706289056 }, |
| 2342 |
{ 0.0, 1.5707963267 }, |
| 2343 |
{ -0.0, 1.5707963267 }, |
| 2344 |
{ -0.1, 1.6709637479 }, |
| 2345 |
{ -0.2, 1.7721542475 }, |
| 2346 |
{ -0.3, 1.8754889808 }, |
| 2347 |
{ -0.4, 1.9823131728 }, |
| 2348 |
{ -0.5, 2.0943951023 }, |
| 2349 |
{ -0.6, 2.2142974355 }, |
| 2350 |
{ -0.7, 2.3461938234 }, |
| 2351 |
{ -0.8, 2.4980915447 }, |
| 2352 |
{ -0.9, 2.6905658417 }, |
| 2353 |
}; |
| 2354 |
return helper_dtod_inexact("Acos", SDL_acos, precision_cases, SDL_arraysize(precision_cases)); |
| 2355 |
} |
| 2356 |
|
| 2357 |
/* SDL_asin tests functions */ |
| 2358 |
|
| 2359 |
/** |
| 2360 |
* Inputs: +/-1.0. |
| 2361 |
* Expected: +/-Pi/2 is returned. |
| 2362 |
*/ |
| 2363 |
static int |
| 2364 |
asin_limitCases(void *args) |
| 2365 |
{ |
| 2366 |
double result; |
| 2367 |
|
| 2368 |
result = SDL_asin(1.0); |
| 2369 |
SDLTest_AssertCheck(SDL_fabs(M_PI / 2.0 - result) <= EPSILON, |
| 2370 |
"Asin(%f), expected %f, got %f", |
| 2371 |
1.0, M_PI / 2.0, result); |
| 2372 |
|
| 2373 |
result = SDL_asin(-1.0); |
| 2374 |
SDLTest_AssertCheck(SDL_fabs(-M_PI / 2.0 - result) <= EPSILON, |
| 2375 |
"Asin(%f), expected %f, got %f", |
| 2376 |
-1.0, -M_PI / 2.0, result); |
| 2377 |
|
| 2378 |
return TEST_COMPLETED; |
| 2379 |
} |
| 2380 |
|
| 2381 |
/** |
| 2382 |
* Inputs: Values outside the domain of [-1, 1]. |
| 2383 |
* Expected: NAN is returned. |
| 2384 |
*/ |
| 2385 |
static int |
| 2386 |
asin_outOfDomainCases(void *args) |
| 2387 |
{ |
| 2388 |
double result; |
| 2389 |
|
| 2390 |
result = SDL_asin(1.1); |
| 2391 |
SDLTest_AssertCheck(isnan(result), |
| 2392 |
"Asin(%f), expected %f, got %f", |
| 2393 |
1.1, NAN, result); |
| 2394 |
|
| 2395 |
result = SDL_asin(-1.1); |
| 2396 |
SDLTest_AssertCheck(isnan(result), |
| 2397 |
"Asin(%f), expected %f, got %f", |
| 2398 |
-1.1, NAN, result); |
| 2399 |
|
| 2400 |
return TEST_COMPLETED; |
| 2401 |
} |
| 2402 |
|
| 2403 |
/** |
| 2404 |
* Input: NAN. |
| 2405 |
* Expected: NAN is returned. |
| 2406 |
*/ |
| 2407 |
static int |
| 2408 |
asin_nanCase(void *args) |
| 2409 |
{ |
| 2410 |
const double result = SDL_asin(NAN); |
| 2411 |
SDLTest_AssertCheck(isnan(result), |
| 2412 |
"Asin(%f), expected %f, got %f", |
| 2413 |
NAN, NAN, result); |
| 2414 |
return TEST_COMPLETED; |
| 2415 |
} |
| 2416 |
|
| 2417 |
/** |
| 2418 |
* Inputs: Values between -0.9 and 0.9 with steps of 0.1. |
| 2419 |
* Expected: The correct result is returned (+/-EPSILON). |
| 2420 |
*/ |
| 2421 |
static int |
| 2422 |
asin_precisionTest(void *args) |
| 2423 |
{ |
| 2424 |
const d_to_d precision_cases[] = { |
| 2425 |
{ 0.9, 1.1197695149986342 }, |
| 2426 |
{ 0.8, 0.9272952180016123 }, |
| 2427 |
{ 0.7, 0.775397496610753 }, |
| 2428 |
{ 0.6, 0.6435011087932844 }, |
| 2429 |
{ 0.5, 0.5235987755982989 }, |
| 2430 |
{ 0.4, 0.41151684606748806 }, |
| 2431 |
{ 0.3, 0.3046926540153976 }, |
| 2432 |
{ 0.2, 0.20135792079033074 }, |
| 2433 |
{ 0.1, 0.10016742116155977 }, |
| 2434 |
{ 0.0, 0.0 }, |
| 2435 |
{ -0.0, -0.0 }, |
| 2436 |
{ -0.1, -0.10016742116155977 }, |
| 2437 |
{ -0.2, -0.20135792079033074 }, |
| 2438 |
{ -0.3, -0.3046926540153976 }, |
| 2439 |
{ -0.4, -0.41151684606748806 }, |
| 2440 |
{ -0.5, -0.5235987755982989 }, |
| 2441 |
{ -0.6, -0.6435011087932844 }, |
| 2442 |
{ -0.7, -0.775397496610753 }, |
| 2443 |
{ -0.8, -0.9272952180016123 }, |
| 2444 |
{ -0.9, -1.1197695149986342 } |
| 2445 |
}; |
| 2446 |
return helper_dtod_inexact("Asin", SDL_asin, precision_cases, SDL_arraysize(precision_cases)); |
| 2447 |
} |
| 2448 |
|
| 2449 |
/* SDL_atan tests functions */ |
| 2450 |
|
| 2451 |
/** |
| 2452 |
* Inputs: +/-Infinity. |
| 2453 |
* Expected: +/-Pi/2 is returned. |
| 2454 |
*/ |
| 2455 |
static int |
| 2456 |
atan_limitCases(void *args) |
| 2457 |
{ |
| 2458 |
double result; |
| 2459 |
|
| 2460 |
result = SDL_atan(INFINITY); |
| 2461 |
SDLTest_AssertCheck((M_PI / 2.0) - EPSILON <= result && |
| 2462 |
result <= (M_PI / 2.0) + EPSILON, |
| 2463 |
"Atan(%f), expected %f, got %f", |
| 2464 |
INFINITY, M_PI / 2.0, result); |
| 2465 |
|
| 2466 |
result = SDL_atan(-INFINITY); |
| 2467 |
SDLTest_AssertCheck((-M_PI / 2.0) - EPSILON <= result && |
| 2468 |
result <= (-M_PI / 2.0) + EPSILON, |
| 2469 |
"Atan(%f), expected %f, got %f", |
| 2470 |
-INFINITY, -M_PI / 2.0, result); |
| 2471 |
|
| 2472 |
return TEST_COMPLETED; |
| 2473 |
} |
| 2474 |
|
| 2475 |
/** |
| 2476 |
* Inputs: +/-0.0. |
| 2477 |
* Expected: Zero is returned as-is. |
| 2478 |
*/ |
| 2479 |
static int |
| 2480 |
atan_zeroCases(void *args) |
| 2481 |
{ |
| 2482 |
double result; |
| 2483 |
|
| 2484 |
result = SDL_atan(0.0); |
| 2485 |
SDLTest_AssertCheck(0.0 == result, |
| 2486 |
"Atan(%f), expected %f, got %f", |
| 2487 |
0.0, 0.0, result); |
| 2488 |
|
| 2489 |
result = SDL_atan(-0.0); |
| 2490 |
SDLTest_AssertCheck(-0.0 == result, |
| 2491 |
"Atan(%f), expected %f, got %f", |
| 2492 |
-0.0, -0.0, result); |
| 2493 |
|
| 2494 |
return TEST_COMPLETED; |
| 2495 |
} |
| 2496 |
|
| 2497 |
/** |
| 2498 |
* Input: NAN. |
| 2499 |
* Expected: NAN is returned. |
| 2500 |
*/ |
| 2501 |
static int |
| 2502 |
atan_nanCase(void *args) |
| 2503 |
{ |
| 2504 |
const double result = SDL_atan(NAN); |
| 2505 |
SDLTest_AssertCheck(isnan(result), |
| 2506 |
"Atan(%f), expected %f, got %f", |
| 2507 |
NAN, NAN, result); |
| 2508 |
return TEST_COMPLETED; |
| 2509 |
} |
| 2510 |
|
| 2511 |
/** |
| 2512 |
* Inputs: Values corresponding to angles between 9Pi/20 and -9Pi/20 with steps of Pi/20. |
| 2513 |
* Expected: The correct result is returned (+/-EPSILON). |
| 2514 |
*/ |
| 2515 |
static int |
| 2516 |
atan_precisionTest(void *args) |
| 2517 |
{ |
| 2518 |
const d_to_d precision_cases[] = { |
| 2519 |
{ 6.313751514675041, 1.413716694115407 }, |
| 2520 |
{ 3.0776835371752527, 1.2566370614359172 }, |
| 2521 |
{ 1.9626105055051504, 1.0995574287564276 }, |
| 2522 |
{ 1.3763819204711734, 0.9424777960769379 }, |
| 2523 |
{ 1.0, 0.7853981633974483 }, |
| 2524 |
{ 0.7265425280053609, 0.6283185307179586 }, |
| 2525 |
{ 0.5095254494944288, 0.47123889803846897 }, |
| 2526 |
{ 0.3249196962329063, 0.3141592653589793 }, |
| 2527 |
{ 0.15838444032453627, 0.15707963267948966 }, |
| 2528 |
{ -0.15838444032453627, -0.15707963267948966 }, |
| 2529 |
{ -0.3249196962329063, -0.3141592653589793 }, |
| 2530 |
{ -0.5095254494944288, -0.47123889803846897 }, |
| 2531 |
{ -0.7265425280053609, -0.6283185307179586 }, |
| 2532 |
{ -1.0, -0.7853981633974483 }, |
| 2533 |
{ -1.3763819204711734, -0.9424777960769379 }, |
| 2534 |
{ -1.9626105055051504, -1.0995574287564276 }, |
| 2535 |
{ -3.0776835371752527, -1.2566370614359172 }, |
| 2536 |
{ -6.313751514675041, -1.413716694115407 }, |
| 2537 |
}; |
| 2538 |
return helper_dtod_inexact("Atan", SDL_atan, precision_cases, SDL_arraysize(precision_cases)); |
| 2539 |
} |
| 2540 |
|
| 2541 |
/* SDL_atan2 tests functions */ |
| 2542 |
|
| 2543 |
/* Zero cases */ |
| 2544 |
|
| 2545 |
/** |
| 2546 |
* Inputs: (+/-0.0, +/-0.0). |
| 2547 |
* Expected: |
| 2548 |
* - Zero if the second argument is positive zero. |
| 2549 |
* - Pi if the second argument is negative zero. |
| 2550 |
* - The sign is inherited from the first argument. |
| 2551 |
*/ |
| 2552 |
static int |
| 2553 |
atan2_bothZeroCases(void *args) |
| 2554 |
{ |
| 2555 |
const dd_to_d cases[] = { |
| 2556 |
{ 0.0, 0.0, 0.0 }, |
| 2557 |
{ -0.0, 0.0, -0.0 }, |
| 2558 |
{ 0.0, -0.0, M_PI }, |
| 2559 |
{ -0.0, -0.0, -M_PI }, |
| 2560 |
}; |
| 2561 |
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); |
| 2562 |
} |
| 2563 |
|
| 2564 |
/** |
| 2565 |
* Inputs: (+/-0.0, +/-1.0). |
| 2566 |
* Expected: |
| 2567 |
* - Zero if the second argument is positive. |
| 2568 |
* - Pi if the second argument is negative. |
| 2569 |
* - The sign is inherited from the first argument. |
| 2570 |
*/ |
| 2571 |
static int |
| 2572 |
atan2_yZeroCases(void *args) |
| 2573 |
{ |
| 2574 |
const dd_to_d cases[] = { |
| 2575 |
{ 0.0, 1.0, 0.0 }, |
| 2576 |
{ 0.0, -1.0, M_PI }, |
| 2577 |
{ -0.0, 1.0, -0.0 }, |
| 2578 |
{ -0.0, -1.0, -M_PI } |
| 2579 |
}; |
| 2580 |
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); |
| 2581 |
} |
| 2582 |
|
| 2583 |
/** |
| 2584 |
* Inputs: (+/-1.0, +/-0.0). |
| 2585 |
* Expected: Pi/2 with the sign of the first argument. |
| 2586 |
*/ |
| 2587 |
static int |
| 2588 |
atan2_xZeroCases(void *args) |
| 2589 |
{ |
| 2590 |
const dd_to_d cases[] = { |
| 2591 |
{ 1.0, 0.0, M_PI / 2.0 }, |
| 2592 |
{ -1.0, 0.0, -M_PI / 2.0 }, |
| 2593 |
{ 1.0, -0.0, M_PI / 2.0 }, |
| 2594 |
{ -1.0, -0.0, -M_PI / 2.0 } |
| 2595 |
}; |
| 2596 |
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases)); |
| 2597 |
} |
| 2598 |
|
| 2599 |
/* Infinity cases */ |
| 2600 |
|
| 2601 |
/** |
| 2602 |
* Inputs: (+/-Infinity, +/-Infinity). |
| 2603 |
* Expected: |
| 2604 |
* - (+int, +inf) -> Pi/4, |
| 2605 |
* - (+int, -inf) -> 3Pi/4, |
| 2606 |
* - (-int, +inf) -> -Pi/4, |
| 2607 |
* - (-int, -inf) -> Pi. |
| 2608 |
*/ |
| 2609 |
static int |
| 2610 |
atan2_bothInfCases(void *args) |
| 2611 |
{ |
| 2612 |
dd_to_d cases[4]; |
| 2613 |
DD_TO_D_CASE(0, INFINITY, INFINITY, 1.0 * M_PI / 4.0); |
| 2614 |
DD_TO_D_CASE(1, INFINITY, -INFINITY, 3.0 * M_PI / 4.0); |
| 2615 |
DD_TO_D_CASE(2, -INFINITY, INFINITY, -1.0 * M_PI / 4.0); |
| 2616 |
DD_TO_D_CASE(3, -INFINITY, -INFINITY, -3.0 * M_PI / 4.0); |
| 2617 |
return helper_ddtod("SDL_atan2(bothInfCases)", SDL_atan2, cases, SDL_arraysize(cases)); |
| 2618 |
} |
| 2619 |
|
| 2620 |
/** |
| 2621 |
* Inputs: (+/-Infinity, +/-1.0). |
| 2622 |
* Expected: Pi/2 with the sign of the first argument. |
| 2623 |
*/ |
| 2624 |
static int |
| 2625 |
atan2_yInfCases(void *args) |
| 2626 |
{ |
| 2627 |
dd_to_d cases[4]; |
| 2628 |
DD_TO_D_CASE(0, INFINITY, 1.0, 1.0 * M_PI / 2.0); |
| 2629 |
DD_TO_D_CASE(1, INFINITY, -1.0, 1.0 * M_PI / 2.0); |
| 2630 |
DD_TO_D_CASE(2, -INFINITY, 1.0, -1.0 * M_PI / 2.0); |
| 2631 |
DD_TO_D_CASE(3, -INFINITY, -1.0, -1.0 * M_PI / 2.0); |
| 2632 |
return helper_ddtod("SDL_atan2(atan2_yInfCases)", SDL_atan2, cases, SDL_arraysize(cases)); |
| 2633 |
} |
| 2634 |
|
| 2635 |
/** |
| 2636 |
* Inputs: (+/-1.0, +/-Infinity). |
| 2637 |
* Expected: |
| 2638 |
* - (+/-1.0, +inf) -> +/-0.0 |
| 2639 |
* - (+/-1.0, -inf) -> +/-Pi. |
| 2640 |
*/ |
| 2641 |
static int |
| 2642 |
atan2_xInfCases(void *args) |
| 2643 |
{ |
| 2644 |
dd_to_d cases[4]; |
| 2645 |
DD_TO_D_CASE(0, 1.0, INFINITY, 0.0); |
| 2646 |
DD_TO_D_CASE(1, -1.0, INFINITY, -0.0); |
| 2647 |
DD_TO_D_CASE(2, 1.0, -INFINITY, M_PI); |
| 2648 |
DD_TO_D_CASE(3, -1.0, -INFINITY, -M_PI); |
| 2649 |
return helper_ddtod("atan2_xInfCases(atan2_yInfCases)", SDL_atan2, cases, SDL_arraysize(cases)); |
| 2650 |
} |
| 2651 |
|
| 2652 |
/* Miscelanious cases */ |
| 2653 |
|
| 2654 |
/** |
| 2655 |
* Inputs: NAN as either or both of the arguments. |
| 2656 |
* Expected: NAN is returned. |
| 2657 |
*/ |
| 2658 |
static int |
| 2659 |
atan2_nanCases(void *args) |
| 2660 |
{ |
| 2661 |
double result; |
| 2662 |
|
| 2663 |
result = SDL_atan2(NAN, NAN); |
| 2664 |
SDLTest_AssertCheck(isnan(result), |
| 2665 |
"Atan2(%f,%f), expected %f, got %f", |
| 2666 |
NAN, NAN, NAN, result); |
| 2667 |
|
| 2668 |
result = SDL_atan2(NAN, 1.0); |
| 2669 |
SDLTest_AssertCheck(isnan(result), |
| 2670 |
"Atan2(%f,%f), expected %f, got %f", |
| 2671 |
NAN, 1.0, NAN, result); |
| 2672 |
|
| 2673 |
result = SDL_atan2(1.0, NAN); |
| 2674 |
SDLTest_AssertCheck(isnan(result), |
| 2675 |
"Atan2(%f,%f), expected %f, got %f", |
| 2676 |
1.0, NAN, NAN, result); |
| 2677 |
|
| 2678 |
return TEST_COMPLETED; |
| 2679 |
} |
| 2680 |
|
| 2681 |
/** |
| 2682 |
* Inputs: (y, x) with x and y positive. |
| 2683 |
* Expected: Angle in the top right quadrant. |
| 2684 |
*/ |
| 2685 |
static int |
| 2686 |
atan2_topRightQuadrantTest(void *args) |
| 2687 |
{ |
| 2688 |
const dd_to_d top_right_cases[] = { |
| 2689 |
{ 1.0, 1.0, M_PI / 4.0 }, |
| 2690 |
{ SQRT3, 3.0, M_PI / 6.0 }, |
| 2691 |
{ SQRT3, 1.0, M_PI / 3.0 } |
| 2692 |
}; |
| 2693 |
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, top_right_cases, SDL_arraysize(top_right_cases)); |
| 2694 |
} |
| 2695 |
|
| 2696 |
/** |
| 2697 |
* Inputs: (y, x) with x negative and y positive. |
| 2698 |
* Expected: Angle in the top left quadrant. |
| 2699 |
*/ |
| 2700 |
static int |
| 2701 |
atan2_topLeftQuadrantTest(void *args) |
| 2702 |
{ |
| 2703 |
const dd_to_d top_left_cases[] = { |
| 2704 |
{ 1.0, -1.0, 3.0 * M_PI / 4.0 }, |
| 2705 |
{ SQRT3, -3.0, 5.0 * M_PI / 6.0 }, |
| 2706 |
{ SQRT3, -1.0, 2.0 * M_PI / 3.0 } |
| 2707 |
}; |
| 2708 |
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, top_left_cases, SDL_arraysize(top_left_cases)); |
| 2709 |
} |
| 2710 |
|
| 2711 |
/** |
| 2712 |
* Inputs: (y, x) with x positive and y negative. |
| 2713 |
* Expected: Angle in the bottom right quadrant. |
| 2714 |
*/ |
| 2715 |
static int |
| 2716 |
atan2_bottomRightQuadrantTest(void *args) |
| 2717 |
{ |
| 2718 |
const dd_to_d bottom_right_cases[] = { |
| 2719 |
{ -1.0, 1.0, -M_PI / 4 }, |
| 2720 |
{ -SQRT3, 3.0, -M_PI / 6.0 }, |
| 2721 |
{ -SQRT3, 1.0, -M_PI / 3.0 } |
| 2722 |
}; |
| 2723 |
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, bottom_right_cases, SDL_arraysize(bottom_right_cases)); |
| 2724 |
} |
| 2725 |
|
| 2726 |
/** |
| 2727 |
* Inputs: (y, x) with x and y negative. |
| 2728 |
* Expected: Angle in the bottom left quadrant. |
| 2729 |
*/ |
| 2730 |
static int |
| 2731 |
atan2_bottomLeftQuadrantTest(void *args) |
| 2732 |
{ |
| 2733 |
const dd_to_d bottom_left_cases[] = { |
| 2734 |
{ -1.0, -1.0, -3.0 * M_PI / 4.0 }, |
| 2735 |
{ -SQRT3, -3.0, -5.0 * M_PI / 6.0 }, |
| 2736 |
{ -SQRT3, -1.0, -4.0 * M_PI / 6.0 } |
| 2737 |
}; |
| 2738 |
return helper_ddtod_inexact("SDL_atan2", SDL_atan2, bottom_left_cases, SDL_arraysize(bottom_left_cases)); |
| 2739 |
} |
| 2740 |
|
| 2741 |
/* ================= Test References ================== */ |
| 2742 |
|
| 2743 |
/* SDL_floor test cases */ |
| 2744 |
|
| 2745 |
static const SDLTest_TestCaseReference floorTestInf = { |
| 2746 |
(SDLTest_TestCaseFp)floor_infCases, "floor_infCases", |
| 2747 |
"Checks positive and negative infinity", TEST_ENABLED |
| 2748 |
}; |
| 2749 |
static const SDLTest_TestCaseReference floorTestZero = { |
| 2750 |
(SDLTest_TestCaseFp)floor_zeroCases, "floor_zeroCases", |
| 2751 |
"Checks positive and negative zero", TEST_ENABLED |
| 2752 |
}; |
| 2753 |
static const SDLTest_TestCaseReference floorTestNan = { |
| 2754 |
(SDLTest_TestCaseFp)floor_nanCase, "floor_nanCase", |
| 2755 |
"Checks NAN", TEST_ENABLED |
| 2756 |
}; |
| 2757 |
static const SDLTest_TestCaseReference floorTestRound = { |
| 2758 |
(SDLTest_TestCaseFp)floor_roundNumbersCases, "floor_roundNumberCases", |
| 2759 |
"Checks a set of integral values", TEST_ENABLED |
| 2760 |
}; |
| 2761 |
static const SDLTest_TestCaseReference floorTestFraction = { |
| 2762 |
(SDLTest_TestCaseFp)floor_fractionCases, "floor_fractionCases", |
| 2763 |
"Checks a set of fractions", TEST_ENABLED |
| 2764 |
}; |
| 2765 |
static const SDLTest_TestCaseReference floorTestRange = { |
| 2766 |
(SDLTest_TestCaseFp)floor_rangeTest, "floor_rangeTest", |
| 2767 |
"Checks a range of positive integer", TEST_ENABLED |
| 2768 |
}; |
| 2769 |
|
| 2770 |
/* SDL_ceil test cases */ |
| 2771 |
|
| 2772 |
static const SDLTest_TestCaseReference ceilTestInf = { |
| 2773 |
(SDLTest_TestCaseFp)ceil_infCases, "ceil_infCases", |
| 2774 |
"Checks positive and negative infinity", TEST_ENABLED |
| 2775 |
}; |
| 2776 |
static const SDLTest_TestCaseReference ceilTestZero = { |
| 2777 |
(SDLTest_TestCaseFp)ceil_zeroCases, "ceil_zeroCases", |
| 2778 |
"Checks positive and negative zero", TEST_ENABLED |
| 2779 |
}; |
| 2780 |
static const SDLTest_TestCaseReference ceilTestNan = { |
| 2781 |
(SDLTest_TestCaseFp)ceil_nanCase, "ceil_nanCase", |
| 2782 |
"Checks NAN", TEST_ENABLED |
| 2783 |
}; |
| 2784 |
static const SDLTest_TestCaseReference ceilTestRound = { |
| 2785 |
(SDLTest_TestCaseFp)ceil_roundNumbersCases, "ceil_roundNumberCases", |
| 2786 |
"Checks a set of integral values", TEST_ENABLED |
| 2787 |
}; |
| 2788 |
static const SDLTest_TestCaseReference ceilTestFraction = { |
| 2789 |
(SDLTest_TestCaseFp)ceil_fractionCases, "ceil_fractionCases", |
| 2790 |
"Checks a set of fractions", TEST_ENABLED |
| 2791 |
}; |
| 2792 |
static const SDLTest_TestCaseReference ceilTestRange = { |
| 2793 |
(SDLTest_TestCaseFp)ceil_rangeTest, "ceil_rangeTest", |
| 2794 |
"Checks a range of positive integer", TEST_ENABLED |
| 2795 |
}; |
| 2796 |
|
| 2797 |
/* SDL_trunc test cases */ |
| 2798 |
|
| 2799 |
static const SDLTest_TestCaseReference truncTestInf = { |
| 2800 |
(SDLTest_TestCaseFp)trunc_infCases, "trunc_infCases", |
| 2801 |
"Checks positive and negative infinity", TEST_ENABLED |
| 2802 |
}; |
| 2803 |
static const SDLTest_TestCaseReference truncTestZero = { |
| 2804 |
(SDLTest_TestCaseFp)trunc_zeroCases, "trunc_zeroCases", |
| 2805 |
"Checks positive and negative zero", TEST_ENABLED |
| 2806 |
}; |
| 2807 |
static const SDLTest_TestCaseReference truncTestNan = { |
| 2808 |
(SDLTest_TestCaseFp)trunc_nanCase, "trunc_nanCase", |
| 2809 |
"Checks NAN", TEST_ENABLED |
| 2810 |
}; |
| 2811 |
static const SDLTest_TestCaseReference truncTestRound = { |
| 2812 |
(SDLTest_TestCaseFp)trunc_roundNumbersCases, "trunc_roundNumberCases", |
| 2813 |
"Checks a set of integral values", TEST_ENABLED |
| 2814 |
}; |
| 2815 |
static const SDLTest_TestCaseReference truncTestFraction = { |
| 2816 |
(SDLTest_TestCaseFp)trunc_fractionCases, "trunc_fractionCases", |
| 2817 |
"Checks a set of fractions", TEST_ENABLED |
| 2818 |
}; |
| 2819 |
static const SDLTest_TestCaseReference truncTestRange = { |
| 2820 |
(SDLTest_TestCaseFp)trunc_rangeTest, "trunc_rangeTest", |
| 2821 |
"Checks a range of positive integer", TEST_ENABLED |
| 2822 |
}; |
| 2823 |
|
| 2824 |
/* SDL_round test cases */ |
| 2825 |
|
| 2826 |
static const SDLTest_TestCaseReference roundTestInf = { |
| 2827 |
(SDLTest_TestCaseFp)round_infCases, "round_infCases", |
| 2828 |
"Checks positive and negative infinity", TEST_ENABLED |
| 2829 |
}; |
| 2830 |
static const SDLTest_TestCaseReference roundTestZero = { |
| 2831 |
(SDLTest_TestCaseFp)round_zeroCases, "round_zeroCases", |
| 2832 |
"Checks positive and negative zero", TEST_ENABLED |
| 2833 |
}; |
| 2834 |
static const SDLTest_TestCaseReference roundTestNan = { |
| 2835 |
(SDLTest_TestCaseFp)round_nanCase, "round_nanCase", |
| 2836 |
"Checks NAN", TEST_ENABLED |
| 2837 |
}; |
| 2838 |
static const SDLTest_TestCaseReference roundTestRound = { |
| 2839 |
(SDLTest_TestCaseFp)round_roundNumbersCases, "round_roundNumberCases", |
| 2840 |
"Checks a set of integral values", TEST_ENABLED |
| 2841 |
}; |
| 2842 |
static const SDLTest_TestCaseReference roundTestFraction = { |
| 2843 |
(SDLTest_TestCaseFp)round_fractionCases, "round_fractionCases", |
| 2844 |
"Checks a set of fractions", TEST_ENABLED |
| 2845 |
}; |
| 2846 |
static const SDLTest_TestCaseReference roundTestRange = { |
| 2847 |
(SDLTest_TestCaseFp)round_rangeTest, "round_rangeTest", |
| 2848 |
"Checks a range of positive integer", TEST_ENABLED |
| 2849 |
}; |
| 2850 |
|
| 2851 |
/* SDL_fabs test cases */ |
| 2852 |
|
| 2853 |
static const SDLTest_TestCaseReference fabsTestInf = { |
| 2854 |
(SDLTest_TestCaseFp)fabs_infCases, "fabs_infCases", |
| 2855 |
"Checks positive and negative infinity", TEST_ENABLED |
| 2856 |
}; |
| 2857 |
static const SDLTest_TestCaseReference fabsTestZero = { |
| 2858 |
(SDLTest_TestCaseFp)fabs_zeroCases, "fabs_zeroCases", |
| 2859 |
"Checks positive and negative zero", TEST_ENABLED |
| 2860 |
}; |
| 2861 |
static const SDLTest_TestCaseReference fabsTestNan = { |
| 2862 |
(SDLTest_TestCaseFp)fabs_nanCase, "fabs_nanCase", |
| 2863 |
"Checks NAN", TEST_ENABLED |
| 2864 |
}; |
| 2865 |
static const SDLTest_TestCaseReference fabsTestRange = { |
| 2866 |
(SDLTest_TestCaseFp)fabs_rangeTest, "fabs_rangeTest", |
| 2867 |
"Checks a range of positive integer", TEST_ENABLED |
| 2868 |
}; |
| 2869 |
|
| 2870 |
/* SDL_copysign test cases */ |
| 2871 |
|
| 2872 |
static const SDLTest_TestCaseReference copysignTestInf = { |
| 2873 |
(SDLTest_TestCaseFp)copysign_infCases, "copysign_infCases", |
| 2874 |
"Checks positive and negative infinity", TEST_ENABLED |
| 2875 |
}; |
| 2876 |
static const SDLTest_TestCaseReference copysignTestZero = { |
| 2877 |
(SDLTest_TestCaseFp)copysign_zeroCases, "copysign_zeroCases", |
| 2878 |
"Checks positive and negative zero", TEST_ENABLED |
| 2879 |
}; |
| 2880 |
static const SDLTest_TestCaseReference copysignTestNan = { |
| 2881 |
(SDLTest_TestCaseFp)copysign_nanCases, "copysign_nanCases", |
| 2882 |
"Checks NANs", TEST_ENABLED |
| 2883 |
}; |
| 2884 |
static const SDLTest_TestCaseReference copysignTestRange = { |
| 2885 |
(SDLTest_TestCaseFp)copysign_rangeTest, "copysign_rangeTest", |
| 2886 |
"Checks a range of positive integer", TEST_ENABLED |
| 2887 |
}; |
| 2888 |
|
| 2889 |
/* SDL_fmod test cases */ |
| 2890 |
|
| 2891 |
static const SDLTest_TestCaseReference fmodTestDivOfInf = { |
| 2892 |
(SDLTest_TestCaseFp)fmod_divOfInfCases, "fmod_divOfInfCases", |
| 2893 |
"Checks division of positive and negative infinity", TEST_ENABLED |
| 2894 |
}; |
| 2895 |
static const SDLTest_TestCaseReference fmodTestDivByInf = { |
| 2896 |
(SDLTest_TestCaseFp)fmod_divByInfCases, "fmod_divByInfCases", |
| 2897 |
"Checks division by positive and negative infinity", TEST_ENABLED |
| 2898 |
}; |
| 2899 |
static const SDLTest_TestCaseReference fmodTestDivOfZero = { |
| 2900 |
(SDLTest_TestCaseFp)fmod_divOfZeroCases, "fmod_divOfZeroCases", |
| 2901 |
"Checks division of positive and negative zero", TEST_ENABLED |
| 2902 |
}; |
| 2903 |
static const SDLTest_TestCaseReference fmodTestDivByZero = { |
| 2904 |
(SDLTest_TestCaseFp)fmod_divByZeroCases, "fmod_divByZeroCases", |
| 2905 |
"Checks division by positive and negative zero", TEST_ENABLED |
| 2906 |
}; |
| 2907 |
static const SDLTest_TestCaseReference fmodTestNan = { |
| 2908 |
(SDLTest_TestCaseFp)fmod_nanCases, "fmod_nanCases", |
| 2909 |
"Checks NANs", TEST_ENABLED |
| 2910 |
}; |
| 2911 |
static const SDLTest_TestCaseReference fmodTestRegular = { |
| 2912 |
(SDLTest_TestCaseFp)fmod_regularCases, "fmod_regularCases", |
| 2913 |
"Checks a set of regular values", TEST_ENABLED |
| 2914 |
}; |
| 2915 |
static const SDLTest_TestCaseReference fmodTestRange = { |
| 2916 |
(SDLTest_TestCaseFp)fmod_rangeTest, "fmod_rangeTest", |
| 2917 |
"Checks a range of positive integer", TEST_ENABLED |
| 2918 |
}; |
| 2919 |
|
| 2920 |
/* SDL_exp test cases */ |
| 2921 |
|
| 2922 |
static const SDLTest_TestCaseReference expTestInf = { |
| 2923 |
(SDLTest_TestCaseFp)exp_infCases, "exp_infCases", |
| 2924 |
"Checks positive and negative infinity", TEST_ENABLED |
| 2925 |
}; |
| 2926 |
static const SDLTest_TestCaseReference expTestZero = { |
| 2927 |
(SDLTest_TestCaseFp)exp_zeroCases, "exp_zeroCases", |
| 2928 |
"Checks for positive and negative zero", TEST_ENABLED |
| 2929 |
}; |
| 2930 |
static const SDLTest_TestCaseReference expTestOverflow = { |
| 2931 |
(SDLTest_TestCaseFp)exp_overflowCase, "exp_overflowCase", |
| 2932 |
"Checks for overflow", TEST_ENABLED |
| 2933 |
}; |
| 2934 |
static const SDLTest_TestCaseReference expTestBase = { |
| 2935 |
(SDLTest_TestCaseFp)exp_baseCase, "exp_baseCase", |
| 2936 |
"Checks the base case", TEST_ENABLED |
| 2937 |
}; |
| 2938 |
static const SDLTest_TestCaseReference expTestRegular = { |
| 2939 |
(SDLTest_TestCaseFp)exp_regularCases, "exp_regularCases", |
| 2940 |
"Checks a set of regular values", TEST_ENABLED |
| 2941 |
}; |
| 2942 |
|
| 2943 |
/* SDL_log test cases */ |
| 2944 |
|
| 2945 |
static const SDLTest_TestCaseReference logTestLimit = { |
| 2946 |
(SDLTest_TestCaseFp)log_limitCases, "log_limitCases", |
| 2947 |
"Checks the domain limits", TEST_ENABLED |
| 2948 |
}; |
| 2949 |
static const SDLTest_TestCaseReference logTestNan = { |
| 2950 |
(SDLTest_TestCaseFp)log_nanCases, "log_nanCases", |
| 2951 |
"Checks NAN and negative values", TEST_ENABLED |
| 2952 |
}; |
| 2953 |
static const SDLTest_TestCaseReference logTestBase = { |
| 2954 |
(SDLTest_TestCaseFp)log_baseCases, "log_baseCases", |
| 2955 |
"Checks the base cases", TEST_ENABLED |
| 2956 |
}; |
| 2957 |
static const SDLTest_TestCaseReference logTestRegular = { |
| 2958 |
(SDLTest_TestCaseFp)log_regularCases, "log_regularCases", |
| 2959 |
"Checks a set of regular values", TEST_ENABLED |
| 2960 |
}; |
| 2961 |
|
| 2962 |
/* SDL_log10 test cases */ |
| 2963 |
|
| 2964 |
static const SDLTest_TestCaseReference log10TestLimit = { |
| 2965 |
(SDLTest_TestCaseFp)log10_limitCases, "log10_limitCases", |
| 2966 |
"Checks the domain limits", TEST_ENABLED |
| 2967 |
}; |
| 2968 |
static const SDLTest_TestCaseReference log10TestNan = { |
| 2969 |
(SDLTest_TestCaseFp)log10_nanCases, "log10_nanCases", |
| 2970 |
"Checks NAN and negative values", TEST_ENABLED |
| 2971 |
}; |
| 2972 |
static const SDLTest_TestCaseReference log10TestBase = { |
| 2973 |
(SDLTest_TestCaseFp)log10_baseCases, "log10_baseCases", |
| 2974 |
"Checks the base cases", TEST_ENABLED |
| 2975 |
}; |
| 2976 |
static const SDLTest_TestCaseReference log10TestRegular = { |
| 2977 |
(SDLTest_TestCaseFp)log10_regularCases, "log10_regularCases", |
| 2978 |
"Checks a set of regular values", TEST_ENABLED |
| 2979 |
}; |
| 2980 |
|
| 2981 |
/* SDL_pow test cases */ |
| 2982 |
|
| 2983 |
static const SDLTest_TestCaseReference powTestExpInf1 = { |
| 2984 |
(SDLTest_TestCaseFp)pow_baseNOneExpInfCases, "pow_baseNOneExpInfCases", |
| 2985 |
"Checks for pow(-1, +/-inf)", TEST_ENABLED |
| 2986 |
}; |
| 2987 |
static const SDLTest_TestCaseReference powTestExpInf2 = { |
| 2988 |
(SDLTest_TestCaseFp)pow_baseZeroExpNInfCases, "pow_baseZeroExpNInfCases", |
| 2989 |
"Checks for pow(+/-0, -inf)", TEST_ENABLED |
| 2990 |
}; |
| 2991 |
static const SDLTest_TestCaseReference powTestExpInf3 = { |
| 2992 |
(SDLTest_TestCaseFp)pow_expInfCases, "pow_expInfCases", |
| 2993 |
"Checks for pow(x, +/-inf)", TEST_ENABLED |
| 2994 |
}; |
| 2995 |
static const SDLTest_TestCaseReference powTestBaseInf1 = { |
| 2996 |
(SDLTest_TestCaseFp)pow_basePInfCases, "pow_basePInfCases", |
| 2997 |
"Checks for pow(inf, x)", TEST_ENABLED |
| 2998 |
}; |
| 2999 |
static const SDLTest_TestCaseReference powTestBaseInf2 = { |
| 3000 |
(SDLTest_TestCaseFp)pow_baseNInfCases, "pow_baseNInfCases", |
| 3001 |
"Checks for pow(-inf, x)", TEST_ENABLED |
| 3002 |
}; |
| 3003 |
static const SDLTest_TestCaseReference powTestNan1 = { |
| 3004 |
(SDLTest_TestCaseFp)pow_badOperationCase, "pow_badOperationCase", |
| 3005 |
"Checks for negative finite base and non-integer finite exponent", TEST_ENABLED |
| 3006 |
}; |
| 3007 |
static const SDLTest_TestCaseReference powTestNan2 = { |
| 3008 |
(SDLTest_TestCaseFp)pow_base1ExpNanCase, "pow_base1ExpNanCase", |
| 3009 |
"Checks for pow(1.0, NAN)", TEST_ENABLED |
| 3010 |
}; |
| 3011 |
static const SDLTest_TestCaseReference powTestNan3 = { |
| 3012 |
(SDLTest_TestCaseFp)pow_baseNanExp0Cases, "pow_baseNanExp0Cases", |
| 3013 |
"Checks for pow(NAN, +/-0)", TEST_ENABLED |
| 3014 |
}; |
| 3015 |
static const SDLTest_TestCaseReference powTestNan4 = { |
| 3016 |
(SDLTest_TestCaseFp)pow_nanArgsCases, "pow_nanArgsCases", |
| 3017 |
"Checks for pow(x, y) with either x or y being NAN", TEST_ENABLED |
| 3018 |
}; |
| 3019 |
static const SDLTest_TestCaseReference powTestZero1 = { |
| 3020 |
(SDLTest_TestCaseFp)pow_baseNZeroExpOddCases, "pow_baseNZeroExpOddCases", |
| 3021 |
"Checks for pow(-0.0, y), with y an odd integer.", TEST_ENABLED |
| 3022 |
}; |
| 3023 |
static const SDLTest_TestCaseReference powTestZero2 = { |
| 3024 |
(SDLTest_TestCaseFp)pow_basePZeroExpOddCases, "pow_basePZeroExpOddCases", |
| 3025 |
"Checks for pow(0.0, y), with y an odd integer.", TEST_ENABLED |
| 3026 |
}; |
| 3027 |
static const SDLTest_TestCaseReference powTestZero3 = { |
| 3028 |
(SDLTest_TestCaseFp)pow_baseNZeroCases, "pow_baseNZeroCases", |
| 3029 |
"Checks for pow(-0.0, y), with y finite and even or non-integer number", TEST_ENABLED |
| 3030 |
}; |
| 3031 |
static const SDLTest_TestCaseReference powTestZero4 = { |
| 3032 |
(SDLTest_TestCaseFp)pow_basePZeroCases, "pow_basePZeroCases", |
| 3033 |
"Checks for pow(0.0, y), with y finite and even or non-integer number", TEST_ENABLED |
| 3034 |
}; |
| 3035 |
static const SDLTest_TestCaseReference powTestRegular = { |
| 3036 |
(SDLTest_TestCaseFp)pow_regularCases, "pow_regularCases", |
| 3037 |
"Checks a set of regular values", TEST_ENABLED |
| 3038 |
}; |
| 3039 |
static const SDLTest_TestCaseReference powTestPowOf2 = { |
| 3040 |
(SDLTest_TestCaseFp)pow_powerOfTwo, "pow_powerOfTwo", |
| 3041 |
"Checks the powers of two from 1 to 8", TEST_ENABLED |
| 3042 |
}; |
| 3043 |
static const SDLTest_TestCaseReference powTestRange = { |
| 3044 |
(SDLTest_TestCaseFp)pow_rangeTest, "pow_rangeTest", |
| 3045 |
"Checks a range of positive integer to the power of 0", TEST_ENABLED |
| 3046 |
}; |
| 3047 |
|
| 3048 |
/* SDL_sqrt test cases */ |
| 3049 |
|
| 3050 |
static const SDLTest_TestCaseReference sqrtTestInf = { |
| 3051 |
(SDLTest_TestCaseFp)sqrt_infCase, "sqrt_infCase", |
| 3052 |
"Checks positive infinity", TEST_ENABLED |
| 3053 |
}; |
| 3054 |
static const SDLTest_TestCaseReference sqrtTestNan = { |
| 3055 |
(SDLTest_TestCaseFp)sqrt_nanCase, "sqrt_nanCase", |
| 3056 |
"Checks NAN", TEST_ENABLED |
| 3057 |
}; |
| 3058 |
static const SDLTest_TestCaseReference sqrtTestDomain = { |
| 3059 |
(SDLTest_TestCaseFp)sqrt_outOfDomainCases, "sqrt_outOfDomainCases", |
| 3060 |
"Checks for values out of the domain", TEST_ENABLED |
| 3061 |
}; |
| 3062 |
static const SDLTest_TestCaseReference sqrtTestBase = { |
| 3063 |
(SDLTest_TestCaseFp)sqrt_baseCases, "sqrt_baseCases", |
| 3064 |
"Checks the base cases", TEST_ENABLED |
| 3065 |
}; |
| 3066 |
static const SDLTest_TestCaseReference sqrtTestRegular = { |
| 3067 |
(SDLTest_TestCaseFp)sqrt_regularCases, "sqrt_regularCases", |
| 3068 |
"Checks a set of regular values", TEST_ENABLED |
| 3069 |
}; |
| 3070 |
|
| 3071 |
/* SDL_scalbn test cases */ |
| 3072 |
|
| 3073 |
static const SDLTest_TestCaseReference scalbnTestInf = { |
| 3074 |
(SDLTest_TestCaseFp)scalbn_infCases, "scalbn_infCases", |
| 3075 |
"Checks positive and negative infinity arg", TEST_ENABLED |
| 3076 |
}; |
| 3077 |
static const SDLTest_TestCaseReference scalbnTestBaseZero = { |
| 3078 |
(SDLTest_TestCaseFp)scalbn_baseZeroCases, "scalbn_baseZeroCases", |
| 3079 |
"Checks for positive and negative zero arg", TEST_ENABLED |
| 3080 |
}; |
| 3081 |
static const SDLTest_TestCaseReference scalbnTestExpZero = { |
| 3082 |
(SDLTest_TestCaseFp)scalbn_expZeroCase, "scalbn_expZeroCase", |
| 3083 |
"Checks for zero exp", TEST_ENABLED |
| 3084 |
}; |
| 3085 |
static const SDLTest_TestCaseReference scalbnTestNan = { |
| 3086 |
(SDLTest_TestCaseFp)scalbn_nanCase, "scalbn_nanCase", |
| 3087 |
"Checks NAN", TEST_ENABLED |
| 3088 |
}; |
| 3089 |
static const SDLTest_TestCaseReference scalbnTestRegular = { |
| 3090 |
(SDLTest_TestCaseFp)scalbn_regularCases, "scalbn_regularCases", |
| 3091 |
"Checks a set of regular cases", TEST_ENABLED |
| 3092 |
}; |
| 3093 |
|
| 3094 |
/* SDL_cos test cases */ |
| 3095 |
|
| 3096 |
static const SDLTest_TestCaseReference cosTestInf = { |
| 3097 |
(SDLTest_TestCaseFp)cos_infCases, "cos_infCases", |
| 3098 |
"Checks for positive and negative infinity", TEST_ENABLED |
| 3099 |
}; |
| 3100 |
static const SDLTest_TestCaseReference cosTestNan = { |
| 3101 |
(SDLTest_TestCaseFp)cos_nanCase, "cos_nanCase", |
| 3102 |
"Checks NAN", TEST_ENABLED |
| 3103 |
}; |
| 3104 |
static const SDLTest_TestCaseReference cosTestRegular = { |
| 3105 |
(SDLTest_TestCaseFp)cos_regularCases, "cos_regularCases", |
| 3106 |
"Checks a set of regular cases", TEST_ENABLED |
| 3107 |
}; |
| 3108 |
static const SDLTest_TestCaseReference cosTestPrecision = { |
| 3109 |
(SDLTest_TestCaseFp)cos_precisionTest, "cos_precisionTest", |
| 3110 |
"Checks cosine precision", TEST_ENABLED |
| 3111 |
}; |
| 3112 |
static const SDLTest_TestCaseReference cosTestRange = { |
| 3113 |
(SDLTest_TestCaseFp)cos_rangeTest, "cos_rangeTest", |
| 3114 |
"Checks a range of positive integer", TEST_ENABLED |
| 3115 |
}; |
| 3116 |
|
| 3117 |
/* SDL_sin test cases */ |
| 3118 |
|
| 3119 |
static const SDLTest_TestCaseReference sinTestInf = { |
| 3120 |
(SDLTest_TestCaseFp)sin_infCases, "sin_infCases", |
| 3121 |
"Checks for positive and negative infinity", TEST_ENABLED |
| 3122 |
}; |
| 3123 |
static const SDLTest_TestCaseReference sinTestNan = { |
| 3124 |
(SDLTest_TestCaseFp)sin_nanCase, "sin_nanCase", |
| 3125 |
"Checks NAN", TEST_ENABLED |
| 3126 |
}; |
| 3127 |
static const SDLTest_TestCaseReference sinTestRegular = { |
| 3128 |
(SDLTest_TestCaseFp)sin_regularCases, "sin_regularCases", |
| 3129 |
"Checks a set of regular cases", TEST_ENABLED |
| 3130 |
}; |
| 3131 |
static const SDLTest_TestCaseReference sinTestPrecision = { |
| 3132 |
(SDLTest_TestCaseFp)sin_precisionTest, "sin_precisionTest", |
| 3133 |
"Checks sine precision", TEST_ENABLED |
| 3134 |
}; |
| 3135 |
static const SDLTest_TestCaseReference sinTestRange = { |
| 3136 |
(SDLTest_TestCaseFp)sin_rangeTest, "sin_rangeTest", |
| 3137 |
"Checks a range of positive integer", TEST_ENABLED |
| 3138 |
}; |
| 3139 |
|
| 3140 |
/* SDL_tan test cases */ |
| 3141 |
|
| 3142 |
static const SDLTest_TestCaseReference tanTestInf = { |
| 3143 |
(SDLTest_TestCaseFp)tan_infCases, "tan_infCases", |
| 3144 |
"Checks for positive and negative infinity", TEST_ENABLED |
| 3145 |
}; |
| 3146 |
static const SDLTest_TestCaseReference tanTestNan = { |
| 3147 |
(SDLTest_TestCaseFp)tan_nanCase, "tan_nanCase", |
| 3148 |
"Checks NAN", TEST_ENABLED |
| 3149 |
}; |
| 3150 |
static const SDLTest_TestCaseReference tanTestZero = { |
| 3151 |
(SDLTest_TestCaseFp)tan_zeroCases, "tan_zeroCases", |
| 3152 |
"Checks a set of regular cases", TEST_ENABLED |
| 3153 |
}; |
| 3154 |
static const SDLTest_TestCaseReference tanTestPrecision = { |
| 3155 |
(SDLTest_TestCaseFp)tan_precisionTest, "tan_precisionTest", |
| 3156 |
"Checks tangent precision", TEST_ENABLED |
| 3157 |
}; |
| 3158 |
|
| 3159 |
/* SDL_acos test cases */ |
| 3160 |
|
| 3161 |
static const SDLTest_TestCaseReference acosTestLimit = { |
| 3162 |
(SDLTest_TestCaseFp)acos_limitCases, "acos_limitCases", |
| 3163 |
"Checks the edge of the domain (+/-1)", TEST_ENABLED |
| 3164 |
}; |
| 3165 |
static const SDLTest_TestCaseReference acosTestOutOfDomain = { |
| 3166 |
(SDLTest_TestCaseFp)acos_outOfDomainCases, "acos_outOfDomainCases", |
| 3167 |
"Checks values outside the domain", TEST_ENABLED |
| 3168 |
}; |
| 3169 |
static const SDLTest_TestCaseReference acosTestNan = { |
| 3170 |
(SDLTest_TestCaseFp)acos_nanCase, "acos_nanCase", |
| 3171 |
"Checks NAN", TEST_ENABLED |
| 3172 |
}; |
| 3173 |
static const SDLTest_TestCaseReference acosTestPrecision = { |
| 3174 |
(SDLTest_TestCaseFp)acos_precisionTest, "acos_precisionTest", |
| 3175 |
"Checks acos precision", TEST_ENABLED |
| 3176 |
}; |
| 3177 |
|
| 3178 |
/* SDL_asin test cases */ |
| 3179 |
|
| 3180 |
static const SDLTest_TestCaseReference asinTestLimit = { |
| 3181 |
(SDLTest_TestCaseFp)asin_limitCases, "asin_limitCases", |
| 3182 |
"Checks the edge of the domain (+/-1)", TEST_ENABLED |
| 3183 |
}; |
| 3184 |
static const SDLTest_TestCaseReference asinTestOutOfDomain = { |
| 3185 |
(SDLTest_TestCaseFp)asin_outOfDomainCases, "asin_outOfDomainCases", |
| 3186 |
"Checks values outside the domain", TEST_ENABLED |
| 3187 |
}; |
| 3188 |
static const SDLTest_TestCaseReference asinTestNan = { |
| 3189 |
(SDLTest_TestCaseFp)asin_nanCase, "asin_nanCase", |
| 3190 |
"Checks NAN", TEST_ENABLED |
| 3191 |
}; |
| 3192 |
static const SDLTest_TestCaseReference asinTestPrecision = { |
| 3193 |
(SDLTest_TestCaseFp)asin_precisionTest, "asin_precisionTest", |
| 3194 |
"Checks asin precision", TEST_ENABLED |
| 3195 |
}; |
| 3196 |
|
| 3197 |
/* SDL_atan test cases */ |
| 3198 |
|
| 3199 |
static const SDLTest_TestCaseReference atanTestLimit = { |
| 3200 |
(SDLTest_TestCaseFp)atan_limitCases, "atan_limitCases", |
| 3201 |
"Checks the edge of the domain (+/-Infinity)", TEST_ENABLED |
| 3202 |
}; |
| 3203 |
static const SDLTest_TestCaseReference atanTestZero = { |
| 3204 |
(SDLTest_TestCaseFp)atan_zeroCases, "atan_zeroCases", |
| 3205 |
"Checks for positive and negative zero", TEST_ENABLED |
| 3206 |
}; |
| 3207 |
static const SDLTest_TestCaseReference atanTestNan = { |
| 3208 |
(SDLTest_TestCaseFp)atan_nanCase, "atan_nanCase", |
| 3209 |
"Checks NAN", TEST_ENABLED |
| 3210 |
}; |
| 3211 |
static const SDLTest_TestCaseReference atanTestPrecision = { |
| 3212 |
(SDLTest_TestCaseFp)atan_precisionTest, "atan_precisionTest", |
| 3213 |
"Checks atan precision", TEST_ENABLED |
| 3214 |
}; |
| 3215 |
|
| 3216 |
/* SDL_atan2 test cases */ |
| 3217 |
|
| 3218 |
static const SDLTest_TestCaseReference atan2TestZero1 = { |
| 3219 |
(SDLTest_TestCaseFp)atan2_bothZeroCases, "atan2_bothZeroCases", |
| 3220 |
"Checks for both arguments being zero", TEST_ENABLED |
| 3221 |
}; |
| 3222 |
static const SDLTest_TestCaseReference atan2TestZero2 = { |
| 3223 |
(SDLTest_TestCaseFp)atan2_yZeroCases, "atan2_yZeroCases", |
| 3224 |
"Checks for y=0", TEST_ENABLED |
| 3225 |
}; |
| 3226 |
static const SDLTest_TestCaseReference atan2TestZero3 = { |
| 3227 |
(SDLTest_TestCaseFp)atan2_xZeroCases, "atan2_xZeroCases", |
| 3228 |
"Checks for x=0", TEST_ENABLED |
| 3229 |
}; |
| 3230 |
static const SDLTest_TestCaseReference atan2TestInf1 = { |
| 3231 |
(SDLTest_TestCaseFp)atan2_bothInfCases, "atan2_bothInfCases", |
| 3232 |
"Checks for both arguments being infinity", TEST_ENABLED |
| 3233 |
}; |
| 3234 |
static const SDLTest_TestCaseReference atan2TestInf2 = { |
| 3235 |
(SDLTest_TestCaseFp)atan2_yInfCases, "atan2_yInfCases", |
| 3236 |
"Checks for y=0", TEST_ENABLED |
| 3237 |
}; |
| 3238 |
static const SDLTest_TestCaseReference atan2TestInf3 = { |
| 3239 |
(SDLTest_TestCaseFp)atan2_xInfCases, "atan2_xInfCases", |
| 3240 |
"Checks for x=0", TEST_ENABLED |
| 3241 |
}; |
| 3242 |
static const SDLTest_TestCaseReference atan2TestNan = { |
| 3243 |
(SDLTest_TestCaseFp)atan2_nanCases, "atan2_nanCases", |
| 3244 |
"Checks NANs", TEST_ENABLED |
| 3245 |
}; |
| 3246 |
static const SDLTest_TestCaseReference atan2TestQuadrantTopRight = { |
| 3247 |
(SDLTest_TestCaseFp)atan2_topRightQuadrantTest, "atan2_topRightQuadrantTest", |
| 3248 |
"Checks values in the top right quadrant", TEST_ENABLED |
| 3249 |
}; |
| 3250 |
static const SDLTest_TestCaseReference atan2TestQuadrantTopLeft = { |
| 3251 |
(SDLTest_TestCaseFp)atan2_topLeftQuadrantTest, "atan2_topLeftQuadrantTest", |
| 3252 |
"Checks values in the top left quadrant", TEST_ENABLED |
| 3253 |
}; |
| 3254 |
static const SDLTest_TestCaseReference atan2TestQuadrantBottomRight = { |
| 3255 |
(SDLTest_TestCaseFp)atan2_bottomRightQuadrantTest, "atan2_bottomRightQuadrantTest", |
| 3256 |
"Checks values in the bottom right quadrant", TEST_ENABLED |
| 3257 |
}; |
| 3258 |
static const SDLTest_TestCaseReference atan2TestQuadrantBottomLeft = { |
| 3259 |
(SDLTest_TestCaseFp)atan2_bottomLeftQuadrantTest, "atan2_bottomLeftQuadrantTest", |
| 3260 |
"Checks values in the bottom left quadrant", TEST_ENABLED |
| 3261 |
}; |
| 3262 |
|
| 3263 |
static const SDLTest_TestCaseReference *mathTests[] = { |
| 3264 |
&floorTestInf, &floorTestZero, &floorTestNan, |
| 3265 |
&floorTestRound, &floorTestFraction, &floorTestRange, |
| 3266 |
|
| 3267 |
&ceilTestInf, &ceilTestZero, &ceilTestNan, |
| 3268 |
&ceilTestRound, &ceilTestFraction, &ceilTestRange, |
| 3269 |
|
| 3270 |
&truncTestInf, &truncTestZero, &truncTestNan, |
| 3271 |
&truncTestRound, &truncTestFraction, &truncTestRange, |
| 3272 |
|
| 3273 |
&roundTestInf, &roundTestZero, &roundTestNan, |
| 3274 |
&roundTestRound, &roundTestFraction, &roundTestRange, |
| 3275 |
|
| 3276 |
&fabsTestInf, &fabsTestZero, &fabsTestNan, &fabsTestRange, |
| 3277 |
|
| 3278 |
©signTestInf, ©signTestZero, ©signTestNan, ©signTestRange, |
| 3279 |
|
| 3280 |
&fmodTestDivOfInf, &fmodTestDivByInf, &fmodTestDivOfZero, &fmodTestDivByZero, |
| 3281 |
&fmodTestNan, &fmodTestRegular, &fmodTestRange, |
| 3282 |
|
| 3283 |
&expTestInf, &expTestZero, &expTestOverflow, |
| 3284 |
&expTestBase, &expTestRegular, |
| 3285 |
|
| 3286 |
&logTestLimit, &logTestNan, |
| 3287 |
&logTestBase, &logTestRegular, |
| 3288 |
|
| 3289 |
&log10TestLimit, &log10TestNan, |
| 3290 |
&log10TestBase, &log10TestRegular, |
| 3291 |
|
| 3292 |
&powTestExpInf1, &powTestExpInf2, &powTestExpInf3, |
| 3293 |
&powTestBaseInf1, &powTestBaseInf2, |
| 3294 |
&powTestNan1, &powTestNan2, &powTestNan3, &powTestNan4, |
| 3295 |
&powTestZero1, &powTestZero2, &powTestZero3, &powTestZero4, |
| 3296 |
&powTestRegular, &powTestPowOf2, &powTestRange, |
| 3297 |
|
| 3298 |
&sqrtTestInf, &sqrtTestNan, &sqrtTestDomain, |
| 3299 |
&sqrtTestBase, &sqrtTestRegular, |
| 3300 |
|
| 3301 |
&scalbnTestInf, &scalbnTestBaseZero, &scalbnTestExpZero, |
| 3302 |
&scalbnTestNan, &scalbnTestRegular, |
| 3303 |
|
| 3304 |
&cosTestInf, &cosTestNan, &cosTestRegular, |
| 3305 |
&cosTestPrecision, &cosTestRange, |
| 3306 |
|
| 3307 |
&sinTestInf, &sinTestNan, &sinTestRegular, |
| 3308 |
&sinTestPrecision, &sinTestRange, |
| 3309 |
|
| 3310 |
&tanTestInf, &tanTestNan, &tanTestZero, &tanTestPrecision, |
| 3311 |
|
| 3312 |
&acosTestLimit, &acosTestOutOfDomain, &acosTestNan, &acosTestPrecision, |
| 3313 |
|
| 3314 |
&asinTestLimit, &asinTestOutOfDomain, &asinTestNan, &asinTestPrecision, |
| 3315 |
|
| 3316 |
&atanTestLimit, &atanTestZero, &atanTestNan, &atanTestPrecision, |
| 3317 |
|
| 3318 |
&atan2TestZero1, &atan2TestZero2, &atan2TestZero3, |
| 3319 |
&atan2TestInf1, &atan2TestInf2, &atan2TestInf3, |
| 3320 |
&atan2TestNan, &atan2TestQuadrantTopRight, &atan2TestQuadrantTopLeft, |
| 3321 |
&atan2TestQuadrantBottomRight, &atan2TestQuadrantBottomLeft, |
| 3322 |
|
| 3323 |
NULL |
| 3324 |
}; |
| 3325 |
|
| 3326 |
SDLTest_TestSuiteReference mathTestSuite = { "Math", NULL, mathTests, NULL }; |