testautomation_math.c 54 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890
  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. /* SDL_pow tests functions */
  984. /* Tests with positive and negative infinities as exponents */
  985. /**
  986. * \brief Checks the cases where the base is negative one and the exponent is infinity.
  987. */
  988. static int
  989. pow_baseNOneExpInfCases(void *args)
  990. {
  991. double result;
  992. result = SDL_pow(-1.0, INFINITY);
  993. SDLTest_AssertCheck(1.0 == result,
  994. "Pow(%f,%f), expected %f, got %f",
  995. -1.0, INFINITY, 1.0, result);
  996. result = SDL_pow(-1.0, -INFINITY);
  997. SDLTest_AssertCheck(1.0 == result,
  998. "Pow(%f,%f), expected %f, got %f",
  999. -1.0, -INFINITY, 1.0, result);
  1000. return TEST_COMPLETED;
  1001. }
  1002. /**
  1003. * \brief Checks the case where the base is zero and the exponent is negative infinity.
  1004. */
  1005. static int
  1006. pow_baseZeroExpNInfCases(void *args)
  1007. {
  1008. double result;
  1009. result = SDL_pow(0.0, -INFINITY);
  1010. SDLTest_AssertCheck(INFINITY == result,
  1011. "Pow(%f,%f), expected %f, got %f",
  1012. 0.0, -INFINITY, INFINITY, result);
  1013. result = SDL_pow(-0.0, -INFINITY);
  1014. SDLTest_AssertCheck(INFINITY == result,
  1015. "Pow(%f,%f), expected %f, got %f",
  1016. -0.0, -INFINITY, INFINITY, result);
  1017. return TEST_COMPLETED;
  1018. }
  1019. /**
  1020. * \brief Checks the remaining cases where the exponent is infinity.
  1021. */
  1022. static int
  1023. pow_expInfCases(void *args)
  1024. {
  1025. double result;
  1026. result = SDL_pow(0.5, INFINITY);
  1027. SDLTest_AssertCheck(0.0 == result,
  1028. "Pow(%f,%f), expected %f, got %f",
  1029. 0.5, INFINITY, 0.0, result);
  1030. result = SDL_pow(1.5, INFINITY);
  1031. SDLTest_AssertCheck(INFINITY == result,
  1032. "Pow(%f,%f), expected %f, got %f",
  1033. 1.5, INFINITY, INFINITY, result);
  1034. result = SDL_pow(0.5, -INFINITY);
  1035. SDLTest_AssertCheck(INFINITY == result,
  1036. "Pow(%f,%f), expected %f, got %f",
  1037. 0.5, INFINITY, INFINITY, result);
  1038. result = SDL_pow(1.5, -INFINITY);
  1039. SDLTest_AssertCheck(0.0 == result,
  1040. "Pow(%f,%f), expected %f, got %f",
  1041. 1.5, -INFINITY, 0.0, result);
  1042. return TEST_COMPLETED;
  1043. }
  1044. /* Tests with positive and negative infinities as base */
  1045. /**
  1046. * \brief Checks the cases with positive infinity as base.
  1047. */
  1048. static int
  1049. pow_basePInfCases(void *args)
  1050. {
  1051. double result;
  1052. result = SDL_pow(INFINITY, -3.0);
  1053. SDLTest_AssertCheck(0.0 == result,
  1054. "Pow(%f,%f), expected %f, got %f",
  1055. INFINITY, -3.0, 0.0, result);
  1056. result = SDL_pow(INFINITY, 2.0);
  1057. SDLTest_AssertCheck(INFINITY == result,
  1058. "Pow(%f,%f), expected %f, got %f",
  1059. INFINITY, 2.0, INFINITY, result);
  1060. result = SDL_pow(INFINITY, -2.12345);
  1061. SDLTest_AssertCheck(0.0 == result,
  1062. "Pow(%f,%f), expected %f, got %f",
  1063. INFINITY, -2.12345, 0.0, result);
  1064. result = SDL_pow(INFINITY, 3.1345);
  1065. SDLTest_AssertCheck(INFINITY == result,
  1066. "Pow(%f,%f), expected %f, got %f",
  1067. INFINITY, 3.12345, INFINITY, result);
  1068. return TEST_COMPLETED;
  1069. }
  1070. /**
  1071. * \brief Checks the cases with negative infinity as base.
  1072. */
  1073. static int
  1074. pow_baseNInfCases(void *args)
  1075. {
  1076. double result;
  1077. result = SDL_pow(-INFINITY, -3.0);
  1078. SDLTest_AssertCheck(-0.0 == result,
  1079. "Pow(%f,%f), expected %f, got %f",
  1080. -INFINITY, -3.0, -0.0, result);
  1081. result = SDL_pow(-INFINITY, -2.0);
  1082. SDLTest_AssertCheck(0.0 == result,
  1083. "Pow(%f,%f), expected %f, got %f",
  1084. -INFINITY, -2.0, 0.0, result);
  1085. result = SDL_pow(-INFINITY, -5.5);
  1086. SDLTest_AssertCheck(0.0 == result,
  1087. "Pow(%f,%f), expected %f, got %f",
  1088. -INFINITY, -5.5, 0.0, result);
  1089. result = SDL_pow(-INFINITY, 3.0);
  1090. SDLTest_AssertCheck(-INFINITY == result,
  1091. "Pow(%f,%f), expected %f, got %f",
  1092. -INFINITY, 3.0, -INFINITY, result);
  1093. result = SDL_pow(-INFINITY, 2.0);
  1094. SDLTest_AssertCheck(INFINITY == result,
  1095. "Pow(%f,%f), expected %f, got %f",
  1096. -INFINITY, 2.0, INFINITY, result);
  1097. result = SDL_pow(-INFINITY, 5.5);
  1098. SDLTest_AssertCheck(INFINITY == result,
  1099. "Pow(%f,%f), expected %f, got %f",
  1100. -INFINITY, 5.5, INFINITY, result);
  1101. return TEST_COMPLETED;
  1102. }
  1103. /* Tests related to nan */
  1104. /**
  1105. * \brief Checks the case where the base is finite and negative and exponent is finite and non-integer.
  1106. */
  1107. static int
  1108. pow_badOperationCase(void *args)
  1109. {
  1110. const double result = SDL_pow(-2.0, 4.2);
  1111. SDLTest_AssertCheck(isnan(result),
  1112. "Pow(%f,%f), expected %f, got %f",
  1113. -2.0, 4.2, NAN, result);
  1114. return TEST_COMPLETED;
  1115. }
  1116. /**
  1117. * \brief Checks the case where the exponent is nan but the base is 1.
  1118. */
  1119. static int
  1120. pow_base1ExpNanCase(void *args)
  1121. {
  1122. const double result = SDL_pow(1.0, NAN);
  1123. SDLTest_AssertCheck(1.0 == result,
  1124. "Pow(%f,%f), expected %f, got %f",
  1125. 1.0, NAN, 1.0, result);
  1126. return TEST_COMPLETED;
  1127. }
  1128. /**
  1129. * \brief Checks the cases where the base is nan but the exponent is 0.
  1130. */
  1131. static int
  1132. pow_baseNanExp0Cases(void *args)
  1133. {
  1134. double result;
  1135. result = SDL_pow(NAN, 0.0);
  1136. SDLTest_AssertCheck(1.0 == result,
  1137. "Pow(%f,%f), expected %f, got %f",
  1138. NAN, 0.0, 1.0, result);
  1139. return TEST_COMPLETED;
  1140. result = SDL_pow(NAN, -0.0);
  1141. SDLTest_AssertCheck(1.0 == result,
  1142. "Pow(%f,%f), expected %f, got %f",
  1143. NAN, -0.0, 1.0, result);
  1144. return TEST_COMPLETED;
  1145. }
  1146. /**
  1147. * \brief Checks the cases where either argument is nan.
  1148. */
  1149. static int
  1150. pow_nanArgsCases(void *args)
  1151. {
  1152. double result;
  1153. result = SDL_pow(7.8, NAN);
  1154. SDLTest_AssertCheck(isnan(result),
  1155. "Pow(%f,%f), expected %f, got %f",
  1156. 7.8, NAN, NAN, result);
  1157. result = SDL_pow(NAN, 10.0);
  1158. SDLTest_AssertCheck(isnan(result),
  1159. "Pow(%f,%f), expected %f, got %f",
  1160. NAN, 10.0, NAN, result);
  1161. result = SDL_pow(NAN, NAN);
  1162. SDLTest_AssertCheck(isnan(result),
  1163. "Pow(%f,%f), expected %f, got %f",
  1164. NAN, NAN, NAN, result);
  1165. return TEST_COMPLETED;
  1166. }
  1167. /* Tests with positive and negative zeros as base */
  1168. /**
  1169. * \brief Checks cases with negative zero as base and an odd exponent.
  1170. */
  1171. static int
  1172. pow_baseNZeroExpOddCases(void *args)
  1173. {
  1174. double result;
  1175. result = SDL_pow(-0.0, -3.0);
  1176. SDLTest_AssertCheck(-INFINITY == result,
  1177. "Pow(%f,%f), expected %f, got %f",
  1178. -0.0, -3.0, -INFINITY, result);
  1179. result = SDL_pow(-0.0, 3.0);
  1180. SDLTest_AssertCheck(-0.0 == result,
  1181. "Pow(%f,%f), expected %f, got %f",
  1182. -0.0, 3.0, -0.0, result);
  1183. return TEST_COMPLETED;
  1184. }
  1185. /**
  1186. * \brief Checks cases with positive zero as base and an odd exponent.
  1187. */
  1188. static int
  1189. pow_basePZeroExpOddCases(void *args)
  1190. {
  1191. double result;
  1192. result = SDL_pow(0.0, -5.0);
  1193. SDLTest_AssertCheck(INFINITY == result,
  1194. "Pow(%f,%f), expected %f, got %f",
  1195. 0.0, -5.0, INFINITY, result);
  1196. result = SDL_pow(0.0, 5.0);
  1197. SDLTest_AssertCheck(0.0 == result,
  1198. "Pow(%f,%f), expected %f, got %f",
  1199. 0.0, 5.0, 0.0, result);
  1200. return TEST_COMPLETED;
  1201. }
  1202. /**
  1203. * \brief Checks cases with negative zero as base and the exponent is finite and even or non-integer.
  1204. */
  1205. static int
  1206. pow_baseNZeroCases(void *args)
  1207. {
  1208. double result;
  1209. result = SDL_pow(-0.0, -3.5);
  1210. SDLTest_AssertCheck(INFINITY == result,
  1211. "Pow(%f,%f), expected %f, got %f",
  1212. -0.0, -3.5, INFINITY, result);
  1213. result = SDL_pow(-0.0, -4.0);
  1214. SDLTest_AssertCheck(INFINITY == result,
  1215. "Pow(%f,%f), expected %f, got %f",
  1216. -0.0, -4.0, INFINITY, result);
  1217. result = SDL_pow(-0.0, 3.5);
  1218. SDLTest_AssertCheck(0.0 == result,
  1219. "Pow(%f,%f), expected %f, got %f",
  1220. -0.0, 3.5, 0.0, result);
  1221. result = SDL_pow(-0.0, 4.0);
  1222. SDLTest_AssertCheck(0.0 == result,
  1223. "Pow(%f,%f), expected %f, got %f",
  1224. -0.0, 4.0, 0.0, result);
  1225. return TEST_COMPLETED;
  1226. }
  1227. /**
  1228. * \brief Checks cases with positive zero as base and the exponent is finite and even or non-integer.
  1229. */
  1230. static int
  1231. pow_basePZeroCases(void *args)
  1232. {
  1233. double result;
  1234. result = SDL_pow(0.0, -3.5);
  1235. SDLTest_AssertCheck(INFINITY == result,
  1236. "Pow(%f,%f), expected %f, got %f",
  1237. 0.0, -3.5, INFINITY, result);
  1238. result = SDL_pow(0.0, -4.0);
  1239. SDLTest_AssertCheck(INFINITY == result,
  1240. "Pow(%f,%f), expected %f, got %f",
  1241. 0.0, -4.0, INFINITY, result);
  1242. result = SDL_pow(0.0, 3.5);
  1243. SDLTest_AssertCheck(0.0 == result,
  1244. "Pow(%f,%f), expected %f, got %f",
  1245. 0.0, 3.5, 0.0, result);
  1246. result = SDL_pow(0.0, 4.0);
  1247. SDLTest_AssertCheck(0.0 == result,
  1248. "Pow(%f,%f), expected %f, got %f",
  1249. 0.0, 4.0, 0.0, result);
  1250. return TEST_COMPLETED;
  1251. }
  1252. /* Remaining tests */
  1253. /**
  1254. * \brief Checks a set of regular values.
  1255. */
  1256. static int
  1257. pow_regularCases(void *args)
  1258. {
  1259. const dd_to_d regular_cases[] = {
  1260. { -391.25, -2.0, 0.00000653267870448815438463212659780943170062528224661946296691894531250 },
  1261. { -72.3, 12.0, 20401381050275984310272.0 },
  1262. { -5.0, 3.0, -125.0 },
  1263. { 3.0, 2.5, 15.58845726811989607085706666111946105957031250 },
  1264. { 39.23, -1.5, 0.0040697950366865498147972424192175822099670767784118652343750 },
  1265. { 478.972, 12.125, 315326359630449587856007411793920.0 }
  1266. };
  1267. return helper_ddtod("Pow", SDL_pow, regular_cases, SDL_arraysize(regular_cases));
  1268. }
  1269. /**
  1270. * \brief Checks the powers of two from 1 to 8.
  1271. */
  1272. static int
  1273. pow_powerOfTwo(void *args)
  1274. {
  1275. const dd_to_d power_of_two_cases[] = {
  1276. { 2.0, 1, 2.0 },
  1277. { 2.0, 2, 4.0 },
  1278. { 2.0, 3, 8.0 },
  1279. { 2.0, 4, 16.0 },
  1280. { 2.0, 5, 32.0 },
  1281. { 2.0, 6, 64.0 },
  1282. { 2.0, 7, 128.0 },
  1283. { 2.0, 8, 256.0 },
  1284. };
  1285. return helper_ddtod("Pow", SDL_pow, power_of_two_cases, SDL_arraysize(power_of_two_cases));
  1286. }
  1287. /**
  1288. * \brief Checks a range of values between 0 and UINT32_MAX to the power of 0.
  1289. */
  1290. static int
  1291. pow_rangeTest(void *args)
  1292. {
  1293. Uint32 i;
  1294. double test_value = 0.0;
  1295. SDLTest_AssertPass("Pow: Testing a range of %u values with steps of %u",
  1296. RANGE_TEST_ITERATIONS,
  1297. RANGE_TEST_STEP);
  1298. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  1299. double result;
  1300. /* These are tested elsewhere */
  1301. if (isnan(test_value) || isinf(test_value)) {
  1302. continue;
  1303. }
  1304. /* Only log failures to save performances */
  1305. result = SDL_pow(test_value, 0.0);
  1306. if (result != 1.0) {
  1307. SDLTest_AssertPass("Pow(%.1f,%.1f), expected %.1f, got %.1f",
  1308. test_value, 1.0, 1.0, result);
  1309. return TEST_ABORTED;
  1310. }
  1311. result = SDL_pow(test_value, -0.0);
  1312. if (result != 1.0) {
  1313. SDLTest_AssertPass("Pow(%.1f,%.1f), expected %.1f, got %.1f",
  1314. test_value, -0.0, 1.0, result);
  1315. return TEST_ABORTED;
  1316. }
  1317. }
  1318. return TEST_COMPLETED;
  1319. }
  1320. /* ================= Test References ================== */
  1321. /* SDL_floor test cases */
  1322. static const SDLTest_TestCaseReference floorTestInf = {
  1323. (SDLTest_TestCaseFp) floor_infCases, "floor_infCases",
  1324. "Check positive and negative infinity", TEST_ENABLED
  1325. };
  1326. static const SDLTest_TestCaseReference floorTestZero = {
  1327. (SDLTest_TestCaseFp) floor_zeroCases, "floor_zeroCases",
  1328. "Check positive and negative zero", TEST_ENABLED
  1329. };
  1330. static const SDLTest_TestCaseReference floorTestNan = {
  1331. (SDLTest_TestCaseFp) floor_nanCase, "floor_nanCase",
  1332. "Check the NaN special case", TEST_ENABLED
  1333. };
  1334. static const SDLTest_TestCaseReference floorTestRound = {
  1335. (SDLTest_TestCaseFp) floor_roundNumbersCases, "floor_roundNumberCases",
  1336. "Check a set of round numbers", TEST_ENABLED
  1337. };
  1338. static const SDLTest_TestCaseReference floorTestFraction = {
  1339. (SDLTest_TestCaseFp) floor_fractionCases, "floor_fractionCases",
  1340. "Check a set of fractions", TEST_ENABLED
  1341. };
  1342. static const SDLTest_TestCaseReference floorTestRange = {
  1343. (SDLTest_TestCaseFp) floor_rangeTest, "floor_rangeTest",
  1344. "Check a range of positive integer", TEST_ENABLED
  1345. };
  1346. /* SDL_ceil test cases */
  1347. static const SDLTest_TestCaseReference ceilTestInf = {
  1348. (SDLTest_TestCaseFp) ceil_infCases, "ceil_infCases",
  1349. "Check positive and negative infinity", TEST_ENABLED
  1350. };
  1351. static const SDLTest_TestCaseReference ceilTestZero = {
  1352. (SDLTest_TestCaseFp) ceil_zeroCases, "ceil_zeroCases",
  1353. "Check positive and negative zero", TEST_ENABLED
  1354. };
  1355. static const SDLTest_TestCaseReference ceilTestNan = {
  1356. (SDLTest_TestCaseFp) ceil_nanCase, "ceil_nanCase",
  1357. "Check the NaN special case", TEST_ENABLED
  1358. };
  1359. static const SDLTest_TestCaseReference ceilTestRound = {
  1360. (SDLTest_TestCaseFp) ceil_roundNumbersCases, "ceil_roundNumberCases",
  1361. "Check a set of round numbers", TEST_ENABLED
  1362. };
  1363. static const SDLTest_TestCaseReference ceilTestFraction = {
  1364. (SDLTest_TestCaseFp) ceil_fractionCases, "ceil_fractionCases",
  1365. "Check a set of fractions", TEST_ENABLED
  1366. };
  1367. static const SDLTest_TestCaseReference ceilTestRange = {
  1368. (SDLTest_TestCaseFp) ceil_rangeTest, "ceil_rangeTest",
  1369. "Check a range of positive integer", TEST_ENABLED
  1370. };
  1371. /* SDL_trunc test cases */
  1372. static const SDLTest_TestCaseReference truncTestInf = {
  1373. (SDLTest_TestCaseFp) trunc_infCases, "trunc_infCases",
  1374. "Check positive and negative infinity", TEST_ENABLED
  1375. };
  1376. static const SDLTest_TestCaseReference truncTestZero = {
  1377. (SDLTest_TestCaseFp) trunc_zeroCases, "trunc_zeroCases",
  1378. "Check positive and negative zero", TEST_ENABLED
  1379. };
  1380. static const SDLTest_TestCaseReference truncTestNan = {
  1381. (SDLTest_TestCaseFp) trunc_nanCase, "trunc_nanCase",
  1382. "Check the NaN special case", TEST_ENABLED
  1383. };
  1384. static const SDLTest_TestCaseReference truncTestRound = {
  1385. (SDLTest_TestCaseFp) trunc_roundNumbersCases, "trunc_roundNumberCases",
  1386. "Check a set of round numbers", TEST_ENABLED
  1387. };
  1388. static const SDLTest_TestCaseReference truncTestFraction = {
  1389. (SDLTest_TestCaseFp) trunc_fractionCases, "trunc_fractionCases",
  1390. "Check a set of fractions", TEST_ENABLED
  1391. };
  1392. static const SDLTest_TestCaseReference truncTestRange = {
  1393. (SDLTest_TestCaseFp) trunc_rangeTest, "trunc_rangeTest",
  1394. "Check a range of positive integer", TEST_ENABLED
  1395. };
  1396. /* SDL_round test cases */
  1397. static const SDLTest_TestCaseReference roundTestInf = {
  1398. (SDLTest_TestCaseFp) round_infCases, "round_infCases",
  1399. "Check positive and negative infinity", TEST_ENABLED
  1400. };
  1401. static const SDLTest_TestCaseReference roundTestZero = {
  1402. (SDLTest_TestCaseFp) round_zeroCases, "round_zeroCases",
  1403. "Check positive and negative zero", TEST_ENABLED
  1404. };
  1405. static const SDLTest_TestCaseReference roundTestNan = {
  1406. (SDLTest_TestCaseFp) round_nanCase, "round_nanCase",
  1407. "Check the NaN special case", TEST_ENABLED
  1408. };
  1409. static const SDLTest_TestCaseReference roundTestRound = {
  1410. (SDLTest_TestCaseFp) round_roundNumbersCases, "round_roundNumberCases",
  1411. "Check a set of round numbers", TEST_ENABLED
  1412. };
  1413. static const SDLTest_TestCaseReference roundTestFraction = {
  1414. (SDLTest_TestCaseFp) round_fractionCases, "round_fractionCases",
  1415. "Check a set of fractions", TEST_ENABLED
  1416. };
  1417. static const SDLTest_TestCaseReference roundTestRange = {
  1418. (SDLTest_TestCaseFp) round_rangeTest, "round_rangeTest",
  1419. "Check a range of positive integer", TEST_ENABLED
  1420. };
  1421. /* SDL_fabs test cases */
  1422. static const SDLTest_TestCaseReference fabsTestInf = {
  1423. (SDLTest_TestCaseFp) fabs_infCases, "fabs_infCases",
  1424. "Check positive and negative infinity", TEST_ENABLED
  1425. };
  1426. static const SDLTest_TestCaseReference fabsTestZero = {
  1427. (SDLTest_TestCaseFp) fabs_zeroCases, "fabs_zeroCases",
  1428. "Check positive and negative zero", TEST_ENABLED
  1429. };
  1430. static const SDLTest_TestCaseReference fabsTestNan = {
  1431. (SDLTest_TestCaseFp) fabs_nanCase, "fabs_nanCase",
  1432. "Check the NaN special case", TEST_ENABLED
  1433. };
  1434. static const SDLTest_TestCaseReference fabsTestRange = {
  1435. (SDLTest_TestCaseFp) fabs_rangeTest, "fabs_rangeTest",
  1436. "Check a range of positive integer", TEST_ENABLED
  1437. };
  1438. /* SDL_copysign test cases */
  1439. static const SDLTest_TestCaseReference copysignTestInf = {
  1440. (SDLTest_TestCaseFp) copysign_infCases, "copysign_infCases",
  1441. "Check positive and negative infinity", TEST_ENABLED
  1442. };
  1443. static const SDLTest_TestCaseReference copysignTestZero = {
  1444. (SDLTest_TestCaseFp) copysign_zeroCases, "copysign_zeroCases",
  1445. "Check positive and negative zero", TEST_ENABLED
  1446. };
  1447. static const SDLTest_TestCaseReference copysignTestNan = {
  1448. (SDLTest_TestCaseFp) copysign_nanCases, "copysign_nanCases",
  1449. "Check the NaN special cases", TEST_ENABLED
  1450. };
  1451. static const SDLTest_TestCaseReference copysignTestRange = {
  1452. (SDLTest_TestCaseFp) copysign_rangeTest, "copysign_rangeTest",
  1453. "Check a range of positive integer", TEST_ENABLED
  1454. };
  1455. /* SDL_fmod test cases */
  1456. static const SDLTest_TestCaseReference fmodTestDivOfInf = {
  1457. (SDLTest_TestCaseFp) fmod_divOfInfCases, "fmod_divOfInfCases",
  1458. "Check division of positive and negative infinity", TEST_ENABLED
  1459. };
  1460. static const SDLTest_TestCaseReference fmodTestDivByInf = {
  1461. (SDLTest_TestCaseFp) fmod_divByInfCases, "fmod_divByInfCases",
  1462. "Check division by positive and negative infinity", TEST_ENABLED
  1463. };
  1464. static const SDLTest_TestCaseReference fmodTestDivOfZero = {
  1465. (SDLTest_TestCaseFp) fmod_divOfZeroCases, "fmod_divOfZeroCases",
  1466. "Check division of positive and negative zero", TEST_ENABLED
  1467. };
  1468. static const SDLTest_TestCaseReference fmodTestDivByZero = {
  1469. (SDLTest_TestCaseFp) fmod_divByZeroCases, "fmod_divByZeroCases",
  1470. "Check division by positive and negative zero", TEST_ENABLED
  1471. };
  1472. static const SDLTest_TestCaseReference fmodTestNan = {
  1473. (SDLTest_TestCaseFp) fmod_nanCases, "fmod_nanCases",
  1474. "Check the NaN special cases", TEST_ENABLED
  1475. };
  1476. static const SDLTest_TestCaseReference fmodTestRegular = {
  1477. (SDLTest_TestCaseFp) fmod_regularCases, "fmod_regularCases",
  1478. "Check a set of regular values", TEST_ENABLED
  1479. };
  1480. static const SDLTest_TestCaseReference fmodTestRange = {
  1481. (SDLTest_TestCaseFp) fmod_rangeTest, "fmod_rangeTest",
  1482. "Check a range of positive integer", TEST_ENABLED
  1483. };
  1484. /* SDL_exp test cases */
  1485. static const SDLTest_TestCaseReference expTestInf = {
  1486. (SDLTest_TestCaseFp) exp_infCases, "exp_infCases",
  1487. "Check positive and negative infinity", TEST_ENABLED
  1488. };
  1489. static const SDLTest_TestCaseReference expTestZero = {
  1490. (SDLTest_TestCaseFp) exp_zeroCases, "exp_zeroCases",
  1491. "Check for positive and negative zero", TEST_ENABLED
  1492. };
  1493. static const SDLTest_TestCaseReference expTestOverflow = {
  1494. (SDLTest_TestCaseFp) exp_overflowCase, "exp_overflowCase",
  1495. "Check for overflow", TEST_ENABLED
  1496. };
  1497. static const SDLTest_TestCaseReference expTestBase = {
  1498. (SDLTest_TestCaseFp) exp_baseCase, "exp_baseCase",
  1499. "Check the base case of 1.0", TEST_ENABLED
  1500. };
  1501. static const SDLTest_TestCaseReference expTestRegular = {
  1502. (SDLTest_TestCaseFp) exp_regularCases, "exp_regularCases",
  1503. "Check a set of regular values", TEST_ENABLED
  1504. };
  1505. /* SDL_log test cases */
  1506. static const SDLTest_TestCaseReference logTestLimit = {
  1507. (SDLTest_TestCaseFp) log_limitCases, "log_limitCases",
  1508. "Check for limits", TEST_ENABLED
  1509. };
  1510. static const SDLTest_TestCaseReference logTestNan = {
  1511. (SDLTest_TestCaseFp) log_nanCases, "log_nanCases",
  1512. "Check for the nan cases", TEST_ENABLED
  1513. };
  1514. static const SDLTest_TestCaseReference logTestBase = {
  1515. (SDLTest_TestCaseFp) log_baseCases, "log_baseCases",
  1516. "Check for base cases", TEST_ENABLED
  1517. };
  1518. static const SDLTest_TestCaseReference logTestRegular = {
  1519. (SDLTest_TestCaseFp) log_regularCases, "log_regularCases",
  1520. "Check a set of regular values", TEST_ENABLED
  1521. };
  1522. /* SDL_log10 test cases */
  1523. static const SDLTest_TestCaseReference log10TestLimit = {
  1524. (SDLTest_TestCaseFp) log10_limitCases, "log10_limitCases",
  1525. "Check for limits", TEST_ENABLED
  1526. };
  1527. static const SDLTest_TestCaseReference log10TestNan = {
  1528. (SDLTest_TestCaseFp) log10_nanCases, "log10_nanCases",
  1529. "Check for the nan cases", TEST_ENABLED
  1530. };
  1531. static const SDLTest_TestCaseReference log10TestBase = {
  1532. (SDLTest_TestCaseFp) log10_baseCases, "log10_baseCases",
  1533. "Check for base cases", TEST_ENABLED
  1534. };
  1535. static const SDLTest_TestCaseReference log10TestRegular = {
  1536. (SDLTest_TestCaseFp) log10_regularCases, "log10_regularCases",
  1537. "Check a set of regular values", TEST_ENABLED
  1538. };
  1539. /* SDL_pow test cases */
  1540. static const SDLTest_TestCaseReference powTestExpInf1 = {
  1541. (SDLTest_TestCaseFp) pow_baseNOneExpInfCases, "pow_baseNOneExpInfCases",
  1542. "Check for pow(-1, +/-inf)", TEST_ENABLED
  1543. };
  1544. static const SDLTest_TestCaseReference powTestExpInf2 = {
  1545. (SDLTest_TestCaseFp) pow_baseZeroExpNInfCases, "pow_baseZeroExpNInfCases",
  1546. "Check for pow(+/-0, -inf)", TEST_ENABLED
  1547. };
  1548. static const SDLTest_TestCaseReference powTestExpInf3 = {
  1549. (SDLTest_TestCaseFp) pow_expInfCases, "pow_expInfCases",
  1550. "Check for pow(x, +/-inf)", TEST_ENABLED
  1551. };
  1552. static const SDLTest_TestCaseReference powTestBaseInf1 = {
  1553. (SDLTest_TestCaseFp) pow_basePInfCases, "pow_basePInfCases",
  1554. "Check for pow(inf, x)", TEST_ENABLED
  1555. };
  1556. static const SDLTest_TestCaseReference powTestBaseInf2 = {
  1557. (SDLTest_TestCaseFp) pow_baseNInfCases, "pow_baseNInfCases",
  1558. "Check for pow(-inf, x)", TEST_ENABLED
  1559. };
  1560. static const SDLTest_TestCaseReference powTestNan1 = {
  1561. (SDLTest_TestCaseFp) pow_badOperationCase, "pow_badOperationCase",
  1562. "Check for negative finite base and non-integer finite exponent", TEST_ENABLED
  1563. };
  1564. static const SDLTest_TestCaseReference powTestNan2 = {
  1565. (SDLTest_TestCaseFp) pow_base1ExpNanCase, "pow_base1ExpNanCase",
  1566. "Check for pow(1.0, nan)", TEST_ENABLED
  1567. };
  1568. static const SDLTest_TestCaseReference powTestNan3 = {
  1569. (SDLTest_TestCaseFp) pow_baseNanExp0Cases, "pow_baseNanExp0Cases",
  1570. "Check for pow(nan, +/-0)", TEST_ENABLED
  1571. };
  1572. static const SDLTest_TestCaseReference powTestNan4 = {
  1573. (SDLTest_TestCaseFp) pow_nanArgsCases, "pow_nanArgsCases",
  1574. "Check for pow(x, y) with either x or y being nan", TEST_ENABLED
  1575. };
  1576. static const SDLTest_TestCaseReference powTestZero1 = {
  1577. (SDLTest_TestCaseFp) pow_baseNZeroExpOddCases, "pow_baseNZeroExpOddCases",
  1578. "Check for pow(-0.0, y), with y an odd integer.", TEST_ENABLED
  1579. };
  1580. static const SDLTest_TestCaseReference powTestZero2 = {
  1581. (SDLTest_TestCaseFp) pow_basePZeroExpOddCases, "pow_basePZeroExpOddCases",
  1582. "Check for pow(0.0, y), with y an odd integer.", TEST_ENABLED
  1583. };
  1584. static const SDLTest_TestCaseReference powTestZero3 = {
  1585. (SDLTest_TestCaseFp) pow_baseNZeroCases, "pow_baseNZeroCases",
  1586. "Check for pow(-0.0, y), with y finite and even or non-integer number", TEST_ENABLED
  1587. };
  1588. static const SDLTest_TestCaseReference powTestZero4 = {
  1589. (SDLTest_TestCaseFp) pow_basePZeroCases, "pow_basePZeroCases",
  1590. "Check for pow(0.0, y), with y finite and even or non-integer number", TEST_ENABLED
  1591. };
  1592. static const SDLTest_TestCaseReference powTestRegular = {
  1593. (SDLTest_TestCaseFp) pow_regularCases, "pow_regularCases",
  1594. "Check a set of regular values", TEST_ENABLED
  1595. };
  1596. static const SDLTest_TestCaseReference powTestPowOf2 = {
  1597. (SDLTest_TestCaseFp) pow_powerOfTwo, "pow_powerOfTwo",
  1598. "Check the powers of two from 1 to 8", TEST_ENABLED
  1599. };
  1600. static const SDLTest_TestCaseReference powTestRange = {
  1601. (SDLTest_TestCaseFp) pow_rangeTest, "pow_rangeTest",
  1602. "Check a range of positive integer to the power of 0", TEST_ENABLED
  1603. };
  1604. static const SDLTest_TestCaseReference *mathTests[] = {
  1605. &floorTestInf, &floorTestZero, &floorTestNan,
  1606. &floorTestRound, &floorTestFraction, &floorTestRange,
  1607. &ceilTestInf, &ceilTestZero, &ceilTestNan,
  1608. &ceilTestRound, &ceilTestFraction, &ceilTestRange,
  1609. &truncTestInf, &truncTestZero, &truncTestNan,
  1610. &truncTestRound, &truncTestFraction, &truncTestRange,
  1611. &roundTestInf, &roundTestZero, &roundTestNan,
  1612. &roundTestRound, &roundTestFraction, &roundTestRange,
  1613. &fabsTestInf, &fabsTestZero, &fabsTestNan, &fabsTestRange,
  1614. &copysignTestInf, &copysignTestZero, &copysignTestNan, &copysignTestRange,
  1615. &fmodTestDivOfInf, &fmodTestDivByInf, &fmodTestDivOfZero, &fmodTestDivByZero,
  1616. &fmodTestNan, &fmodTestRegular, &fmodTestRange,
  1617. &expTestInf, &expTestZero, &expTestOverflow,
  1618. &expTestBase, &expTestRegular,
  1619. &logTestLimit, &logTestNan,
  1620. &logTestBase, &logTestRegular,
  1621. &log10TestLimit, &log10TestNan,
  1622. &log10TestBase, &log10TestRegular,
  1623. &powTestExpInf1, &powTestExpInf2, &powTestExpInf3,
  1624. &powTestBaseInf1, &powTestBaseInf2,
  1625. &powTestNan1, &powTestNan2, &powTestNan3, &powTestNan4,
  1626. &powTestZero1, &powTestZero2, &powTestZero3, &powTestZero4,
  1627. &powTestRegular, &powTestPowOf2, &powTestRange,
  1628. NULL
  1629. };
  1630. SDLTest_TestSuiteReference mathTestSuite = { "Math", NULL, mathTests, NULL };