testautomation_math.c 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408
  1. /**
  2. * Math test suite
  3. */
  4. #include <math.h>
  5. #include "SDL.h"
  6. #include "SDL_test.h"
  7. /* Range tests parameters */
  8. #define RANGE_TEST_ITERATIONS 10000000
  9. #define RANGE_TEST_STEP SDL_MAX_UINT32 / RANGE_TEST_ITERATIONS
  10. /* Define the Euler constant */
  11. #ifndef M_E
  12. #define EULER 2.7182818284590450907955982984276488423347473144531250
  13. #else
  14. #define EULER M_E
  15. #endif
  16. /* ================= Test Structs ================== */
  17. /**
  18. * Stores a single input and the expected result
  19. */
  20. typedef struct
  21. {
  22. double input;
  23. double expected;
  24. } d_to_d;
  25. /**
  26. * Stores a pair of inputs and the expected result
  27. */
  28. typedef struct
  29. {
  30. double x_input, y_input;
  31. double expected;
  32. } dd_to_d;
  33. /*
  34. NB: You cannot create an array of these structures containing INFINITY or NAN.
  35. On platforms such as OS/2, they are defined as 'extern const double' making them
  36. not compile-time constant.
  37. */
  38. /* ================= Test Helpers ================== */
  39. typedef double(SDLCALL *d_to_d_func)(double);
  40. typedef double(SDLCALL *dd_to_d_func)(double, double);
  41. /**
  42. * \brief Runs all the cases on a given function with a signature double -> double
  43. *
  44. * \param func_name, the name of the tested function.
  45. * \param func, the function to call.
  46. * \param cases, an array of all the cases.
  47. * \param cases_size, the size of the cases array.
  48. */
  49. static int
  50. helper_dtod(const char *func_name, d_to_d_func func,
  51. const d_to_d *cases, const size_t cases_size)
  52. {
  53. Uint32 i;
  54. for (i = 0; i < cases_size; i++) {
  55. const double result = func(cases[i].input);
  56. SDLTest_AssertCheck(result == cases[i].expected,
  57. "%s(%f), expected %f, got %f",
  58. func_name,
  59. cases[i].input,
  60. cases[i].expected, result);
  61. }
  62. return TEST_COMPLETED;
  63. }
  64. /**
  65. * \brief Runs all the cases on a given function with a signature (double, double) -> double
  66. *
  67. * \param func_name, the name of the tested function.
  68. * \param func, the function to call.
  69. * \param cases, an array of all the cases.
  70. * \param cases_size, the size of the cases array.
  71. */
  72. static int
  73. helper_ddtod(const char *func_name, dd_to_d_func func,
  74. const dd_to_d *cases, const size_t cases_size)
  75. {
  76. Uint32 i;
  77. for (i = 0; i < cases_size; i++) {
  78. const double result = func(cases[i].x_input, cases[i].y_input);
  79. SDLTest_AssertCheck(result == cases[i].expected,
  80. "%s(%f,%f), expected %f, got %f",
  81. func_name,
  82. cases[i].x_input, cases[i].y_input,
  83. cases[i].expected, result);
  84. }
  85. return TEST_COMPLETED;
  86. }
  87. /**
  88. * \brief Runs a range of values on a given function with a signature double -> double
  89. *
  90. * This function is only meant to test functions that returns the input value if it is
  91. * integral: f(x) -> x for x in N.
  92. *
  93. * \param func_name, the name of the tested function.
  94. * \param func, the function to call.
  95. */
  96. static int
  97. helper_range(const char *func_name, d_to_d_func func)
  98. {
  99. Uint32 i;
  100. double test_value = 0.0;
  101. SDLTest_AssertPass("%s: Testing a range of %u values with steps of %u",
  102. func_name,
  103. RANGE_TEST_ITERATIONS,
  104. RANGE_TEST_STEP);
  105. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  106. double result;
  107. /* These are tested elsewhere */
  108. if (isnan(test_value) || isinf(test_value)) {
  109. continue;
  110. }
  111. result = func(test_value);
  112. if (result != test_value) { /* Only log failures to save performances */
  113. SDLTest_AssertPass("%s(%.1f), expected %.1f, got %.1f",
  114. func_name, test_value,
  115. test_value, result);
  116. return TEST_ABORTED;
  117. }
  118. }
  119. return TEST_COMPLETED;
  120. }
  121. /* ================= Test Case Implementation ================== */
  122. /* SDL_floor tests functions */
  123. /**
  124. * \brief Checks positive and negative infinity.
  125. */
  126. static int
  127. floor_infCases(void *args)
  128. {
  129. double result;
  130. result = SDL_floor(INFINITY);
  131. SDLTest_AssertCheck(INFINITY == result,
  132. "Floor(%f), expected %f, got %f",
  133. INFINITY, INFINITY, result);
  134. result = SDL_floor(-INFINITY);
  135. SDLTest_AssertCheck(-INFINITY == result,
  136. "Floor(%f), expected %f, got %f",
  137. -INFINITY, -INFINITY, result);
  138. return TEST_COMPLETED;
  139. }
  140. /**
  141. * \brief Checks positive and negative zero.
  142. */
  143. static int
  144. floor_zeroCases(void *args)
  145. {
  146. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  147. return helper_dtod("Floor", SDL_floor, zero_cases, SDL_arraysize(zero_cases));
  148. }
  149. /**
  150. * \brief Checks the NaN case.
  151. */
  152. static int
  153. floor_nanCase(void *args)
  154. {
  155. const double result = SDL_floor(NAN);
  156. SDLTest_AssertCheck(isnan(result),
  157. "Floor(nan), expected nan, got %f",
  158. result);
  159. return TEST_COMPLETED;
  160. }
  161. /**
  162. * \brief Checks round values (x.0) for themselves
  163. */
  164. static int
  165. floor_roundNumbersCases(void *args)
  166. {
  167. const d_to_d round_cases[] = {
  168. { 1.0, 1.0 },
  169. { -1.0, -1.0 },
  170. { 15.0, 15.0 },
  171. { -15.0, -15.0 },
  172. { 125.0, 125.0 },
  173. { -125.0, -125.0 },
  174. { 1024.0, 1024.0 },
  175. { -1024.0, -1024.0 }
  176. };
  177. return helper_dtod("Floor", SDL_floor, round_cases, SDL_arraysize(round_cases));
  178. }
  179. /**
  180. * \brief Checks a set of fractions
  181. */
  182. static int
  183. floor_fractionCases(void *args)
  184. {
  185. const d_to_d frac_cases[] = {
  186. { 1.0 / 2.0, 0.0 },
  187. { -1.0 / 2.0, -1.0 },
  188. { 4.0 / 3.0, 1.0 },
  189. { -4.0 / 3.0, -2.0 },
  190. { 76.0 / 7.0, 10.0 },
  191. { -76.0 / 7.0, -11.0 },
  192. { 535.0 / 8.0, 66.0 },
  193. { -535.0 / 8.0, -67.0 },
  194. { 19357.0 / 53.0, 365.0 },
  195. { -19357.0 / 53.0, -366.0 }
  196. };
  197. return helper_dtod("Floor", SDL_floor, frac_cases, SDL_arraysize(frac_cases));
  198. }
  199. /**
  200. * \brief Checks a range of values between 0 and UINT32_MAX
  201. */
  202. static int
  203. floor_rangeTest(void *args)
  204. {
  205. return helper_range("Floor", SDL_floor);
  206. }
  207. /* SDL_ceil tests functions */
  208. /**
  209. * \brief Checks positive and negative infinity.
  210. */
  211. static int
  212. ceil_infCases(void *args)
  213. {
  214. double result;
  215. result = SDL_ceil(INFINITY);
  216. SDLTest_AssertCheck(INFINITY == result,
  217. "Ceil(%f), expected %f, got %f",
  218. INFINITY, INFINITY, result);
  219. result = SDL_ceil(-INFINITY);
  220. SDLTest_AssertCheck(-INFINITY == result,
  221. "Ceil(%f), expected %f, got %f",
  222. -INFINITY, -INFINITY, result);
  223. return TEST_COMPLETED;
  224. }
  225. /**
  226. * \brief Checks positive and negative zero.
  227. */
  228. static int
  229. ceil_zeroCases(void *args)
  230. {
  231. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  232. return helper_dtod("Ceil", SDL_ceil, zero_cases, SDL_arraysize(zero_cases));
  233. }
  234. /**
  235. * \brief Checks the NaN case.
  236. */
  237. static int
  238. ceil_nanCase(void *args)
  239. {
  240. const double result = SDL_ceil(NAN);
  241. SDLTest_AssertCheck(isnan(result),
  242. "Ceil(nan), expected nan, got %f",
  243. result);
  244. return TEST_COMPLETED;
  245. }
  246. /**
  247. * \brief Checks round values (x.0) for themselves
  248. */
  249. static int
  250. ceil_roundNumbersCases(void *args)
  251. {
  252. const d_to_d round_cases[] = {
  253. { 1.0, 1.0 },
  254. { -1.0, -1.0 },
  255. { 15.0, 15.0 },
  256. { -15.0, -15.0 },
  257. { 125.0, 125.0 },
  258. { -125.0, -125.0 },
  259. { 1024.0, 1024.0 },
  260. { -1024.0, -1024.0 }
  261. };
  262. return helper_dtod("Ceil", SDL_ceil, round_cases, SDL_arraysize(round_cases));
  263. }
  264. /**
  265. * \brief Checks a set of fractions
  266. */
  267. static int
  268. ceil_fractionCases(void *args)
  269. {
  270. const d_to_d frac_cases[] = {
  271. { 1.0 / 2.0, 1.0 },
  272. { -1.0 / 2.0, -0.0 },
  273. { 4.0 / 3.0, 2.0 },
  274. { -4.0 / 3.0, -1.0 },
  275. { 76.0 / 7.0, 11.0 },
  276. { -76.0 / 7.0, -10.0 },
  277. { 535.0 / 8.0, 67.0 },
  278. { -535.0 / 8.0, -66.0 },
  279. { 19357.0 / 53.0, 366.0 },
  280. { -19357.0 / 53.0, -365.0 }
  281. };
  282. return helper_dtod("Ceil", SDL_ceil, frac_cases, SDL_arraysize(frac_cases));
  283. }
  284. /**
  285. * \brief Checks a range of values between 0 and UINT32_MAX
  286. */
  287. static int
  288. ceil_rangeTest(void *args)
  289. {
  290. return helper_range("Ceil", SDL_ceil);
  291. }
  292. /* SDL_trunc tests functions */
  293. /**
  294. * \brief Checks positive and negative infinity.
  295. */
  296. static int
  297. trunc_infCases(void *args)
  298. {
  299. double result;
  300. result = SDL_trunc(INFINITY);
  301. SDLTest_AssertCheck(INFINITY == result,
  302. "Trunc(%f), expected %f, got %f",
  303. INFINITY, INFINITY, result);
  304. result = SDL_trunc(-INFINITY);
  305. SDLTest_AssertCheck(-INFINITY == result,
  306. "Trunc(%f), expected %f, got %f",
  307. -INFINITY, -INFINITY, result);
  308. return TEST_COMPLETED;
  309. }
  310. /**
  311. * \brief Checks positive and negative zero.
  312. */
  313. static int
  314. trunc_zeroCases(void *args)
  315. {
  316. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  317. return helper_dtod("Trunc", SDL_trunc, zero_cases, SDL_arraysize(zero_cases));
  318. }
  319. /**
  320. * \brief Checks the NaN case.
  321. */
  322. static int
  323. trunc_nanCase(void *args)
  324. {
  325. const double result = SDL_trunc(NAN);
  326. SDLTest_AssertCheck(isnan(result),
  327. "Trunc(nan), expected nan, got %f",
  328. result);
  329. return TEST_COMPLETED;
  330. }
  331. /**
  332. * \brief Checks round values (x.0) for themselves
  333. */
  334. static int
  335. trunc_roundNumbersCases(void *args)
  336. {
  337. const d_to_d round_cases[] = {
  338. { 1.0, 1.0 },
  339. { -1.0, -1.0 },
  340. { 15.0, 15.0 },
  341. { -15.0, -15.0 },
  342. { 125.0, 125.0 },
  343. { -125.0, -125.0 },
  344. { 1024.0, 1024.0 },
  345. { -1024.0, -1024.0 }
  346. };
  347. return helper_dtod("Trunc", SDL_trunc, round_cases, SDL_arraysize(round_cases));
  348. }
  349. /**
  350. * \brief Checks a set of fractions
  351. */
  352. static int
  353. trunc_fractionCases(void *args)
  354. {
  355. const d_to_d frac_cases[] = {
  356. { 1.0 / 2.0, 0.0 },
  357. { -1.0 / 2.0, -0.0 },
  358. { 4.0 / 3.0, 1.0 },
  359. { -4.0 / 3.0, -1.0 },
  360. { 76.0 / 7.0, 10.0 },
  361. { -76.0 / 7.0, -10.0 },
  362. { 535.0 / 8.0, 66.0 },
  363. { -535.0 / 8.0, -66.0 },
  364. { 19357.0 / 53.0, 365.0 },
  365. { -19357.0 / 53.0, -365.0 }
  366. };
  367. return helper_dtod("Trunc", SDL_trunc, frac_cases, SDL_arraysize(frac_cases));
  368. }
  369. /**
  370. * \brief Checks a range of values between 0 and UINT32_MAX
  371. */
  372. static int
  373. trunc_rangeTest(void *args)
  374. {
  375. return helper_range("Trunc", SDL_trunc);
  376. }
  377. /* SDL_round tests functions */
  378. /**
  379. * \brief Checks positive and negative infinity.
  380. */
  381. static int
  382. round_infCases(void *args)
  383. {
  384. double result;
  385. result = SDL_round(INFINITY);
  386. SDLTest_AssertCheck(INFINITY == result,
  387. "Round(%f), expected %f, got %f",
  388. INFINITY, INFINITY, result);
  389. result = SDL_round(-INFINITY);
  390. SDLTest_AssertCheck(-INFINITY == result,
  391. "Round(%f), expected %f, got %f",
  392. -INFINITY, -INFINITY, result);
  393. return TEST_COMPLETED;
  394. }
  395. /**
  396. * \brief Checks positive and negative zero.
  397. */
  398. static int
  399. round_zeroCases(void *args)
  400. {
  401. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  402. return helper_dtod("Round", SDL_round, zero_cases, SDL_arraysize(zero_cases));
  403. }
  404. /**
  405. * \brief Checks the NaN case.
  406. */
  407. static int
  408. round_nanCase(void *args)
  409. {
  410. const double result = SDL_round(NAN);
  411. SDLTest_AssertCheck(isnan(result),
  412. "Round(nan), expected nan, got %f",
  413. result);
  414. return TEST_COMPLETED;
  415. }
  416. /**
  417. * \brief Checks round values (x.0) for themselves
  418. */
  419. static int
  420. round_roundNumbersCases(void *args)
  421. {
  422. const d_to_d round_cases[] = {
  423. { 1.0, 1.0 },
  424. { -1.0, -1.0 },
  425. { 15.0, 15.0 },
  426. { -15.0, -15.0 },
  427. { 125.0, 125.0 },
  428. { -125.0, -125.0 },
  429. { 1024.0, 1024.0 },
  430. { -1024.0, -1024.0 }
  431. };
  432. return helper_dtod("Round", SDL_round, round_cases, SDL_arraysize(round_cases));
  433. }
  434. /**
  435. * \brief Checks a set of fractions
  436. */
  437. static int
  438. round_fractionCases(void *args)
  439. {
  440. const d_to_d frac_cases[] = {
  441. { 1.0 / 2.0, 1.0 },
  442. { -1.0 / 2.0, -1.0 },
  443. { 4.0 / 3.0, 1.0 },
  444. { -4.0 / 3.0, -1.0 },
  445. { 76.0 / 7.0, 11.0 },
  446. { -76.0 / 7.0, -11.0 },
  447. { 535.0 / 8.0, 67.0 },
  448. { -535.0 / 8.0, -67.0 },
  449. { 19357.0 / 53.0, 365.0 },
  450. { -19357.0 / 53.0, -365.0 }
  451. };
  452. return helper_dtod("Round", SDL_round, frac_cases, SDL_arraysize(frac_cases));
  453. }
  454. /**
  455. * \brief Checks a range of values between 0 and UINT32_MAX
  456. */
  457. static int
  458. round_rangeTest(void *args)
  459. {
  460. return helper_range("Round", SDL_round);
  461. }
  462. /* SDL_fabs tests functions */
  463. /**
  464. * \brief Checks positive and negative infinity.
  465. */
  466. static int
  467. fabs_infCases(void *args)
  468. {
  469. double result;
  470. result = SDL_fabs(INFINITY);
  471. SDLTest_AssertCheck(INFINITY == result,
  472. "Fabs(%f), expected %f, got %f",
  473. INFINITY, INFINITY, result);
  474. result = SDL_fabs(-INFINITY);
  475. SDLTest_AssertCheck(INFINITY == result,
  476. "Fabs(%f), expected %f, got %f",
  477. -INFINITY, INFINITY, result);
  478. return TEST_COMPLETED;
  479. }
  480. /**
  481. * \brief Checks positive and negative zero
  482. */
  483. static int
  484. fabs_zeroCases(void *args)
  485. {
  486. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, 0.0 } };
  487. return helper_dtod("Fabs", SDL_fabs, zero_cases, SDL_arraysize(zero_cases));
  488. }
  489. /**
  490. * \brief Checks the NaN case.
  491. */
  492. static int
  493. fabs_nanCase(void *args)
  494. {
  495. const double result = SDL_fabs(NAN);
  496. SDLTest_AssertCheck(isnan(result),
  497. "Fabs(nan), expected nan, got %f",
  498. result);
  499. return TEST_COMPLETED;
  500. }
  501. /**
  502. * \brief Checks a range of values between 0 and UINT32_MAX
  503. */
  504. static int
  505. fabs_rangeTest(void *args)
  506. {
  507. return helper_range("Fabs", SDL_fabs);
  508. }
  509. /* SDL_copysign tests functions */
  510. /**
  511. * \brief Checks positive and negative inifnity.
  512. */
  513. static int
  514. copysign_infCases(void *args)
  515. {
  516. double result;
  517. result = SDL_copysign(INFINITY, -1.0);
  518. SDLTest_AssertCheck(-INFINITY == result,
  519. "Copysign(%f,%.1f), expected %f, got %f",
  520. INFINITY, -1.0, -INFINITY, result);
  521. result = SDL_copysign(INFINITY, 1.0);
  522. SDLTest_AssertCheck(INFINITY == result,
  523. "Copysign(%f,%.1f), expected %f, got %f",
  524. INFINITY, 1.0, INFINITY, result);
  525. result = SDL_copysign(-INFINITY, -1.0);
  526. SDLTest_AssertCheck(-INFINITY == result,
  527. "Copysign(%f,%.1f), expected %f, got %f",
  528. -INFINITY, -1.0, -INFINITY, result);
  529. result = SDL_copysign(-INFINITY, 1.0);
  530. SDLTest_AssertCheck(INFINITY == result,
  531. "Copysign(%f,%.1f), expected %f, got %f",
  532. -INFINITY, 1.0, INFINITY, result);
  533. return TEST_COMPLETED;
  534. }
  535. /**
  536. * \brief Checks positive and negative zero.
  537. */
  538. static int
  539. copysign_zeroCases(void *args)
  540. {
  541. const dd_to_d zero_cases[] = {
  542. { 0.0, 1.0, 0.0 },
  543. { 0.0, -1.0, -0.0 },
  544. { -0.0, 1.0, 0.0 },
  545. { -0.0, -1.0, -0.0 }
  546. };
  547. return helper_ddtod("Copysign", SDL_copysign, zero_cases, SDL_arraysize(zero_cases));
  548. }
  549. /**
  550. * \brief Checks the NaN cases.
  551. */
  552. static int
  553. copysign_nanCases(void *args)
  554. {
  555. double result;
  556. result = SDL_copysign(NAN, 1.0);
  557. SDLTest_AssertCheck(isnan(result),
  558. "Copysign(nan,1.0), expected nan, got %f",
  559. result);
  560. result = SDL_copysign(NAN, -1.0);
  561. SDLTest_AssertCheck(isnan(result),
  562. "Copysign(nan,-1.0), expected nan, got %f",
  563. result);
  564. return TEST_COMPLETED;
  565. }
  566. /**
  567. * \brief Checks a range of values between 0 and UINT32_MAX
  568. */
  569. static int
  570. copysign_rangeTest(void *args)
  571. {
  572. Uint32 i;
  573. double test_value = 0.0;
  574. SDLTest_AssertPass("Copysign: Testing a range of %u values with steps of %u",
  575. RANGE_TEST_ITERATIONS,
  576. RANGE_TEST_STEP);
  577. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  578. double result;
  579. /* These are tested elsewhere */
  580. if (isnan(test_value) || isinf(test_value)) {
  581. continue;
  582. }
  583. /* Only log failures to save performances */
  584. result = SDL_copysign(test_value, 1.0);
  585. if (result != test_value) {
  586. SDLTest_AssertPass("Copysign(%.1f,%.1f), expected %.1f, got %.1f",
  587. test_value, 1.0,
  588. test_value, result);
  589. return TEST_ABORTED;
  590. }
  591. result = SDL_copysign(test_value, -1.0);
  592. if (result != -test_value) {
  593. SDLTest_AssertPass("Copysign(%.1f,%.1f), expected %.1f, got %.1f",
  594. test_value, -1.0,
  595. -test_value, result);
  596. return TEST_ABORTED;
  597. }
  598. }
  599. return TEST_COMPLETED;
  600. }
  601. /* SDL_fmod tests functions */
  602. /**
  603. * \brief Checks division of positive and negative inifnity.
  604. */
  605. static int
  606. fmod_divOfInfCases(void *args)
  607. {
  608. double result;
  609. result = SDL_fmod(INFINITY, -1.0);
  610. SDLTest_AssertCheck(isnan(result),
  611. "Fmod(%f,%.1f), expected %f, got %f",
  612. INFINITY, -1.0, NAN, result);
  613. result = SDL_fmod(INFINITY, 1.0);
  614. SDLTest_AssertCheck(isnan(result),
  615. "Fmod(%f,%.1f), expected %f, got %f",
  616. INFINITY, 1.0, NAN, result);
  617. result = SDL_fmod(-INFINITY, -1.0);
  618. SDLTest_AssertCheck(isnan(result),
  619. "Fmod(%f,%.1f), expected %f, got %f",
  620. -INFINITY, -1.0, NAN, result);
  621. result = SDL_fmod(-INFINITY, 1.0);
  622. SDLTest_AssertCheck(isnan(result),
  623. "Fmod(%f,%.1f), expected %f, got %f",
  624. -INFINITY, 1.0, NAN, result);
  625. return TEST_COMPLETED;
  626. }
  627. /**
  628. * \brief Checks division by positive and negative inifnity.
  629. */
  630. static int
  631. fmod_divByInfCases(void *args)
  632. {
  633. double result;
  634. result = SDL_fmod(1.0, INFINITY);
  635. SDLTest_AssertCheck(1.0 == result,
  636. "Fmod(%.1f,%f), expected %f, got %f",
  637. 1.0, INFINITY, 1.0, result);
  638. result = SDL_fmod(-1.0, INFINITY);
  639. SDLTest_AssertCheck(-1.0 == result,
  640. "Fmod(%.1f,%f), expected %f, got %f",
  641. -1.0, INFINITY, -1.0, result);
  642. result = SDL_fmod(1.0, -INFINITY);
  643. SDLTest_AssertCheck(1.0 == result,
  644. "Fmod(%.1f,%f), expected %f, got %f",
  645. 1.0, -INFINITY, 1.0, result);
  646. result = SDL_fmod(-1.0, -INFINITY);
  647. SDLTest_AssertCheck(-1.0 == result,
  648. "Fmod(%.1f,%f), expected %f, got %f",
  649. -1.0, -INFINITY, -1.0, result);
  650. return TEST_COMPLETED;
  651. }
  652. /**
  653. * \brief Checks division of positive and negative zero.
  654. */
  655. static int
  656. fmod_divOfZeroCases(void *args)
  657. {
  658. const dd_to_d zero_cases[] = {
  659. { 0.0, 1.0, 0.0 },
  660. { 0.0, -1.0, 0.0 },
  661. { -0.0, 1.0, -0.0 },
  662. { -0.0, -1.0, -0.0 }
  663. };
  664. return helper_ddtod("Fmod", SDL_fmod, zero_cases, SDL_arraysize(zero_cases));
  665. }
  666. /**
  667. * \brief Checks division by positive and negative zero.
  668. */
  669. static int
  670. fmod_divByZeroCases(void *args)
  671. {
  672. double result;
  673. result = SDL_fmod(1.0, 0.0);
  674. SDLTest_AssertCheck(isnan(result),
  675. "Fmod(1.0,0.0), expected nan, got %f",
  676. result);
  677. result = SDL_fmod(-1.0, 0.0);
  678. SDLTest_AssertCheck(isnan(result),
  679. "Fmod(-1.0,0.0), expected nan, got %f",
  680. result);
  681. result = SDL_fmod(1.0, -0.0);
  682. SDLTest_AssertCheck(isnan(result),
  683. "Fmod(1.0,-0.0), expected nan, got %f",
  684. result);
  685. result = SDL_fmod(-1.0, -0.0);
  686. SDLTest_AssertCheck(isnan(result),
  687. "Fmod(-1.0,-0.0), expected nan, got %f",
  688. result);
  689. return TEST_COMPLETED;
  690. }
  691. /**
  692. * \brief Checks the NaN cases.
  693. */
  694. static int
  695. fmod_nanCases(void *args)
  696. {
  697. double result;
  698. result = SDL_fmod(NAN, 1.0);
  699. SDLTest_AssertCheck(isnan(result),
  700. "Fmod(nan,1.0), expected nan, got %f",
  701. result);
  702. result = SDL_fmod(NAN, -1.0);
  703. SDLTest_AssertCheck(isnan(result),
  704. "Fmod(nan,-1.0), expected nan, got %f",
  705. result);
  706. result = SDL_fmod(1.0, NAN);
  707. SDLTest_AssertCheck(isnan(result),
  708. "Fmod(1.0,nan), expected nan, got %f",
  709. result);
  710. result = SDL_fmod(-1.0, NAN);
  711. SDLTest_AssertCheck(isnan(result),
  712. "Fmod(-1.0,nan), expected nan, got %f",
  713. result);
  714. return TEST_COMPLETED;
  715. }
  716. /**
  717. * \brief Checks a set of regular values.
  718. */
  719. static int
  720. fmod_regularCases(void *args)
  721. {
  722. const dd_to_d regular_cases[] = {
  723. { 3.5, 2.0, 1.5 },
  724. { -6.25, 3.0, -0.25 },
  725. { 7.5, 2.5, 0.0 },
  726. { 2.0 / 3.0, -1.0 / 3.0, 0.0 }
  727. };
  728. return helper_ddtod("Fmod", SDL_fmod, regular_cases, SDL_arraysize(regular_cases));
  729. }
  730. /**
  731. * \brief Checks a range of values between 0 and UINT32_MAX
  732. */
  733. static int
  734. fmod_rangeTest(void *args)
  735. {
  736. Uint32 i;
  737. double test_value = 0.0;
  738. SDLTest_AssertPass("Fmod: Testing a range of %u values with steps of %u",
  739. RANGE_TEST_ITERATIONS,
  740. RANGE_TEST_STEP);
  741. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  742. double result;
  743. /* These are tested elsewhere */
  744. if (isnan(test_value) || isinf(test_value)) {
  745. continue;
  746. }
  747. /* Only log failures to save performances */
  748. result = SDL_fmod(test_value, 1.0);
  749. if (0.0 != result) {
  750. SDLTest_AssertPass("Fmod(%.1f,%.1f), expected %.1f, got %.1f",
  751. test_value, 1.0,
  752. 0.0, result);
  753. return TEST_ABORTED;
  754. }
  755. }
  756. return TEST_COMPLETED;
  757. }
  758. /* SDL_exp tests functions */
  759. /**
  760. * \brief Checks positive and negative infinity.
  761. */
  762. static int
  763. exp_infCases(void *args)
  764. {
  765. double result;
  766. result = SDL_exp(INFINITY);
  767. SDLTest_AssertCheck(INFINITY == result,
  768. "Exp(%f), expected %f, got %f",
  769. INFINITY, INFINITY, result);
  770. result = SDL_exp(-INFINITY);
  771. SDLTest_AssertCheck(0.0 == result,
  772. "Exp(%f), expected %f, got %f",
  773. -INFINITY, 0.0, result);
  774. return TEST_COMPLETED;
  775. }
  776. /**
  777. * \brief Checks positive and negative zero.
  778. */
  779. static int
  780. exp_zeroCases(void *args)
  781. {
  782. const d_to_d zero_cases[] = {
  783. { 0.0, 1.0 },
  784. { -0.0, 1.0 }
  785. };
  786. return helper_dtod("Exp", SDL_exp, zero_cases, SDL_arraysize(zero_cases));
  787. }
  788. /**
  789. * \brief Checks for overflow.
  790. *
  791. * This test is skipped for double types larger than 64 bits.
  792. */
  793. static int
  794. exp_overflowCase(void *args)
  795. {
  796. double result;
  797. if (sizeof(double) > 8) {
  798. return TEST_SKIPPED;
  799. }
  800. result = SDL_exp(710.0);
  801. SDLTest_AssertCheck(isinf(result),
  802. "Exp(%f), expected %f, got %f",
  803. 710.0, INFINITY, result);
  804. return TEST_COMPLETED;
  805. }
  806. /**
  807. * \brief Checks the base case of 1.0.
  808. */
  809. static int
  810. exp_baseCase(void *args)
  811. {
  812. const double result = SDL_exp(1.0);
  813. SDLTest_AssertCheck(EULER == result,
  814. "Exp(%f), expected %f, got %f",
  815. 1.0, EULER, result);
  816. return TEST_COMPLETED;
  817. }
  818. /**
  819. * \brief Checks a set of regular cases.
  820. */
  821. static int
  822. exp_regularCases(void *args)
  823. {
  824. /* Hexadecimal floating constants are not supported on C89 compilers */
  825. const d_to_d regular_cases[] = {
  826. { -101.0, 1.36853947117385291381565719268793547578002532127613087E-44 },
  827. { -15.73, 0.00000014741707833928422931856502906683425990763681 },
  828. { -1.0, 0.36787944117144233402427744294982403516769409179688 },
  829. { -0.5, 0.60653065971263342426311737654032185673713684082031 },
  830. { 0.5, 1.64872127070012819416433558217249810695648193359375 },
  831. { 2.25, 9.48773583635852624240669683786109089851379394531250 },
  832. { 34.125, 661148770968660.375 },
  833. { 112.89, 10653788283588960962604279261058893737879589093376.0 },
  834. { 539.483, 1970107755334319939701129934673541628417235942656909222826926175622435588279443011110464355295725187195188154768877850257012251677751742837992843520967922303961718983154427294786640886286983037548604937796221048661733679844353544028160.0 },
  835. };
  836. return helper_dtod("Exp", SDL_exp, regular_cases, SDL_arraysize(regular_cases));
  837. }
  838. /* SDL_log tests functions */
  839. /**
  840. * \brief Checks limits (zeros and positive infinity).
  841. */
  842. static int
  843. log_limitCases(void *args)
  844. {
  845. double result;
  846. result = SDL_log(INFINITY);
  847. SDLTest_AssertCheck(INFINITY == result,
  848. "Log(%f), expected %f, got %f",
  849. INFINITY, INFINITY, result);
  850. result = SDL_log(0.0);
  851. SDLTest_AssertCheck(-INFINITY == result,
  852. "Log(%f), expected %f, got %f",
  853. 0.0, -INFINITY, result);
  854. result = SDL_log(-0.0);
  855. SDLTest_AssertCheck(-INFINITY == result,
  856. "Log(%f), expected %f, got %f",
  857. -0.0, -INFINITY, result);
  858. return TEST_COMPLETED;
  859. }
  860. /**
  861. * \brief Checks some base cases.
  862. */
  863. static int
  864. log_baseCases(void *args)
  865. {
  866. double result;
  867. result = SDL_log(1.0);
  868. SDLTest_AssertCheck(0.0 == result,
  869. "Log(%f), expected %f, got %f",
  870. 1.0, 0.0, result);
  871. result = SDL_log(EULER);
  872. SDLTest_AssertCheck(1.0 == result,
  873. "Log(%f), expected %f, got %f",
  874. EULER, 1.0, result);
  875. return TEST_COMPLETED;
  876. }
  877. /**
  878. * \brief Checks the nan cases.
  879. */
  880. static int
  881. log_nanCases(void *args)
  882. {
  883. double result;
  884. result = SDL_log(NAN);
  885. SDLTest_AssertCheck(isnan(result),
  886. "Log(%f), expected %f, got %f",
  887. NAN, NAN, result);
  888. result = SDL_log(-1234.5678);
  889. SDLTest_AssertCheck(isnan(result),
  890. "Log(%f), expected %f, got %f",
  891. -1234.5678, NAN, result);
  892. return TEST_COMPLETED;
  893. }
  894. /**
  895. * \brief Checks a set of regular cases.
  896. */
  897. static int
  898. log_regularCases(void *args)
  899. {
  900. const d_to_d regular_cases[] = {
  901. { 5.0, 1.60943791243410028179994242236716672778129577636718750 },
  902. { 10.0, 2.302585092994045901093613792909309267997741699218750 },
  903. { 56.32, 4.031049711849786554296315443934872746467590332031250 },
  904. { 789.123, 6.670922202231861497523368598194792866706848144531250 },
  905. { 2734.876324, 7.91384149408957959792587644187733530998229980468750 }
  906. };
  907. return helper_dtod("Log", SDL_log, regular_cases, SDL_arraysize(regular_cases));
  908. }
  909. /* SDL_log10 tests functions */
  910. /**
  911. * \brief Checks limits (zeros and positive infinity).
  912. */
  913. static int
  914. log10_limitCases(void *args)
  915. {
  916. double result;
  917. result = SDL_log10(INFINITY);
  918. SDLTest_AssertCheck(INFINITY == result,
  919. "Log10(%f), expected %f, got %f",
  920. INFINITY, INFINITY, result);
  921. result = SDL_log10(0.0);
  922. SDLTest_AssertCheck(-INFINITY == result,
  923. "Log10(%f), expected %f, got %f",
  924. 0.0, -INFINITY, result);
  925. result = SDL_log10(-0.0);
  926. SDLTest_AssertCheck(-INFINITY == result,
  927. "Log10(%f), expected %f, got %f",
  928. -0.0, -INFINITY, result);
  929. return TEST_COMPLETED;
  930. }
  931. /**
  932. * \brief Checks some base cases.
  933. */
  934. static int
  935. log10_baseCases(void *args)
  936. {
  937. const d_to_d base_cases[] = {
  938. { 1.0, 0.0 },
  939. { 10.0, 1.0 },
  940. { 100.0, 2.0 },
  941. { 1000.0, 3.0 },
  942. { 10000.0, 4.0 },
  943. { 100000.0, 5.0 },
  944. { 1000000.0, 6.0 },
  945. { 10000000.0, 7.0 },
  946. { 100000000.0, 8.0 },
  947. { 1000000000.0, 9.0 },
  948. };
  949. return helper_dtod("Log10", SDL_log10, base_cases, SDL_arraysize(base_cases));
  950. }
  951. /**
  952. * \brief Checks the nan cases.
  953. */
  954. static int
  955. log10_nanCases(void *args)
  956. {
  957. double result;
  958. result = SDL_log10(NAN);
  959. SDLTest_AssertCheck(isnan(result),
  960. "Log10(%f), expected %f, got %f",
  961. NAN, NAN, result);
  962. result = SDL_log10(-1234.5678);
  963. SDLTest_AssertCheck(isnan(result),
  964. "Log10(%f), expected %f, got %f",
  965. -1234.5678, NAN, result);
  966. return TEST_COMPLETED;
  967. }
  968. /**
  969. * \brief Checks a set of regular cases.
  970. */
  971. static int
  972. log10_regularCases(void *args)
  973. {
  974. const d_to_d regular_cases[] = {
  975. { 5.0, 0.698970004336018857493684208748163655400276184082031250 },
  976. { 12.5, 1.09691001300805646145875016372883692383766174316406250 },
  977. { 56.32, 1.750662646134055755453573510749265551567077636718750 },
  978. { 789.123, 2.8971447016351858927407647570362314581871032714843750 },
  979. { 2734.876324, 3.436937691540090433761633903486654162406921386718750 }
  980. };
  981. return helper_dtod("Log10", SDL_log10, regular_cases, SDL_arraysize(regular_cases));
  982. }
  983. /* ================= Test References ================== */
  984. /* SDL_floor test cases */
  985. static const SDLTest_TestCaseReference floorTestInf = {
  986. (SDLTest_TestCaseFp) floor_infCases, "floor_infCases",
  987. "Check positive and negative infinity", TEST_ENABLED
  988. };
  989. static const SDLTest_TestCaseReference floorTestZero = {
  990. (SDLTest_TestCaseFp) floor_zeroCases, "floor_zeroCases",
  991. "Check positive and negative zero", TEST_ENABLED
  992. };
  993. static const SDLTest_TestCaseReference floorTestNan = {
  994. (SDLTest_TestCaseFp) floor_nanCase, "floor_nanCase",
  995. "Check the NaN special case", TEST_ENABLED
  996. };
  997. static const SDLTest_TestCaseReference floorTestRound = {
  998. (SDLTest_TestCaseFp) floor_roundNumbersCases, "floor_roundNumberCases",
  999. "Check a set of round numbers", TEST_ENABLED
  1000. };
  1001. static const SDLTest_TestCaseReference floorTestFraction = {
  1002. (SDLTest_TestCaseFp) floor_fractionCases, "floor_fractionCases",
  1003. "Check a set of fractions", TEST_ENABLED
  1004. };
  1005. static const SDLTest_TestCaseReference floorTestRange = {
  1006. (SDLTest_TestCaseFp) floor_rangeTest, "floor_rangeTest",
  1007. "Check a range of positive integer", TEST_ENABLED
  1008. };
  1009. /* SDL_ceil test cases */
  1010. static const SDLTest_TestCaseReference ceilTestInf = {
  1011. (SDLTest_TestCaseFp) ceil_infCases, "ceil_infCases",
  1012. "Check positive and negative infinity", TEST_ENABLED
  1013. };
  1014. static const SDLTest_TestCaseReference ceilTestZero = {
  1015. (SDLTest_TestCaseFp) ceil_zeroCases, "ceil_zeroCases",
  1016. "Check positive and negative zero", TEST_ENABLED
  1017. };
  1018. static const SDLTest_TestCaseReference ceilTestNan = {
  1019. (SDLTest_TestCaseFp) ceil_nanCase, "ceil_nanCase",
  1020. "Check the NaN special case", TEST_ENABLED
  1021. };
  1022. static const SDLTest_TestCaseReference ceilTestRound = {
  1023. (SDLTest_TestCaseFp) ceil_roundNumbersCases, "ceil_roundNumberCases",
  1024. "Check a set of round numbers", TEST_ENABLED
  1025. };
  1026. static const SDLTest_TestCaseReference ceilTestFraction = {
  1027. (SDLTest_TestCaseFp) ceil_fractionCases, "ceil_fractionCases",
  1028. "Check a set of fractions", TEST_ENABLED
  1029. };
  1030. static const SDLTest_TestCaseReference ceilTestRange = {
  1031. (SDLTest_TestCaseFp) ceil_rangeTest, "ceil_rangeTest",
  1032. "Check a range of positive integer", TEST_ENABLED
  1033. };
  1034. /* SDL_trunc test cases */
  1035. static const SDLTest_TestCaseReference truncTestInf = {
  1036. (SDLTest_TestCaseFp) trunc_infCases, "trunc_infCases",
  1037. "Check positive and negative infinity", TEST_ENABLED
  1038. };
  1039. static const SDLTest_TestCaseReference truncTestZero = {
  1040. (SDLTest_TestCaseFp) trunc_zeroCases, "trunc_zeroCases",
  1041. "Check positive and negative zero", TEST_ENABLED
  1042. };
  1043. static const SDLTest_TestCaseReference truncTestNan = {
  1044. (SDLTest_TestCaseFp) trunc_nanCase, "trunc_nanCase",
  1045. "Check the NaN special case", TEST_ENABLED
  1046. };
  1047. static const SDLTest_TestCaseReference truncTestRound = {
  1048. (SDLTest_TestCaseFp) trunc_roundNumbersCases, "trunc_roundNumberCases",
  1049. "Check a set of round numbers", TEST_ENABLED
  1050. };
  1051. static const SDLTest_TestCaseReference truncTestFraction = {
  1052. (SDLTest_TestCaseFp) trunc_fractionCases, "trunc_fractionCases",
  1053. "Check a set of fractions", TEST_ENABLED
  1054. };
  1055. static const SDLTest_TestCaseReference truncTestRange = {
  1056. (SDLTest_TestCaseFp) trunc_rangeTest, "trunc_rangeTest",
  1057. "Check a range of positive integer", TEST_ENABLED
  1058. };
  1059. /* SDL_round test cases */
  1060. static const SDLTest_TestCaseReference roundTestInf = {
  1061. (SDLTest_TestCaseFp) round_infCases, "round_infCases",
  1062. "Check positive and negative infinity", TEST_ENABLED
  1063. };
  1064. static const SDLTest_TestCaseReference roundTestZero = {
  1065. (SDLTest_TestCaseFp) round_zeroCases, "round_zeroCases",
  1066. "Check positive and negative zero", TEST_ENABLED
  1067. };
  1068. static const SDLTest_TestCaseReference roundTestNan = {
  1069. (SDLTest_TestCaseFp) round_nanCase, "round_nanCase",
  1070. "Check the NaN special case", TEST_ENABLED
  1071. };
  1072. static const SDLTest_TestCaseReference roundTestRound = {
  1073. (SDLTest_TestCaseFp) round_roundNumbersCases, "round_roundNumberCases",
  1074. "Check a set of round numbers", TEST_ENABLED
  1075. };
  1076. static const SDLTest_TestCaseReference roundTestFraction = {
  1077. (SDLTest_TestCaseFp) round_fractionCases, "round_fractionCases",
  1078. "Check a set of fractions", TEST_ENABLED
  1079. };
  1080. static const SDLTest_TestCaseReference roundTestRange = {
  1081. (SDLTest_TestCaseFp) round_rangeTest, "round_rangeTest",
  1082. "Check a range of positive integer", TEST_ENABLED
  1083. };
  1084. /* SDL_fabs test cases */
  1085. static const SDLTest_TestCaseReference fabsTestInf = {
  1086. (SDLTest_TestCaseFp) fabs_infCases, "fabs_infCases",
  1087. "Check positive and negative infinity", TEST_ENABLED
  1088. };
  1089. static const SDLTest_TestCaseReference fabsTestZero = {
  1090. (SDLTest_TestCaseFp) fabs_zeroCases, "fabs_zeroCases",
  1091. "Check positive and negative zero", TEST_ENABLED
  1092. };
  1093. static const SDLTest_TestCaseReference fabsTestNan = {
  1094. (SDLTest_TestCaseFp) fabs_nanCase, "fabs_nanCase",
  1095. "Check the NaN special case", TEST_ENABLED
  1096. };
  1097. static const SDLTest_TestCaseReference fabsTestRange = {
  1098. (SDLTest_TestCaseFp) fabs_rangeTest, "fabs_rangeTest",
  1099. "Check a range of positive integer", TEST_ENABLED
  1100. };
  1101. /* SDL_copysign test cases */
  1102. static const SDLTest_TestCaseReference copysignTestInf = {
  1103. (SDLTest_TestCaseFp) copysign_infCases, "copysign_infCases",
  1104. "Check positive and negative infinity", TEST_ENABLED
  1105. };
  1106. static const SDLTest_TestCaseReference copysignTestZero = {
  1107. (SDLTest_TestCaseFp) copysign_zeroCases, "copysign_zeroCases",
  1108. "Check positive and negative zero", TEST_ENABLED
  1109. };
  1110. static const SDLTest_TestCaseReference copysignTestNan = {
  1111. (SDLTest_TestCaseFp) copysign_nanCases, "copysign_nanCases",
  1112. "Check the NaN special cases", TEST_ENABLED
  1113. };
  1114. static const SDLTest_TestCaseReference copysignTestRange = {
  1115. (SDLTest_TestCaseFp) copysign_rangeTest, "copysign_rangeTest",
  1116. "Check a range of positive integer", TEST_ENABLED
  1117. };
  1118. /* SDL_fmod test cases */
  1119. static const SDLTest_TestCaseReference fmodTestDivOfInf = {
  1120. (SDLTest_TestCaseFp) fmod_divOfInfCases, "fmod_divOfInfCases",
  1121. "Check division of positive and negative infinity", TEST_ENABLED
  1122. };
  1123. static const SDLTest_TestCaseReference fmodTestDivByInf = {
  1124. (SDLTest_TestCaseFp) fmod_divByInfCases, "fmod_divByInfCases",
  1125. "Check division by positive and negative infinity", TEST_ENABLED
  1126. };
  1127. static const SDLTest_TestCaseReference fmodTestDivOfZero = {
  1128. (SDLTest_TestCaseFp) fmod_divOfZeroCases, "fmod_divOfZeroCases",
  1129. "Check division of positive and negative zero", TEST_ENABLED
  1130. };
  1131. static const SDLTest_TestCaseReference fmodTestDivByZero = {
  1132. (SDLTest_TestCaseFp) fmod_divByZeroCases, "fmod_divByZeroCases",
  1133. "Check division by positive and negative zero", TEST_ENABLED
  1134. };
  1135. static const SDLTest_TestCaseReference fmodTestNan = {
  1136. (SDLTest_TestCaseFp) fmod_nanCases, "fmod_nanCases",
  1137. "Check the NaN special cases", TEST_ENABLED
  1138. };
  1139. static const SDLTest_TestCaseReference fmodTestRegular = {
  1140. (SDLTest_TestCaseFp) fmod_regularCases, "fmod_regularCases",
  1141. "Check a set of regular values", TEST_ENABLED
  1142. };
  1143. static const SDLTest_TestCaseReference fmodTestRange = {
  1144. (SDLTest_TestCaseFp) fmod_rangeTest, "fmod_rangeTest",
  1145. "Check a range of positive integer", TEST_ENABLED
  1146. };
  1147. /* SDL_exp test cases */
  1148. static const SDLTest_TestCaseReference expTestInf = {
  1149. (SDLTest_TestCaseFp) exp_infCases, "exp_infCases",
  1150. "Check positive and negative infinity", TEST_ENABLED
  1151. };
  1152. static const SDLTest_TestCaseReference expTestZero = {
  1153. (SDLTest_TestCaseFp) exp_zeroCases, "exp_zeroCases",
  1154. "Check for positive and negative zero", TEST_ENABLED
  1155. };
  1156. static const SDLTest_TestCaseReference expTestOverflow = {
  1157. (SDLTest_TestCaseFp) exp_overflowCase, "exp_overflowCase",
  1158. "Check for overflow", TEST_ENABLED
  1159. };
  1160. static const SDLTest_TestCaseReference expTestBase = {
  1161. (SDLTest_TestCaseFp) exp_baseCase, "exp_baseCase",
  1162. "Check the base case of 1.0", TEST_ENABLED
  1163. };
  1164. static const SDLTest_TestCaseReference expTestRegular = {
  1165. (SDLTest_TestCaseFp) exp_regularCases, "exp_regularCases",
  1166. "Check a set of regular values", TEST_ENABLED
  1167. };
  1168. /* SDL_log test cases */
  1169. static const SDLTest_TestCaseReference logTestLimit = {
  1170. (SDLTest_TestCaseFp) log_limitCases, "log_limitCases",
  1171. "Check for limits", TEST_ENABLED
  1172. };
  1173. static const SDLTest_TestCaseReference logTestNan = {
  1174. (SDLTest_TestCaseFp) log_nanCases, "log_nanCases",
  1175. "Check for the nan cases", TEST_ENABLED
  1176. };
  1177. static const SDLTest_TestCaseReference logTestBase = {
  1178. (SDLTest_TestCaseFp) log_baseCases, "log_baseCases",
  1179. "Check for base cases", TEST_ENABLED
  1180. };
  1181. static const SDLTest_TestCaseReference logTestRegular = {
  1182. (SDLTest_TestCaseFp) log_regularCases, "log_regularCases",
  1183. "Check a set of regular values", TEST_ENABLED
  1184. };
  1185. /* SDL_log10 test cases */
  1186. static const SDLTest_TestCaseReference log10TestLimit = {
  1187. (SDLTest_TestCaseFp) log10_limitCases, "log10_limitCases",
  1188. "Check for limits", TEST_ENABLED
  1189. };
  1190. static const SDLTest_TestCaseReference log10TestNan = {
  1191. (SDLTest_TestCaseFp) log10_nanCases, "log10_nanCases",
  1192. "Check for the nan cases", TEST_ENABLED
  1193. };
  1194. static const SDLTest_TestCaseReference log10TestBase = {
  1195. (SDLTest_TestCaseFp) log10_baseCases, "log10_baseCases",
  1196. "Check for base cases", TEST_ENABLED
  1197. };
  1198. static const SDLTest_TestCaseReference log10TestRegular = {
  1199. (SDLTest_TestCaseFp) log10_regularCases, "log10_regularCases",
  1200. "Check a set of regular values", TEST_ENABLED
  1201. };
  1202. static const SDLTest_TestCaseReference *mathTests[] = {
  1203. &floorTestInf, &floorTestZero, &floorTestNan,
  1204. &floorTestRound, &floorTestFraction, &floorTestRange,
  1205. &ceilTestInf, &ceilTestZero, &ceilTestNan,
  1206. &ceilTestRound, &ceilTestFraction, &ceilTestRange,
  1207. &truncTestInf, &truncTestZero, &truncTestNan,
  1208. &truncTestRound, &truncTestFraction, &truncTestRange,
  1209. &roundTestInf, &roundTestZero, &roundTestNan,
  1210. &roundTestRound, &roundTestFraction, &roundTestRange,
  1211. &fabsTestInf, &fabsTestZero, &fabsTestNan, &fabsTestRange,
  1212. &copysignTestInf, &copysignTestZero, &copysignTestNan, &copysignTestRange,
  1213. &fmodTestDivOfInf, &fmodTestDivByInf, &fmodTestDivOfZero, &fmodTestDivByZero,
  1214. &fmodTestNan, &fmodTestRegular, &fmodTestRange,
  1215. &expTestInf, &expTestZero, &expTestOverflow,
  1216. &expTestBase, &expTestRegular,
  1217. &logTestLimit, &logTestNan,
  1218. &logTestBase, &logTestRegular,
  1219. &log10TestLimit, &log10TestNan,
  1220. &log10TestBase, &log10TestRegular,
  1221. NULL
  1222. };
  1223. SDLTest_TestSuiteReference mathTestSuite = { "Math", NULL, mathTests, NULL };