testautomation_math.c 23 KB

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