testautomation_math.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. /**
  2. * Math test suite
  3. */
  4. #include <math.h>
  5. #include "SDL.h"
  6. #include "SDL_test.h"
  7. /* ================= Test Structs ================== */
  8. /**
  9. * Stores a single input and the expected result
  10. */
  11. typedef struct
  12. {
  13. double input;
  14. double expected;
  15. } d_to_d;
  16. /**
  17. * Stores a pair of inputs and the expected result
  18. */
  19. typedef struct
  20. {
  21. double x_input, y_input;
  22. double expected;
  23. } dd_to_d;
  24. /*
  25. NB: You cannot create an array of these structures containing INFINITY or NAN.
  26. On platforms such as OS/2, they are defined as 'extern const double' making them
  27. not compile-time constant.
  28. */
  29. /* ================= Test Helpers ================== */
  30. typedef double(SDLCALL *d_to_d_func)(double);
  31. typedef double(SDLCALL *dd_to_d_func)(double, double);
  32. /**
  33. * \brief Runs all the cases on a given function with a signature double -> double
  34. *
  35. * \param func_name, the name of the tested function.
  36. * \param func, the function to call.
  37. * \param cases, an array of all the cases.
  38. * \param cases_size, the size of the cases array.
  39. */
  40. static int
  41. helper_dtod(const char *func_name, d_to_d_func func,
  42. const d_to_d *cases, const size_t cases_size)
  43. {
  44. Uint32 i;
  45. for (i = 0; i < cases_size; i++) {
  46. const double result = func(cases[i].input);
  47. SDLTest_AssertCheck(result == cases[i].expected,
  48. "%s(%f), expected %f, got %f",
  49. func_name,
  50. cases[i].input,
  51. cases[i].expected, result);
  52. }
  53. return TEST_COMPLETED;
  54. }
  55. /**
  56. * \brief Runs all the cases on a given function with a signature (double, double) -> double
  57. *
  58. * \param func_name, the name of the tested function.
  59. * \param func, the function to call.
  60. * \param cases, an array of all the cases.
  61. * \param cases_size, the size of the cases array.
  62. */
  63. static int
  64. helper_ddtod(const char *func_name, dd_to_d_func func,
  65. const dd_to_d *cases, const size_t cases_size)
  66. {
  67. Uint32 i;
  68. for (i = 0; i < cases_size; i++) {
  69. const double result = func(cases[i].x_input, cases[i].y_input);
  70. SDLTest_AssertCheck(result == cases[i].expected,
  71. "%s(%f,%f), expected %f, got %f",
  72. func_name,
  73. cases[i].x_input, cases[i].y_input,
  74. cases[i].expected, result);
  75. }
  76. return TEST_COMPLETED;
  77. }
  78. /**
  79. * \brief Runs a range of values on a given function with a signature double -> double
  80. *
  81. * This function is only meant to test functions that returns the input value if it is
  82. * integral: f(x) -> x for x in N.
  83. *
  84. * \param func_name, the name of the tested function.
  85. * \param func, the function to call.
  86. */
  87. static int
  88. helper_range(const char *func_name, d_to_d_func func)
  89. {
  90. const Uint32 ITERATIONS = 10000000;
  91. const Uint32 STEP = SDL_MAX_UINT32 / ITERATIONS;
  92. Uint32 i;
  93. double test_value = 0.0;
  94. SDLTest_AssertPass("%s: Testing a range of %u values with %u steps",
  95. func_name, ITERATIONS, STEP);
  96. for (i = 0; i < ITERATIONS; i++, test_value += STEP) {
  97. double result;
  98. /* These are tested elsewhere */
  99. if (isnan(test_value) || isinf(test_value)) {
  100. continue;
  101. }
  102. result = func(test_value);
  103. if (result != test_value) { /* Only log failures to save performances */
  104. SDLTest_AssertPass("%s(%.1f), expected %.1f, got %.1f",
  105. func_name, test_value,
  106. test_value, result);
  107. return TEST_ABORTED;
  108. }
  109. }
  110. return TEST_COMPLETED;
  111. }
  112. /* ================= Test Case Implementation ================== */
  113. /* SDL_floor tests functions */
  114. /**
  115. * \brief Checks positive and negative infinity.
  116. */
  117. static int
  118. floor_infCases(void *args)
  119. {
  120. double result;
  121. result = SDL_floor(INFINITY);
  122. SDLTest_AssertCheck(INFINITY == result,
  123. "Floor(%f), expected %f, got %f",
  124. INFINITY, INFINITY, result);
  125. result = SDL_floor(-INFINITY);
  126. SDLTest_AssertCheck(-INFINITY == result,
  127. "Floor(%f), expected %f, got %f",
  128. -INFINITY, -INFINITY, result);
  129. return TEST_COMPLETED;
  130. }
  131. /**
  132. * \brief Checks positive and negative zero.
  133. */
  134. static int
  135. floor_zeroCases(void *args)
  136. {
  137. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  138. return helper_dtod("Floor", SDL_floor, zero_cases, SDL_arraysize(zero_cases));
  139. }
  140. /**
  141. * \brief Checks the NaN case.
  142. */
  143. static int
  144. floor_nanCase(void *args)
  145. {
  146. const double result = SDL_floor(NAN);
  147. SDLTest_AssertCheck(isnan(result),
  148. "Floor(nan), expected nan, got %f",
  149. result);
  150. return TEST_COMPLETED;
  151. }
  152. /**
  153. * \brief Checks round values (x.0) for themselves
  154. */
  155. static int
  156. floor_roundNumbersCases(void *args)
  157. {
  158. const d_to_d round_cases[] = {
  159. { 1.0, 1.0 },
  160. { -1.0, -1.0 },
  161. { 15.0, 15.0 },
  162. { -15.0, -15.0 },
  163. { 125.0, 125.0 },
  164. { -125.0, -125.0 },
  165. { 1024.0, 1024.0 },
  166. { -1024.0, -1024.0 }
  167. };
  168. return helper_dtod("Floor", SDL_floor, round_cases, SDL_arraysize(round_cases));
  169. }
  170. /**
  171. * \brief Checks a set of fractions
  172. */
  173. static int
  174. floor_fractionCases(void *args)
  175. {
  176. const d_to_d frac_cases[] = {
  177. { 1.0 / 2.0, 0.0 },
  178. { -1.0 / 2.0, -1.0 },
  179. { 4.0 / 3.0, 1.0 },
  180. { -4.0 / 3.0, -2.0 },
  181. { 76.0 / 7.0, 10.0 },
  182. { -76.0 / 7.0, -11.0 },
  183. { 535.0 / 8.0, 66.0 },
  184. { -535.0 / 8.0, -67.0 },
  185. { 19357.0 / 53.0, 365.0 },
  186. { -19357.0 / 53.0, -366.0 }
  187. };
  188. return helper_dtod("Floor", SDL_floor, frac_cases, SDL_arraysize(frac_cases));
  189. }
  190. /**
  191. * \brief Checks a range of values between 0 and UINT32_MAX
  192. */
  193. static int
  194. floor_rangeTest(void *args)
  195. {
  196. return helper_range("Floor", SDL_floor);
  197. }
  198. /* SDL_ceil tests functions */
  199. /**
  200. * \brief Checks positive and negative infinity.
  201. */
  202. static int
  203. ceil_infCases(void *args)
  204. {
  205. double result;
  206. result = SDL_ceil(INFINITY);
  207. SDLTest_AssertCheck(INFINITY == result,
  208. "Ceil(%f), expected %f, got %f",
  209. INFINITY, INFINITY, result);
  210. result = SDL_ceil(-INFINITY);
  211. SDLTest_AssertCheck(-INFINITY == result,
  212. "Ceil(%f), expected %f, got %f",
  213. -INFINITY, -INFINITY, result);
  214. return TEST_COMPLETED;
  215. }
  216. /**
  217. * \brief Checks positive and negative zero.
  218. */
  219. static int
  220. ceil_zeroCases(void *args)
  221. {
  222. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  223. return helper_dtod("Ceil", SDL_ceil, zero_cases, SDL_arraysize(zero_cases));
  224. }
  225. /**
  226. * \brief Checks the NaN case.
  227. */
  228. static int
  229. ceil_nanCase(void *args)
  230. {
  231. const double result = SDL_ceil(NAN);
  232. SDLTest_AssertCheck(isnan(result),
  233. "Ceil(nan), expected nan, got %f",
  234. result);
  235. return TEST_COMPLETED;
  236. }
  237. /**
  238. * \brief Checks round values (x.0) for themselves
  239. */
  240. static int
  241. ceil_roundNumbersCases(void *args)
  242. {
  243. const d_to_d round_cases[] = {
  244. { 1.0, 1.0 },
  245. { -1.0, -1.0 },
  246. { 15.0, 15.0 },
  247. { -15.0, -15.0 },
  248. { 125.0, 125.0 },
  249. { -125.0, -125.0 },
  250. { 1024.0, 1024.0 },
  251. { -1024.0, -1024.0 }
  252. };
  253. return helper_dtod("Ceil", SDL_ceil, round_cases, SDL_arraysize(round_cases));
  254. }
  255. /**
  256. * \brief Checks a set of fractions
  257. */
  258. static int
  259. ceil_fractionCases(void *args)
  260. {
  261. const d_to_d frac_cases[] = {
  262. { 1.0 / 2.0, 1.0 },
  263. { -1.0 / 2.0, -0.0 },
  264. { 4.0 / 3.0, 2.0 },
  265. { -4.0 / 3.0, -1.0 },
  266. { 76.0 / 7.0, 11.0 },
  267. { -76.0 / 7.0, -10.0 },
  268. { 535.0 / 8.0, 67.0 },
  269. { -535.0 / 8.0, -66.0 },
  270. { 19357.0 / 53.0, 366.0 },
  271. { -19357.0 / 53.0, -365.0 }
  272. };
  273. return helper_dtod("Ceil", SDL_ceil, frac_cases, SDL_arraysize(frac_cases));
  274. }
  275. /**
  276. * \brief Checks a range of values between 0 and UINT32_MAX
  277. */
  278. static int
  279. ceil_rangeTest(void *args)
  280. {
  281. return helper_range("Ceil", SDL_ceil);
  282. }
  283. /* SDL_trunc tests functions */
  284. /**
  285. * \brief Checks positive and negative infinity.
  286. */
  287. static int
  288. trunc_infCases(void *args)
  289. {
  290. double result;
  291. result = SDL_trunc(INFINITY);
  292. SDLTest_AssertCheck(INFINITY == result,
  293. "Trunc(%f), expected %f, got %f",
  294. INFINITY, INFINITY, result);
  295. result = SDL_trunc(-INFINITY);
  296. SDLTest_AssertCheck(-INFINITY == result,
  297. "Trunc(%f), expected %f, got %f",
  298. -INFINITY, -INFINITY, result);
  299. return TEST_COMPLETED;
  300. }
  301. /**
  302. * \brief Checks positive and negative zero.
  303. */
  304. static int
  305. trunc_zeroCases(void *args)
  306. {
  307. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  308. return helper_dtod("Trunc", SDL_trunc, zero_cases, SDL_arraysize(zero_cases));
  309. }
  310. /**
  311. * \brief Checks the NaN case.
  312. */
  313. static int
  314. trunc_nanCase(void *args)
  315. {
  316. const double result = SDL_trunc(NAN);
  317. SDLTest_AssertCheck(isnan(result),
  318. "Trunc(nan), expected nan, got %f",
  319. result);
  320. return TEST_COMPLETED;
  321. }
  322. /**
  323. * \brief Checks round values (x.0) for themselves
  324. */
  325. static int
  326. trunc_roundNumbersCases(void *args)
  327. {
  328. const d_to_d round_cases[] = {
  329. { 1.0, 1.0 },
  330. { -1.0, -1.0 },
  331. { 15.0, 15.0 },
  332. { -15.0, -15.0 },
  333. { 125.0, 125.0 },
  334. { -125.0, -125.0 },
  335. { 1024.0, 1024.0 },
  336. { -1024.0, -1024.0 }
  337. };
  338. return helper_dtod("Trunc", SDL_trunc, round_cases, SDL_arraysize(round_cases));
  339. }
  340. /**
  341. * \brief Checks a set of fractions
  342. */
  343. static int
  344. trunc_fractionCases(void *args)
  345. {
  346. const d_to_d frac_cases[] = {
  347. { 1.0 / 2.0, 0.0 },
  348. { -1.0 / 2.0, -0.0 },
  349. { 4.0 / 3.0, 1.0 },
  350. { -4.0 / 3.0, -1.0 },
  351. { 76.0 / 7.0, 10.0 },
  352. { -76.0 / 7.0, -10.0 },
  353. { 535.0 / 8.0, 66.0 },
  354. { -535.0 / 8.0, -66.0 },
  355. { 19357.0 / 53.0, 365.0 },
  356. { -19357.0 / 53.0, -365.0 }
  357. };
  358. return helper_dtod("Trunc", SDL_trunc, frac_cases, SDL_arraysize(frac_cases));
  359. }
  360. /**
  361. * \brief Checks a range of values between 0 and UINT32_MAX
  362. */
  363. static int
  364. trunc_rangeTest(void *args)
  365. {
  366. return helper_range("Trunc", SDL_trunc);
  367. }
  368. /* SDL_round tests functions */
  369. /**
  370. * \brief Checks positive and negative infinity.
  371. */
  372. static int
  373. round_infCases(void *args)
  374. {
  375. double result;
  376. result = SDL_round(INFINITY);
  377. SDLTest_AssertCheck(INFINITY == result,
  378. "Round(%f), expected %f, got %f",
  379. INFINITY, INFINITY, result);
  380. result = SDL_round(-INFINITY);
  381. SDLTest_AssertCheck(-INFINITY == result,
  382. "Round(%f), expected %f, got %f",
  383. -INFINITY, -INFINITY, result);
  384. return TEST_COMPLETED;
  385. }
  386. /**
  387. * \brief Checks positive and negative zero.
  388. */
  389. static int
  390. round_zeroCases(void *args)
  391. {
  392. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  393. return helper_dtod("Round", SDL_round, zero_cases, SDL_arraysize(zero_cases));
  394. }
  395. /**
  396. * \brief Checks the NaN case.
  397. */
  398. static int
  399. round_nanCase(void *args)
  400. {
  401. const double result = SDL_round(NAN);
  402. SDLTest_AssertCheck(isnan(result),
  403. "Round(nan), expected nan, got %f",
  404. result);
  405. return TEST_COMPLETED;
  406. }
  407. /**
  408. * \brief Checks round values (x.0) for themselves
  409. */
  410. static int
  411. round_roundNumbersCases(void *args)
  412. {
  413. const d_to_d round_cases[] = {
  414. { 1.0, 1.0 },
  415. { -1.0, -1.0 },
  416. { 15.0, 15.0 },
  417. { -15.0, -15.0 },
  418. { 125.0, 125.0 },
  419. { -125.0, -125.0 },
  420. { 1024.0, 1024.0 },
  421. { -1024.0, -1024.0 }
  422. };
  423. return helper_dtod("Round", SDL_round, round_cases, SDL_arraysize(round_cases));
  424. }
  425. /**
  426. * \brief Checks a set of fractions
  427. */
  428. static int
  429. round_fractionCases(void *args)
  430. {
  431. const d_to_d frac_cases[] = {
  432. { 1.0 / 2.0, 1.0 },
  433. { -1.0 / 2.0, -1.0 },
  434. { 4.0 / 3.0, 1.0 },
  435. { -4.0 / 3.0, -1.0 },
  436. { 76.0 / 7.0, 11.0 },
  437. { -76.0 / 7.0, -11.0 },
  438. { 535.0 / 8.0, 67.0 },
  439. { -535.0 / 8.0, -67.0 },
  440. { 19357.0 / 53.0, 365.0 },
  441. { -19357.0 / 53.0, -365.0 }
  442. };
  443. return helper_dtod("Round", SDL_round, frac_cases, SDL_arraysize(frac_cases));
  444. }
  445. /**
  446. * \brief Checks a range of values between 0 and UINT32_MAX
  447. */
  448. static int
  449. round_rangeTest(void *args)
  450. {
  451. return helper_range("Round", SDL_round);
  452. }
  453. /* SDL_fabs tests functions */
  454. /**
  455. * \brief Checks positive and negative infinity.
  456. */
  457. static int
  458. fabs_infCases(void *args)
  459. {
  460. double result;
  461. result = SDL_fabs(INFINITY);
  462. SDLTest_AssertCheck(INFINITY == result,
  463. "Fabs(%f), expected %f, got %f",
  464. INFINITY, INFINITY, result);
  465. result = SDL_fabs(-INFINITY);
  466. SDLTest_AssertCheck(INFINITY == result,
  467. "Fabs(%f), expected %f, got %f",
  468. -INFINITY, INFINITY, result);
  469. return TEST_COMPLETED;
  470. }
  471. /**
  472. * \brief Checks positive and negative zero
  473. */
  474. static int
  475. fabs_zeroCases(void *args)
  476. {
  477. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, 0.0 } };
  478. return helper_dtod("Fabs", SDL_fabs, zero_cases, SDL_arraysize(zero_cases));
  479. }
  480. /**
  481. * \brief Checks the NaN case.
  482. */
  483. static int
  484. fabs_nanCase(void *args)
  485. {
  486. const double result = SDL_fabs(NAN);
  487. SDLTest_AssertCheck(isnan(result),
  488. "Fabs(nan), expected nan, got %f",
  489. result);
  490. return TEST_COMPLETED;
  491. }
  492. /**
  493. * \brief Checks a range of values between 0 and UINT32_MAX
  494. */
  495. static int
  496. fabs_rangeTest(void *args)
  497. {
  498. return helper_range("Fabs", SDL_fabs);
  499. }
  500. /* SDL_copysign tests functions */
  501. /**
  502. * \brief Checks positive and negative inifnity.
  503. */
  504. static int
  505. copysign_infCases(void *args)
  506. {
  507. double result;
  508. result = SDL_copysign(INFINITY, -1.0);
  509. SDLTest_AssertCheck(-INFINITY == result,
  510. "Copysign(%f,%.1f), expected %f, got %f",
  511. INFINITY, -1.0, -INFINITY, result);
  512. result = SDL_copysign(INFINITY, 1.0);
  513. SDLTest_AssertCheck(INFINITY == result,
  514. "Copysign(%f,%.1f), expected %f, got %f",
  515. INFINITY, 1.0, INFINITY, result);
  516. result = SDL_copysign(-INFINITY, -1.0);
  517. SDLTest_AssertCheck(-INFINITY == result,
  518. "Copysign(%f,%.1f), expected %f, got %f",
  519. -INFINITY, -1.0, -INFINITY, result);
  520. result = SDL_copysign(-INFINITY, 1.0);
  521. SDLTest_AssertCheck(INFINITY == result,
  522. "Copysign(%f,%.1f), expected %f, got %f",
  523. -INFINITY, 1.0, INFINITY, result);
  524. return TEST_COMPLETED;
  525. }
  526. /**
  527. * \brief Checks positive and negative zero.
  528. */
  529. static int
  530. copysign_zeroCases(void *args)
  531. {
  532. const dd_to_d zero_cases[] = {
  533. { 0.0, 1.0, 0.0 },
  534. { 0.0, -1.0, -0.0 },
  535. { -0.0, 1.0, 0.0 },
  536. { -0.0, -1.0, -0.0 }
  537. };
  538. return helper_ddtod("Copysign", SDL_copysign, zero_cases, SDL_arraysize(zero_cases));
  539. }
  540. /**
  541. * \brief Checks the NaN cases.
  542. */
  543. static int
  544. copysign_nanCases(void *args)
  545. {
  546. double result;
  547. result = SDL_copysign(NAN, 1.0);
  548. SDLTest_AssertCheck(isnan(result),
  549. "Copysign(nan,1.0), expected nan, got %f",
  550. result);
  551. result = SDL_copysign(NAN, -1.0);
  552. SDLTest_AssertCheck(isnan(result),
  553. "Copysign(nan,-1.0), expected nan, got %f",
  554. result);
  555. return TEST_COMPLETED;
  556. }
  557. /**
  558. * \brief Checks a range of values between 0 and UINT32_MAX
  559. */
  560. static int
  561. copysign_rangeTest(void *args)
  562. {
  563. const Uint32 ITERATIONS = 10000000;
  564. const Uint32 STEP = SDL_MAX_UINT32 / ITERATIONS;
  565. Uint32 i;
  566. double test_value = 0.0;
  567. SDLTest_AssertPass("Fabs: Testing a range of %u values with %u steps",
  568. ITERATIONS, STEP);
  569. for (i = 0; i < ITERATIONS; i++, test_value += STEP) {
  570. double result;
  571. /* These are tested elsewhere */
  572. if (isnan(test_value) || isinf(test_value)) {
  573. continue;
  574. }
  575. /* Only log failures to save performances */
  576. result = SDL_copysign(test_value, 1.0);
  577. if (result != test_value) {
  578. SDLTest_AssertPass("Copysign(%.1f,%.1f), expected %.1f, got %.1f",
  579. test_value, 1.0,
  580. test_value, result);
  581. return TEST_ABORTED;
  582. }
  583. result = SDL_copysign(test_value, -1.0);
  584. if (result != -test_value) {
  585. SDLTest_AssertPass("Copysign(%.1f,%.1f), expected %.1f, got %.1f",
  586. test_value, -1.0,
  587. -test_value, result);
  588. return TEST_ABORTED;
  589. }
  590. }
  591. return TEST_COMPLETED;
  592. }
  593. /* ================= Test References ================== */
  594. /* SDL_floor test cases */
  595. static const SDLTest_TestCaseReference floorTestInf = {
  596. (SDLTest_TestCaseFp) floor_infCases, "floor_infCases",
  597. "Check positive and negative infinity", TEST_ENABLED
  598. };
  599. static const SDLTest_TestCaseReference floorTestZero = {
  600. (SDLTest_TestCaseFp) floor_zeroCases, "floor_zeroCases",
  601. "Check positive and negative zero", TEST_ENABLED
  602. };
  603. static const SDLTest_TestCaseReference floorTestNan = {
  604. (SDLTest_TestCaseFp) floor_nanCase, "floor_nanCase",
  605. "Check the NaN special case", TEST_ENABLED
  606. };
  607. static const SDLTest_TestCaseReference floorTestRound = {
  608. (SDLTest_TestCaseFp) floor_roundNumbersCases, "floor_roundNumberCases",
  609. "Check a set of round numbers", TEST_ENABLED
  610. };
  611. static const SDLTest_TestCaseReference floorTestFraction = {
  612. (SDLTest_TestCaseFp) floor_fractionCases, "floor_fractionCases",
  613. "Check a set of fractions", TEST_ENABLED
  614. };
  615. static const SDLTest_TestCaseReference floorTestRange = {
  616. (SDLTest_TestCaseFp) floor_rangeTest, "floor_rangeTest",
  617. "Check a range of positive integer", TEST_ENABLED
  618. };
  619. /* SDL_ceil test cases */
  620. static const SDLTest_TestCaseReference ceilTestInf = {
  621. (SDLTest_TestCaseFp) ceil_infCases, "ceil_infCases",
  622. "Check positive and negative infinity", TEST_ENABLED
  623. };
  624. static const SDLTest_TestCaseReference ceilTestZero = {
  625. (SDLTest_TestCaseFp) ceil_zeroCases, "ceil_zeroCases",
  626. "Check positive and negative zero", TEST_ENABLED
  627. };
  628. static const SDLTest_TestCaseReference ceilTestNan = {
  629. (SDLTest_TestCaseFp) ceil_nanCase, "ceil_nanCase",
  630. "Check the NaN special case", TEST_ENABLED
  631. };
  632. static const SDLTest_TestCaseReference ceilTestRound = {
  633. (SDLTest_TestCaseFp) ceil_roundNumbersCases, "ceil_roundNumberCases",
  634. "Check a set of round numbers", TEST_ENABLED
  635. };
  636. static const SDLTest_TestCaseReference ceilTestFraction = {
  637. (SDLTest_TestCaseFp) ceil_fractionCases, "ceil_fractionCases",
  638. "Check a set of fractions", TEST_ENABLED
  639. };
  640. static const SDLTest_TestCaseReference ceilTestRange = {
  641. (SDLTest_TestCaseFp) ceil_rangeTest, "ceil_rangeTest",
  642. "Check a range of positive integer", TEST_ENABLED
  643. };
  644. /* SDL_trunc test cases */
  645. static const SDLTest_TestCaseReference truncTestInf = {
  646. (SDLTest_TestCaseFp) trunc_infCases, "trunc_infCases",
  647. "Check positive and negative infinity", TEST_ENABLED
  648. };
  649. static const SDLTest_TestCaseReference truncTestZero = {
  650. (SDLTest_TestCaseFp) trunc_zeroCases, "trunc_zeroCases",
  651. "Check positive and negative zero", TEST_ENABLED
  652. };
  653. static const SDLTest_TestCaseReference truncTestNan = {
  654. (SDLTest_TestCaseFp) trunc_nanCase, "trunc_nanCase",
  655. "Check the NaN special case", TEST_ENABLED
  656. };
  657. static const SDLTest_TestCaseReference truncTestRound = {
  658. (SDLTest_TestCaseFp) trunc_roundNumbersCases, "trunc_roundNumberCases",
  659. "Check a set of round numbers", TEST_ENABLED
  660. };
  661. static const SDLTest_TestCaseReference truncTestFraction = {
  662. (SDLTest_TestCaseFp) trunc_fractionCases, "trunc_fractionCases",
  663. "Check a set of fractions", TEST_ENABLED
  664. };
  665. static const SDLTest_TestCaseReference truncTestRange = {
  666. (SDLTest_TestCaseFp) trunc_rangeTest, "trunc_rangeTest",
  667. "Check a range of positive integer", TEST_ENABLED
  668. };
  669. /* SDL_round test cases */
  670. static const SDLTest_TestCaseReference roundTestInf = {
  671. (SDLTest_TestCaseFp) round_infCases, "round_infCases",
  672. "Check positive and negative infinity", TEST_ENABLED
  673. };
  674. static const SDLTest_TestCaseReference roundTestZero = {
  675. (SDLTest_TestCaseFp) round_zeroCases, "round_zeroCases",
  676. "Check positive and negative zero", TEST_ENABLED
  677. };
  678. static const SDLTest_TestCaseReference roundTestNan = {
  679. (SDLTest_TestCaseFp) round_nanCase, "round_nanCase",
  680. "Check the NaN special case", TEST_ENABLED
  681. };
  682. static const SDLTest_TestCaseReference roundTestRound = {
  683. (SDLTest_TestCaseFp) round_roundNumbersCases, "round_roundNumberCases",
  684. "Check a set of round numbers", TEST_ENABLED
  685. };
  686. static const SDLTest_TestCaseReference roundTestFraction = {
  687. (SDLTest_TestCaseFp) round_fractionCases, "round_fractionCases",
  688. "Check a set of fractions", TEST_ENABLED
  689. };
  690. static const SDLTest_TestCaseReference roundTestRange = {
  691. (SDLTest_TestCaseFp) round_rangeTest, "round_rangeTest",
  692. "Check a range of positive integer", TEST_ENABLED
  693. };
  694. /* SDL_fabs test cases */
  695. static const SDLTest_TestCaseReference fabsTestInf = {
  696. (SDLTest_TestCaseFp) fabs_infCases, "fabs_infCases",
  697. "Check positive and negative infinity", TEST_ENABLED
  698. };
  699. static const SDLTest_TestCaseReference fabsTestZero = {
  700. (SDLTest_TestCaseFp) fabs_zeroCases, "fabs_zeroCases",
  701. "Check positive and negative zero", TEST_ENABLED
  702. };
  703. static const SDLTest_TestCaseReference fabsTestNan = {
  704. (SDLTest_TestCaseFp) fabs_nanCase, "fabs_nanCase",
  705. "Check the NaN special case", TEST_ENABLED
  706. };
  707. static const SDLTest_TestCaseReference fabsTestRange = {
  708. (SDLTest_TestCaseFp) fabs_rangeTest, "fabs_rangeTest",
  709. "Check a range of positive integer", TEST_ENABLED
  710. };
  711. /* SDL_copysign test cases */
  712. static const SDLTest_TestCaseReference copysignTestInf = {
  713. (SDLTest_TestCaseFp) copysign_infCases, "copysign_infCases",
  714. "Check positive and negative infinity", TEST_ENABLED
  715. };
  716. static const SDLTest_TestCaseReference copysignTestZero = {
  717. (SDLTest_TestCaseFp) copysign_zeroCases, "copysign_zeroCases",
  718. "Check positive and negative zero", TEST_ENABLED
  719. };
  720. static const SDLTest_TestCaseReference copysignTestNan = {
  721. (SDLTest_TestCaseFp) copysign_nanCases, "copysign_nanCase",
  722. "Check the NaN special cases", TEST_ENABLED
  723. };
  724. static const SDLTest_TestCaseReference copysignTestRange = {
  725. (SDLTest_TestCaseFp) copysign_rangeTest, "copysign_rangeTest",
  726. "Check a range of positive integer", TEST_ENABLED
  727. };
  728. static const SDLTest_TestCaseReference *mathTests[] = {
  729. &floorTestInf, &floorTestZero, &floorTestNan,
  730. &floorTestRound, &floorTestFraction, &floorTestRange,
  731. &ceilTestInf, &ceilTestZero, &ceilTestNan,
  732. &ceilTestRound, &ceilTestFraction, &ceilTestRange,
  733. &truncTestInf, &truncTestZero, &truncTestNan,
  734. &truncTestRound, &truncTestFraction, &truncTestRange,
  735. &roundTestInf, &roundTestZero, &roundTestNan,
  736. &roundTestRound, &roundTestFraction, &roundTestRange,
  737. &fabsTestInf, &fabsTestZero, &fabsTestNan, &fabsTestRange,
  738. &copysignTestInf, &copysignTestZero, &copysignTestNan, &copysignTestRange,
  739. NULL
  740. };
  741. SDLTest_TestSuiteReference mathTestSuite = { "Math", NULL, mathTests, NULL };