testautomation_math.c 23 KB

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