testautomation_math.c 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409
  1. /**
  2. * Math test suite
  3. */
  4. #include <math.h>
  5. #include <float.h>
  6. #include "SDL.h"
  7. #include "SDL_test.h"
  8. /* Range tests parameters */
  9. #define RANGE_TEST_ITERATIONS 10000000
  10. #define RANGE_TEST_STEP SDL_MAX_UINT32 / RANGE_TEST_ITERATIONS
  11. /* Define the Euler constant */
  12. #ifndef M_E
  13. #define EULER 2.7182818284590450907955982984276488423347473144531250
  14. #else
  15. #define EULER M_E
  16. #endif
  17. /* ================= Test Structs ================== */
  18. /**
  19. * Stores a single input and the expected result
  20. */
  21. typedef struct
  22. {
  23. double input;
  24. double expected;
  25. } d_to_d;
  26. /**
  27. * Stores a pair of inputs and the expected result
  28. */
  29. typedef struct
  30. {
  31. double x_input, y_input;
  32. double expected;
  33. } dd_to_d;
  34. /*
  35. NB: You cannot create an array of these structures containing INFINITY or NAN.
  36. On platforms such as OS/2, they are defined as 'extern const double' making them
  37. not compile-time constant.
  38. */
  39. /* ================= Test Helpers ================== */
  40. typedef double(SDLCALL *d_to_d_func)(double);
  41. typedef double(SDLCALL *dd_to_d_func)(double, double);
  42. /**
  43. * \brief Runs all the cases on a given function with a signature double -> double
  44. *
  45. * \param func_name, the name of the tested function.
  46. * \param func, the function to call.
  47. * \param cases, an array of all the cases.
  48. * \param cases_size, the size of the cases array.
  49. */
  50. static int
  51. helper_dtod(const char *func_name, d_to_d_func func,
  52. const d_to_d *cases, const size_t cases_size)
  53. {
  54. Uint32 i;
  55. for (i = 0; i < cases_size; i++) {
  56. const double result = func(cases[i].input);
  57. SDLTest_AssertCheck(result == cases[i].expected,
  58. "%s(%f), expected %f, got %f",
  59. func_name,
  60. cases[i].input,
  61. cases[i].expected, result);
  62. }
  63. return TEST_COMPLETED;
  64. }
  65. /**
  66. * \brief Runs all the cases on a given function with a signature (double, double) -> double
  67. *
  68. * \param func_name, the name of the tested function.
  69. * \param func, the function to call.
  70. * \param cases, an array of all the cases.
  71. * \param cases_size, the size of the cases array.
  72. */
  73. static int
  74. helper_ddtod(const char *func_name, dd_to_d_func func,
  75. const dd_to_d *cases, const size_t cases_size)
  76. {
  77. Uint32 i;
  78. for (i = 0; i < cases_size; i++) {
  79. const double result = func(cases[i].x_input, cases[i].y_input);
  80. SDLTest_AssertCheck(result == cases[i].expected,
  81. "%s(%f,%f), expected %f, got %f",
  82. func_name,
  83. cases[i].x_input, cases[i].y_input,
  84. cases[i].expected, result);
  85. }
  86. return TEST_COMPLETED;
  87. }
  88. /**
  89. * \brief Runs a range of values on a given function with a signature double -> double
  90. *
  91. * This function is only meant to test functions that returns the input value if it is
  92. * integral: f(x) -> x for x in N.
  93. *
  94. * \param func_name, the name of the tested function.
  95. * \param func, the function to call.
  96. */
  97. static int
  98. helper_range(const char *func_name, d_to_d_func func)
  99. {
  100. Uint32 i;
  101. double test_value = 0.0;
  102. SDLTest_AssertPass("%s: Testing a range of %u values with steps of %u",
  103. func_name,
  104. RANGE_TEST_ITERATIONS,
  105. RANGE_TEST_STEP);
  106. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  107. double result;
  108. /* These are tested elsewhere */
  109. if (isnan(test_value) || isinf(test_value)) {
  110. continue;
  111. }
  112. result = func(test_value);
  113. if (result != test_value) { /* Only log failures to save performances */
  114. SDLTest_AssertCheck(SDL_FALSE,
  115. "%s(%.1f), expected %.1f, got %.1f",
  116. func_name, test_value,
  117. test_value, result);
  118. return TEST_ABORTED;
  119. }
  120. }
  121. return TEST_COMPLETED;
  122. }
  123. /* ================= Test Case Implementation ================== */
  124. /* SDL_floor tests functions */
  125. /**
  126. * \brief Checks positive and negative infinity.
  127. */
  128. static int
  129. floor_infCases(void *args)
  130. {
  131. double result;
  132. result = SDL_floor(INFINITY);
  133. SDLTest_AssertCheck(INFINITY == result,
  134. "Floor(%f), expected %f, got %f",
  135. INFINITY, INFINITY, result);
  136. result = SDL_floor(-INFINITY);
  137. SDLTest_AssertCheck(-INFINITY == result,
  138. "Floor(%f), expected %f, got %f",
  139. -INFINITY, -INFINITY, result);
  140. return TEST_COMPLETED;
  141. }
  142. /**
  143. * \brief Checks positive and negative zero.
  144. */
  145. static int
  146. floor_zeroCases(void *args)
  147. {
  148. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  149. return helper_dtod("Floor", SDL_floor, zero_cases, SDL_arraysize(zero_cases));
  150. }
  151. /**
  152. * \brief Checks the NaN case.
  153. */
  154. static int
  155. floor_nanCase(void *args)
  156. {
  157. const double result = SDL_floor(NAN);
  158. SDLTest_AssertCheck(isnan(result),
  159. "Floor(nan), expected nan, got %f",
  160. result);
  161. return TEST_COMPLETED;
  162. }
  163. /**
  164. * \brief Checks round values (x.0) for themselves
  165. */
  166. static int
  167. floor_roundNumbersCases(void *args)
  168. {
  169. const d_to_d round_cases[] = {
  170. { 1.0, 1.0 },
  171. { -1.0, -1.0 },
  172. { 15.0, 15.0 },
  173. { -15.0, -15.0 },
  174. { 125.0, 125.0 },
  175. { -125.0, -125.0 },
  176. { 1024.0, 1024.0 },
  177. { -1024.0, -1024.0 }
  178. };
  179. return helper_dtod("Floor", SDL_floor, round_cases, SDL_arraysize(round_cases));
  180. }
  181. /**
  182. * \brief Checks a set of fractions
  183. */
  184. static int
  185. floor_fractionCases(void *args)
  186. {
  187. const d_to_d frac_cases[] = {
  188. { 1.0 / 2.0, 0.0 },
  189. { -1.0 / 2.0, -1.0 },
  190. { 4.0 / 3.0, 1.0 },
  191. { -4.0 / 3.0, -2.0 },
  192. { 76.0 / 7.0, 10.0 },
  193. { -76.0 / 7.0, -11.0 },
  194. { 535.0 / 8.0, 66.0 },
  195. { -535.0 / 8.0, -67.0 },
  196. { 19357.0 / 53.0, 365.0 },
  197. { -19357.0 / 53.0, -366.0 }
  198. };
  199. return helper_dtod("Floor", SDL_floor, frac_cases, SDL_arraysize(frac_cases));
  200. }
  201. /**
  202. * \brief Checks a range of values between 0 and UINT32_MAX
  203. */
  204. static int
  205. floor_rangeTest(void *args)
  206. {
  207. return helper_range("Floor", SDL_floor);
  208. }
  209. /* SDL_ceil tests functions */
  210. /**
  211. * \brief Checks positive and negative infinity.
  212. */
  213. static int
  214. ceil_infCases(void *args)
  215. {
  216. double result;
  217. result = SDL_ceil(INFINITY);
  218. SDLTest_AssertCheck(INFINITY == result,
  219. "Ceil(%f), expected %f, got %f",
  220. INFINITY, INFINITY, result);
  221. result = SDL_ceil(-INFINITY);
  222. SDLTest_AssertCheck(-INFINITY == result,
  223. "Ceil(%f), expected %f, got %f",
  224. -INFINITY, -INFINITY, result);
  225. return TEST_COMPLETED;
  226. }
  227. /**
  228. * \brief Checks positive and negative zero.
  229. */
  230. static int
  231. ceil_zeroCases(void *args)
  232. {
  233. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  234. return helper_dtod("Ceil", SDL_ceil, zero_cases, SDL_arraysize(zero_cases));
  235. }
  236. /**
  237. * \brief Checks the NaN case.
  238. */
  239. static int
  240. ceil_nanCase(void *args)
  241. {
  242. const double result = SDL_ceil(NAN);
  243. SDLTest_AssertCheck(isnan(result),
  244. "Ceil(nan), expected nan, got %f",
  245. result);
  246. return TEST_COMPLETED;
  247. }
  248. /**
  249. * \brief Checks round values (x.0) for themselves
  250. */
  251. static int
  252. ceil_roundNumbersCases(void *args)
  253. {
  254. const d_to_d round_cases[] = {
  255. { 1.0, 1.0 },
  256. { -1.0, -1.0 },
  257. { 15.0, 15.0 },
  258. { -15.0, -15.0 },
  259. { 125.0, 125.0 },
  260. { -125.0, -125.0 },
  261. { 1024.0, 1024.0 },
  262. { -1024.0, -1024.0 }
  263. };
  264. return helper_dtod("Ceil", SDL_ceil, round_cases, SDL_arraysize(round_cases));
  265. }
  266. /**
  267. * \brief Checks a set of fractions
  268. */
  269. static int
  270. ceil_fractionCases(void *args)
  271. {
  272. const d_to_d frac_cases[] = {
  273. { 1.0 / 2.0, 1.0 },
  274. { -1.0 / 2.0, -0.0 },
  275. { 4.0 / 3.0, 2.0 },
  276. { -4.0 / 3.0, -1.0 },
  277. { 76.0 / 7.0, 11.0 },
  278. { -76.0 / 7.0, -10.0 },
  279. { 535.0 / 8.0, 67.0 },
  280. { -535.0 / 8.0, -66.0 },
  281. { 19357.0 / 53.0, 366.0 },
  282. { -19357.0 / 53.0, -365.0 }
  283. };
  284. return helper_dtod("Ceil", SDL_ceil, frac_cases, SDL_arraysize(frac_cases));
  285. }
  286. /**
  287. * \brief Checks a range of values between 0 and UINT32_MAX
  288. */
  289. static int
  290. ceil_rangeTest(void *args)
  291. {
  292. return helper_range("Ceil", SDL_ceil);
  293. }
  294. /* SDL_trunc tests functions */
  295. /**
  296. * \brief Checks positive and negative infinity.
  297. */
  298. static int
  299. trunc_infCases(void *args)
  300. {
  301. double result;
  302. result = SDL_trunc(INFINITY);
  303. SDLTest_AssertCheck(INFINITY == result,
  304. "Trunc(%f), expected %f, got %f",
  305. INFINITY, INFINITY, result);
  306. result = SDL_trunc(-INFINITY);
  307. SDLTest_AssertCheck(-INFINITY == result,
  308. "Trunc(%f), expected %f, got %f",
  309. -INFINITY, -INFINITY, result);
  310. return TEST_COMPLETED;
  311. }
  312. /**
  313. * \brief Checks positive and negative zero.
  314. */
  315. static int
  316. trunc_zeroCases(void *args)
  317. {
  318. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  319. return helper_dtod("Trunc", SDL_trunc, zero_cases, SDL_arraysize(zero_cases));
  320. }
  321. /**
  322. * \brief Checks the NaN case.
  323. */
  324. static int
  325. trunc_nanCase(void *args)
  326. {
  327. const double result = SDL_trunc(NAN);
  328. SDLTest_AssertCheck(isnan(result),
  329. "Trunc(nan), expected nan, got %f",
  330. result);
  331. return TEST_COMPLETED;
  332. }
  333. /**
  334. * \brief Checks round values (x.0) for themselves
  335. */
  336. static int
  337. trunc_roundNumbersCases(void *args)
  338. {
  339. const d_to_d round_cases[] = {
  340. { 1.0, 1.0 },
  341. { -1.0, -1.0 },
  342. { 15.0, 15.0 },
  343. { -15.0, -15.0 },
  344. { 125.0, 125.0 },
  345. { -125.0, -125.0 },
  346. { 1024.0, 1024.0 },
  347. { -1024.0, -1024.0 }
  348. };
  349. return helper_dtod("Trunc", SDL_trunc, round_cases, SDL_arraysize(round_cases));
  350. }
  351. /**
  352. * \brief Checks a set of fractions
  353. */
  354. static int
  355. trunc_fractionCases(void *args)
  356. {
  357. const d_to_d frac_cases[] = {
  358. { 1.0 / 2.0, 0.0 },
  359. { -1.0 / 2.0, -0.0 },
  360. { 4.0 / 3.0, 1.0 },
  361. { -4.0 / 3.0, -1.0 },
  362. { 76.0 / 7.0, 10.0 },
  363. { -76.0 / 7.0, -10.0 },
  364. { 535.0 / 8.0, 66.0 },
  365. { -535.0 / 8.0, -66.0 },
  366. { 19357.0 / 53.0, 365.0 },
  367. { -19357.0 / 53.0, -365.0 }
  368. };
  369. return helper_dtod("Trunc", SDL_trunc, frac_cases, SDL_arraysize(frac_cases));
  370. }
  371. /**
  372. * \brief Checks a range of values between 0 and UINT32_MAX
  373. */
  374. static int
  375. trunc_rangeTest(void *args)
  376. {
  377. return helper_range("Trunc", SDL_trunc);
  378. }
  379. /* SDL_round tests functions */
  380. /**
  381. * \brief Checks positive and negative infinity.
  382. */
  383. static int
  384. round_infCases(void *args)
  385. {
  386. double result;
  387. result = SDL_round(INFINITY);
  388. SDLTest_AssertCheck(INFINITY == result,
  389. "Round(%f), expected %f, got %f",
  390. INFINITY, INFINITY, result);
  391. result = SDL_round(-INFINITY);
  392. SDLTest_AssertCheck(-INFINITY == result,
  393. "Round(%f), expected %f, got %f",
  394. -INFINITY, -INFINITY, result);
  395. return TEST_COMPLETED;
  396. }
  397. /**
  398. * \brief Checks positive and negative zero.
  399. */
  400. static int
  401. round_zeroCases(void *args)
  402. {
  403. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, -0.0 } };
  404. return helper_dtod("Round", SDL_round, zero_cases, SDL_arraysize(zero_cases));
  405. }
  406. /**
  407. * \brief Checks the NaN case.
  408. */
  409. static int
  410. round_nanCase(void *args)
  411. {
  412. const double result = SDL_round(NAN);
  413. SDLTest_AssertCheck(isnan(result),
  414. "Round(nan), expected nan, got %f",
  415. result);
  416. return TEST_COMPLETED;
  417. }
  418. /**
  419. * \brief Checks round values (x.0) for themselves
  420. */
  421. static int
  422. round_roundNumbersCases(void *args)
  423. {
  424. const d_to_d round_cases[] = {
  425. { 1.0, 1.0 },
  426. { -1.0, -1.0 },
  427. { 15.0, 15.0 },
  428. { -15.0, -15.0 },
  429. { 125.0, 125.0 },
  430. { -125.0, -125.0 },
  431. { 1024.0, 1024.0 },
  432. { -1024.0, -1024.0 }
  433. };
  434. return helper_dtod("Round", SDL_round, round_cases, SDL_arraysize(round_cases));
  435. }
  436. /**
  437. * \brief Checks a set of fractions
  438. */
  439. static int
  440. round_fractionCases(void *args)
  441. {
  442. const d_to_d frac_cases[] = {
  443. { 1.0 / 2.0, 1.0 },
  444. { -1.0 / 2.0, -1.0 },
  445. { 4.0 / 3.0, 1.0 },
  446. { -4.0 / 3.0, -1.0 },
  447. { 76.0 / 7.0, 11.0 },
  448. { -76.0 / 7.0, -11.0 },
  449. { 535.0 / 8.0, 67.0 },
  450. { -535.0 / 8.0, -67.0 },
  451. { 19357.0 / 53.0, 365.0 },
  452. { -19357.0 / 53.0, -365.0 }
  453. };
  454. return helper_dtod("Round", SDL_round, frac_cases, SDL_arraysize(frac_cases));
  455. }
  456. /**
  457. * \brief Checks a range of values between 0 and UINT32_MAX
  458. */
  459. static int
  460. round_rangeTest(void *args)
  461. {
  462. return helper_range("Round", SDL_round);
  463. }
  464. /* SDL_fabs tests functions */
  465. /**
  466. * \brief Checks positive and negative infinity.
  467. */
  468. static int
  469. fabs_infCases(void *args)
  470. {
  471. double result;
  472. result = SDL_fabs(INFINITY);
  473. SDLTest_AssertCheck(INFINITY == result,
  474. "Fabs(%f), expected %f, got %f",
  475. INFINITY, INFINITY, result);
  476. result = SDL_fabs(-INFINITY);
  477. SDLTest_AssertCheck(INFINITY == result,
  478. "Fabs(%f), expected %f, got %f",
  479. -INFINITY, INFINITY, result);
  480. return TEST_COMPLETED;
  481. }
  482. /**
  483. * \brief Checks positive and negative zero
  484. */
  485. static int
  486. fabs_zeroCases(void *args)
  487. {
  488. const d_to_d zero_cases[] = { { 0.0, 0.0 }, { -0.0, 0.0 } };
  489. return helper_dtod("Fabs", SDL_fabs, zero_cases, SDL_arraysize(zero_cases));
  490. }
  491. /**
  492. * \brief Checks the NaN case.
  493. */
  494. static int
  495. fabs_nanCase(void *args)
  496. {
  497. const double result = SDL_fabs(NAN);
  498. SDLTest_AssertCheck(isnan(result),
  499. "Fabs(nan), expected nan, got %f",
  500. result);
  501. return TEST_COMPLETED;
  502. }
  503. /**
  504. * \brief Checks a range of values between 0 and UINT32_MAX
  505. */
  506. static int
  507. fabs_rangeTest(void *args)
  508. {
  509. return helper_range("Fabs", SDL_fabs);
  510. }
  511. /* SDL_copysign tests functions */
  512. /**
  513. * \brief Checks positive and negative inifnity.
  514. */
  515. static int
  516. copysign_infCases(void *args)
  517. {
  518. double result;
  519. result = SDL_copysign(INFINITY, -1.0);
  520. SDLTest_AssertCheck(-INFINITY == result,
  521. "Copysign(%f,%.1f), expected %f, got %f",
  522. INFINITY, -1.0, -INFINITY, result);
  523. result = SDL_copysign(INFINITY, 1.0);
  524. SDLTest_AssertCheck(INFINITY == result,
  525. "Copysign(%f,%.1f), expected %f, got %f",
  526. INFINITY, 1.0, INFINITY, result);
  527. result = SDL_copysign(-INFINITY, -1.0);
  528. SDLTest_AssertCheck(-INFINITY == result,
  529. "Copysign(%f,%.1f), expected %f, got %f",
  530. -INFINITY, -1.0, -INFINITY, result);
  531. result = SDL_copysign(-INFINITY, 1.0);
  532. SDLTest_AssertCheck(INFINITY == result,
  533. "Copysign(%f,%.1f), expected %f, got %f",
  534. -INFINITY, 1.0, INFINITY, result);
  535. return TEST_COMPLETED;
  536. }
  537. /**
  538. * \brief Checks positive and negative zero.
  539. */
  540. static int
  541. copysign_zeroCases(void *args)
  542. {
  543. const dd_to_d zero_cases[] = {
  544. { 0.0, 1.0, 0.0 },
  545. { 0.0, -1.0, -0.0 },
  546. { -0.0, 1.0, 0.0 },
  547. { -0.0, -1.0, -0.0 }
  548. };
  549. return helper_ddtod("Copysign", SDL_copysign, zero_cases, SDL_arraysize(zero_cases));
  550. }
  551. /**
  552. * \brief Checks the NaN cases.
  553. */
  554. static int
  555. copysign_nanCases(void *args)
  556. {
  557. double result;
  558. result = SDL_copysign(NAN, 1.0);
  559. SDLTest_AssertCheck(isnan(result),
  560. "Copysign(nan,1.0), expected nan, got %f",
  561. result);
  562. result = SDL_copysign(NAN, -1.0);
  563. SDLTest_AssertCheck(isnan(result),
  564. "Copysign(nan,-1.0), expected nan, got %f",
  565. result);
  566. return TEST_COMPLETED;
  567. }
  568. /**
  569. * \brief Checks a range of values between 0 and UINT32_MAX
  570. */
  571. static int
  572. copysign_rangeTest(void *args)
  573. {
  574. Uint32 i;
  575. double test_value = 0.0;
  576. SDLTest_AssertPass("Copysign: Testing a range of %u values with steps of %u",
  577. RANGE_TEST_ITERATIONS,
  578. RANGE_TEST_STEP);
  579. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  580. double result;
  581. /* These are tested elsewhere */
  582. if (isnan(test_value) || isinf(test_value)) {
  583. continue;
  584. }
  585. /* Only log failures to save performances */
  586. result = SDL_copysign(test_value, 1.0);
  587. if (result != test_value) {
  588. SDLTest_AssertCheck(SDL_FALSE,
  589. "Copysign(%.1f,%.1f), expected %.1f, got %.1f",
  590. test_value, 1.0, test_value, result);
  591. return TEST_ABORTED;
  592. }
  593. result = SDL_copysign(test_value, -1.0);
  594. if (result != -test_value) {
  595. SDLTest_AssertCheck(SDL_FALSE,
  596. "Copysign(%.1f,%.1f), expected %.1f, got %.1f",
  597. test_value, -1.0, -test_value, result);
  598. return TEST_ABORTED;
  599. }
  600. }
  601. return TEST_COMPLETED;
  602. }
  603. /* SDL_fmod tests functions */
  604. /**
  605. * \brief Checks division of positive and negative inifnity.
  606. */
  607. static int
  608. fmod_divOfInfCases(void *args)
  609. {
  610. double result;
  611. result = SDL_fmod(INFINITY, -1.0);
  612. SDLTest_AssertCheck(isnan(result),
  613. "Fmod(%f,%.1f), expected %f, got %f",
  614. INFINITY, -1.0, NAN, result);
  615. result = SDL_fmod(INFINITY, 1.0);
  616. SDLTest_AssertCheck(isnan(result),
  617. "Fmod(%f,%.1f), expected %f, got %f",
  618. INFINITY, 1.0, NAN, result);
  619. result = SDL_fmod(-INFINITY, -1.0);
  620. SDLTest_AssertCheck(isnan(result),
  621. "Fmod(%f,%.1f), expected %f, got %f",
  622. -INFINITY, -1.0, NAN, result);
  623. result = SDL_fmod(-INFINITY, 1.0);
  624. SDLTest_AssertCheck(isnan(result),
  625. "Fmod(%f,%.1f), expected %f, got %f",
  626. -INFINITY, 1.0, NAN, result);
  627. return TEST_COMPLETED;
  628. }
  629. /**
  630. * \brief Checks division by positive and negative inifnity.
  631. */
  632. static int
  633. fmod_divByInfCases(void *args)
  634. {
  635. double result;
  636. result = SDL_fmod(1.0, INFINITY);
  637. SDLTest_AssertCheck(1.0 == result,
  638. "Fmod(%.1f,%f), expected %f, got %f",
  639. 1.0, INFINITY, 1.0, result);
  640. result = SDL_fmod(-1.0, INFINITY);
  641. SDLTest_AssertCheck(-1.0 == result,
  642. "Fmod(%.1f,%f), expected %f, got %f",
  643. -1.0, INFINITY, -1.0, result);
  644. result = SDL_fmod(1.0, -INFINITY);
  645. SDLTest_AssertCheck(1.0 == result,
  646. "Fmod(%.1f,%f), expected %f, got %f",
  647. 1.0, -INFINITY, 1.0, result);
  648. result = SDL_fmod(-1.0, -INFINITY);
  649. SDLTest_AssertCheck(-1.0 == result,
  650. "Fmod(%.1f,%f), expected %f, got %f",
  651. -1.0, -INFINITY, -1.0, result);
  652. return TEST_COMPLETED;
  653. }
  654. /**
  655. * \brief Checks division of positive and negative zero.
  656. */
  657. static int
  658. fmod_divOfZeroCases(void *args)
  659. {
  660. const dd_to_d zero_cases[] = {
  661. { 0.0, 1.0, 0.0 },
  662. { 0.0, -1.0, 0.0 },
  663. { -0.0, 1.0, -0.0 },
  664. { -0.0, -1.0, -0.0 }
  665. };
  666. return helper_ddtod("Fmod", SDL_fmod, zero_cases, SDL_arraysize(zero_cases));
  667. }
  668. /**
  669. * \brief Checks division by positive and negative zero.
  670. */
  671. static int
  672. fmod_divByZeroCases(void *args)
  673. {
  674. double result;
  675. result = SDL_fmod(1.0, 0.0);
  676. SDLTest_AssertCheck(isnan(result),
  677. "Fmod(1.0,0.0), expected nan, got %f",
  678. result);
  679. result = SDL_fmod(-1.0, 0.0);
  680. SDLTest_AssertCheck(isnan(result),
  681. "Fmod(-1.0,0.0), expected nan, got %f",
  682. result);
  683. result = SDL_fmod(1.0, -0.0);
  684. SDLTest_AssertCheck(isnan(result),
  685. "Fmod(1.0,-0.0), expected nan, got %f",
  686. result);
  687. result = SDL_fmod(-1.0, -0.0);
  688. SDLTest_AssertCheck(isnan(result),
  689. "Fmod(-1.0,-0.0), expected nan, got %f",
  690. result);
  691. return TEST_COMPLETED;
  692. }
  693. /**
  694. * \brief Checks the NaN cases.
  695. */
  696. static int
  697. fmod_nanCases(void *args)
  698. {
  699. double result;
  700. result = SDL_fmod(NAN, 1.0);
  701. SDLTest_AssertCheck(isnan(result),
  702. "Fmod(nan,1.0), expected nan, got %f",
  703. result);
  704. result = SDL_fmod(NAN, -1.0);
  705. SDLTest_AssertCheck(isnan(result),
  706. "Fmod(nan,-1.0), expected nan, got %f",
  707. result);
  708. result = SDL_fmod(1.0, NAN);
  709. SDLTest_AssertCheck(isnan(result),
  710. "Fmod(1.0,nan), expected nan, got %f",
  711. result);
  712. result = SDL_fmod(-1.0, NAN);
  713. SDLTest_AssertCheck(isnan(result),
  714. "Fmod(-1.0,nan), expected nan, got %f",
  715. result);
  716. return TEST_COMPLETED;
  717. }
  718. /**
  719. * \brief Checks a set of regular values.
  720. */
  721. static int
  722. fmod_regularCases(void *args)
  723. {
  724. const dd_to_d regular_cases[] = {
  725. { 3.5, 2.0, 1.5 },
  726. { -6.25, 3.0, -0.25 },
  727. { 7.5, 2.5, 0.0 },
  728. { 2.0 / 3.0, -1.0 / 3.0, 0.0 }
  729. };
  730. return helper_ddtod("Fmod", SDL_fmod, regular_cases, SDL_arraysize(regular_cases));
  731. }
  732. /**
  733. * \brief Checks a range of values between 0 and UINT32_MAX
  734. */
  735. static int
  736. fmod_rangeTest(void *args)
  737. {
  738. Uint32 i;
  739. double test_value = 0.0;
  740. SDLTest_AssertPass("Fmod: Testing a range of %u values with steps of %u",
  741. RANGE_TEST_ITERATIONS,
  742. RANGE_TEST_STEP);
  743. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  744. double result;
  745. /* These are tested elsewhere */
  746. if (isnan(test_value) || isinf(test_value)) {
  747. continue;
  748. }
  749. /* Only log failures to save performances */
  750. result = SDL_fmod(test_value, 1.0);
  751. if (0.0 != result) {
  752. SDLTest_AssertCheck(SDL_FALSE,
  753. "Fmod(%.1f,%.1f), expected %.1f, got %.1f",
  754. test_value, 1.0, 0.0, result);
  755. return TEST_ABORTED;
  756. }
  757. }
  758. return TEST_COMPLETED;
  759. }
  760. /* SDL_exp tests functions */
  761. /**
  762. * \brief Checks positive and negative infinity.
  763. */
  764. static int
  765. exp_infCases(void *args)
  766. {
  767. double result;
  768. result = SDL_exp(INFINITY);
  769. SDLTest_AssertCheck(INFINITY == result,
  770. "Exp(%f), expected %f, got %f",
  771. INFINITY, INFINITY, result);
  772. result = SDL_exp(-INFINITY);
  773. SDLTest_AssertCheck(0.0 == result,
  774. "Exp(%f), expected %f, got %f",
  775. -INFINITY, 0.0, result);
  776. return TEST_COMPLETED;
  777. }
  778. /**
  779. * \brief Checks positive and negative zero.
  780. */
  781. static int
  782. exp_zeroCases(void *args)
  783. {
  784. const d_to_d zero_cases[] = {
  785. { 0.0, 1.0 },
  786. { -0.0, 1.0 }
  787. };
  788. return helper_dtod("Exp", SDL_exp, zero_cases, SDL_arraysize(zero_cases));
  789. }
  790. /**
  791. * \brief Checks for overflow.
  792. *
  793. * This test is skipped for double types larger than 64 bits.
  794. */
  795. static int
  796. exp_overflowCase(void *args)
  797. {
  798. double result;
  799. if (sizeof(double) > 8) {
  800. return TEST_SKIPPED;
  801. }
  802. result = SDL_exp(710.0);
  803. SDLTest_AssertCheck(isinf(result),
  804. "Exp(%f), expected %f, got %f",
  805. 710.0, INFINITY, result);
  806. return TEST_COMPLETED;
  807. }
  808. /**
  809. * \brief Checks the base case of 1.0.
  810. */
  811. static int
  812. exp_baseCase(void *args)
  813. {
  814. const double result = SDL_exp(1.0);
  815. SDLTest_AssertCheck(EULER == result,
  816. "Exp(%f), expected %f, got %f",
  817. 1.0, EULER, result);
  818. return TEST_COMPLETED;
  819. }
  820. /**
  821. * \brief Checks a set of regular cases.
  822. */
  823. static int
  824. exp_regularCases(void *args)
  825. {
  826. /* Hexadecimal floating constants are not supported on C89 compilers */
  827. const d_to_d regular_cases[] = {
  828. { -101.0, 1.36853947117385291381565719268793547578002532127613087E-44 },
  829. { -15.73, 0.00000014741707833928422931856502906683425990763681 },
  830. { -1.0, 0.36787944117144233402427744294982403516769409179688 },
  831. { -0.5, 0.60653065971263342426311737654032185673713684082031 },
  832. { 0.5, 1.64872127070012819416433558217249810695648193359375 },
  833. { 2.25, 9.48773583635852624240669683786109089851379394531250 },
  834. { 34.125, 661148770968660.375 },
  835. { 112.89, 10653788283588960962604279261058893737879589093376.0 },
  836. { 539.483, 1970107755334319939701129934673541628417235942656909222826926175622435588279443011110464355295725187195188154768877850257012251677751742837992843520967922303961718983154427294786640886286983037548604937796221048661733679844353544028160.0 },
  837. };
  838. return helper_dtod("Exp", SDL_exp, regular_cases, SDL_arraysize(regular_cases));
  839. }
  840. /* SDL_log tests functions */
  841. /**
  842. * \brief Checks limits (zeros and positive infinity).
  843. */
  844. static int
  845. log_limitCases(void *args)
  846. {
  847. double result;
  848. result = SDL_log(INFINITY);
  849. SDLTest_AssertCheck(INFINITY == result,
  850. "Log(%f), expected %f, got %f",
  851. INFINITY, INFINITY, result);
  852. result = SDL_log(0.0);
  853. SDLTest_AssertCheck(-INFINITY == result,
  854. "Log(%f), expected %f, got %f",
  855. 0.0, -INFINITY, result);
  856. result = SDL_log(-0.0);
  857. SDLTest_AssertCheck(-INFINITY == result,
  858. "Log(%f), expected %f, got %f",
  859. -0.0, -INFINITY, result);
  860. return TEST_COMPLETED;
  861. }
  862. /**
  863. * \brief Checks some base cases.
  864. */
  865. static int
  866. log_baseCases(void *args)
  867. {
  868. double result;
  869. result = SDL_log(1.0);
  870. SDLTest_AssertCheck(0.0 == result,
  871. "Log(%f), expected %f, got %f",
  872. 1.0, 0.0, result);
  873. result = SDL_log(EULER);
  874. SDLTest_AssertCheck(1.0 == result,
  875. "Log(%f), expected %f, got %f",
  876. EULER, 1.0, result);
  877. return TEST_COMPLETED;
  878. }
  879. /**
  880. * \brief Checks the nan cases.
  881. */
  882. static int
  883. log_nanCases(void *args)
  884. {
  885. double result;
  886. result = SDL_log(NAN);
  887. SDLTest_AssertCheck(isnan(result),
  888. "Log(%f), expected %f, got %f",
  889. NAN, NAN, result);
  890. result = SDL_log(-1234.5678);
  891. SDLTest_AssertCheck(isnan(result),
  892. "Log(%f), expected %f, got %f",
  893. -1234.5678, NAN, result);
  894. return TEST_COMPLETED;
  895. }
  896. /**
  897. * \brief Checks a set of regular cases.
  898. */
  899. static int
  900. log_regularCases(void *args)
  901. {
  902. const d_to_d regular_cases[] = {
  903. { 5.0, 1.60943791243410028179994242236716672778129577636718750 },
  904. { 10.0, 2.302585092994045901093613792909309267997741699218750 },
  905. { 56.32, 4.031049711849786554296315443934872746467590332031250 },
  906. { 789.123, 6.670922202231861497523368598194792866706848144531250 },
  907. { 2734.876324, 7.91384149408957959792587644187733530998229980468750 }
  908. };
  909. return helper_dtod("Log", SDL_log, regular_cases, SDL_arraysize(regular_cases));
  910. }
  911. /* SDL_log10 tests functions */
  912. /**
  913. * \brief Checks limits (zeros and positive infinity).
  914. */
  915. static int
  916. log10_limitCases(void *args)
  917. {
  918. double result;
  919. result = SDL_log10(INFINITY);
  920. SDLTest_AssertCheck(INFINITY == result,
  921. "Log10(%f), expected %f, got %f",
  922. INFINITY, INFINITY, result);
  923. result = SDL_log10(0.0);
  924. SDLTest_AssertCheck(-INFINITY == result,
  925. "Log10(%f), expected %f, got %f",
  926. 0.0, -INFINITY, result);
  927. result = SDL_log10(-0.0);
  928. SDLTest_AssertCheck(-INFINITY == result,
  929. "Log10(%f), expected %f, got %f",
  930. -0.0, -INFINITY, result);
  931. return TEST_COMPLETED;
  932. }
  933. /**
  934. * \brief Checks some base cases.
  935. */
  936. static int
  937. log10_baseCases(void *args)
  938. {
  939. const d_to_d base_cases[] = {
  940. { 1.0, 0.0 },
  941. { 10.0, 1.0 },
  942. { 100.0, 2.0 },
  943. { 1000.0, 3.0 },
  944. { 10000.0, 4.0 },
  945. { 100000.0, 5.0 },
  946. { 1000000.0, 6.0 },
  947. { 10000000.0, 7.0 },
  948. { 100000000.0, 8.0 },
  949. { 1000000000.0, 9.0 },
  950. };
  951. return helper_dtod("Log10", SDL_log10, base_cases, SDL_arraysize(base_cases));
  952. }
  953. /**
  954. * \brief Checks the nan cases.
  955. */
  956. static int
  957. log10_nanCases(void *args)
  958. {
  959. double result;
  960. result = SDL_log10(NAN);
  961. SDLTest_AssertCheck(isnan(result),
  962. "Log10(%f), expected %f, got %f",
  963. NAN, NAN, result);
  964. result = SDL_log10(-1234.5678);
  965. SDLTest_AssertCheck(isnan(result),
  966. "Log10(%f), expected %f, got %f",
  967. -1234.5678, NAN, result);
  968. return TEST_COMPLETED;
  969. }
  970. /**
  971. * \brief Checks a set of regular cases.
  972. */
  973. static int
  974. log10_regularCases(void *args)
  975. {
  976. const d_to_d regular_cases[] = {
  977. { 5.0, 0.698970004336018857493684208748163655400276184082031250 },
  978. { 12.5, 1.09691001300805646145875016372883692383766174316406250 },
  979. { 56.32, 1.750662646134055755453573510749265551567077636718750 },
  980. { 789.123, 2.8971447016351858927407647570362314581871032714843750 },
  981. { 2734.876324, 3.436937691540090433761633903486654162406921386718750 }
  982. };
  983. return helper_dtod("Log10", SDL_log10, regular_cases, SDL_arraysize(regular_cases));
  984. }
  985. /* SDL_pow tests functions */
  986. /* Tests with positive and negative infinities as exponents */
  987. /**
  988. * \brief Checks the cases where the base is negative one and the exponent is infinity.
  989. */
  990. static int
  991. pow_baseNOneExpInfCases(void *args)
  992. {
  993. double result;
  994. result = SDL_pow(-1.0, INFINITY);
  995. SDLTest_AssertCheck(1.0 == result,
  996. "Pow(%f,%f), expected %f, got %f",
  997. -1.0, INFINITY, 1.0, result);
  998. result = SDL_pow(-1.0, -INFINITY);
  999. SDLTest_AssertCheck(1.0 == result,
  1000. "Pow(%f,%f), expected %f, got %f",
  1001. -1.0, -INFINITY, 1.0, result);
  1002. return TEST_COMPLETED;
  1003. }
  1004. /**
  1005. * \brief Checks the case where the base is zero and the exponent is negative infinity.
  1006. */
  1007. static int
  1008. pow_baseZeroExpNInfCases(void *args)
  1009. {
  1010. double result;
  1011. result = SDL_pow(0.0, -INFINITY);
  1012. SDLTest_AssertCheck(INFINITY == result,
  1013. "Pow(%f,%f), expected %f, got %f",
  1014. 0.0, -INFINITY, INFINITY, result);
  1015. result = SDL_pow(-0.0, -INFINITY);
  1016. SDLTest_AssertCheck(INFINITY == result,
  1017. "Pow(%f,%f), expected %f, got %f",
  1018. -0.0, -INFINITY, INFINITY, result);
  1019. return TEST_COMPLETED;
  1020. }
  1021. /**
  1022. * \brief Checks the remaining cases where the exponent is infinity.
  1023. */
  1024. static int
  1025. pow_expInfCases(void *args)
  1026. {
  1027. double result;
  1028. result = SDL_pow(0.5, INFINITY);
  1029. SDLTest_AssertCheck(0.0 == result,
  1030. "Pow(%f,%f), expected %f, got %f",
  1031. 0.5, INFINITY, 0.0, result);
  1032. result = SDL_pow(1.5, INFINITY);
  1033. SDLTest_AssertCheck(INFINITY == result,
  1034. "Pow(%f,%f), expected %f, got %f",
  1035. 1.5, INFINITY, INFINITY, result);
  1036. result = SDL_pow(0.5, -INFINITY);
  1037. SDLTest_AssertCheck(INFINITY == result,
  1038. "Pow(%f,%f), expected %f, got %f",
  1039. 0.5, INFINITY, INFINITY, result);
  1040. result = SDL_pow(1.5, -INFINITY);
  1041. SDLTest_AssertCheck(0.0 == result,
  1042. "Pow(%f,%f), expected %f, got %f",
  1043. 1.5, -INFINITY, 0.0, result);
  1044. return TEST_COMPLETED;
  1045. }
  1046. /* Tests with positive and negative infinities as base */
  1047. /**
  1048. * \brief Checks the cases with positive infinity as base.
  1049. */
  1050. static int
  1051. pow_basePInfCases(void *args)
  1052. {
  1053. double result;
  1054. result = SDL_pow(INFINITY, -3.0);
  1055. SDLTest_AssertCheck(0.0 == result,
  1056. "Pow(%f,%f), expected %f, got %f",
  1057. INFINITY, -3.0, 0.0, result);
  1058. result = SDL_pow(INFINITY, 2.0);
  1059. SDLTest_AssertCheck(INFINITY == result,
  1060. "Pow(%f,%f), expected %f, got %f",
  1061. INFINITY, 2.0, INFINITY, result);
  1062. result = SDL_pow(INFINITY, -2.12345);
  1063. SDLTest_AssertCheck(0.0 == result,
  1064. "Pow(%f,%f), expected %f, got %f",
  1065. INFINITY, -2.12345, 0.0, result);
  1066. result = SDL_pow(INFINITY, 3.1345);
  1067. SDLTest_AssertCheck(INFINITY == result,
  1068. "Pow(%f,%f), expected %f, got %f",
  1069. INFINITY, 3.12345, INFINITY, result);
  1070. return TEST_COMPLETED;
  1071. }
  1072. /**
  1073. * \brief Checks the cases with negative infinity as base.
  1074. */
  1075. static int
  1076. pow_baseNInfCases(void *args)
  1077. {
  1078. double result;
  1079. result = SDL_pow(-INFINITY, -3.0);
  1080. SDLTest_AssertCheck(-0.0 == result,
  1081. "Pow(%f,%f), expected %f, got %f",
  1082. -INFINITY, -3.0, -0.0, result);
  1083. result = SDL_pow(-INFINITY, -2.0);
  1084. SDLTest_AssertCheck(0.0 == result,
  1085. "Pow(%f,%f), expected %f, got %f",
  1086. -INFINITY, -2.0, 0.0, result);
  1087. result = SDL_pow(-INFINITY, -5.5);
  1088. SDLTest_AssertCheck(0.0 == result,
  1089. "Pow(%f,%f), expected %f, got %f",
  1090. -INFINITY, -5.5, 0.0, result);
  1091. result = SDL_pow(-INFINITY, 3.0);
  1092. SDLTest_AssertCheck(-INFINITY == result,
  1093. "Pow(%f,%f), expected %f, got %f",
  1094. -INFINITY, 3.0, -INFINITY, result);
  1095. result = SDL_pow(-INFINITY, 2.0);
  1096. SDLTest_AssertCheck(INFINITY == result,
  1097. "Pow(%f,%f), expected %f, got %f",
  1098. -INFINITY, 2.0, INFINITY, result);
  1099. result = SDL_pow(-INFINITY, 5.5);
  1100. SDLTest_AssertCheck(INFINITY == result,
  1101. "Pow(%f,%f), expected %f, got %f",
  1102. -INFINITY, 5.5, INFINITY, result);
  1103. return TEST_COMPLETED;
  1104. }
  1105. /* Tests related to nan */
  1106. /**
  1107. * \brief Checks the case where the base is finite and negative and exponent is finite and non-integer.
  1108. */
  1109. static int
  1110. pow_badOperationCase(void *args)
  1111. {
  1112. const double result = SDL_pow(-2.0, 4.2);
  1113. SDLTest_AssertCheck(isnan(result),
  1114. "Pow(%f,%f), expected %f, got %f",
  1115. -2.0, 4.2, NAN, result);
  1116. return TEST_COMPLETED;
  1117. }
  1118. /**
  1119. * \brief Checks the case where the exponent is nan but the base is 1.
  1120. */
  1121. static int
  1122. pow_base1ExpNanCase(void *args)
  1123. {
  1124. const double result = SDL_pow(1.0, NAN);
  1125. SDLTest_AssertCheck(1.0 == result,
  1126. "Pow(%f,%f), expected %f, got %f",
  1127. 1.0, NAN, 1.0, result);
  1128. return TEST_COMPLETED;
  1129. }
  1130. /**
  1131. * \brief Checks the cases where the base is nan but the exponent is 0.
  1132. */
  1133. static int
  1134. pow_baseNanExp0Cases(void *args)
  1135. {
  1136. double result;
  1137. result = SDL_pow(NAN, 0.0);
  1138. SDLTest_AssertCheck(1.0 == result,
  1139. "Pow(%f,%f), expected %f, got %f",
  1140. NAN, 0.0, 1.0, result);
  1141. return TEST_COMPLETED;
  1142. result = SDL_pow(NAN, -0.0);
  1143. SDLTest_AssertCheck(1.0 == result,
  1144. "Pow(%f,%f), expected %f, got %f",
  1145. NAN, -0.0, 1.0, result);
  1146. return TEST_COMPLETED;
  1147. }
  1148. /**
  1149. * \brief Checks the cases where either argument is nan.
  1150. */
  1151. static int
  1152. pow_nanArgsCases(void *args)
  1153. {
  1154. double result;
  1155. result = SDL_pow(7.8, NAN);
  1156. SDLTest_AssertCheck(isnan(result),
  1157. "Pow(%f,%f), expected %f, got %f",
  1158. 7.8, NAN, NAN, result);
  1159. result = SDL_pow(NAN, 10.0);
  1160. SDLTest_AssertCheck(isnan(result),
  1161. "Pow(%f,%f), expected %f, got %f",
  1162. NAN, 10.0, NAN, result);
  1163. result = SDL_pow(NAN, NAN);
  1164. SDLTest_AssertCheck(isnan(result),
  1165. "Pow(%f,%f), expected %f, got %f",
  1166. NAN, NAN, NAN, result);
  1167. return TEST_COMPLETED;
  1168. }
  1169. /* Tests with positive and negative zeros as base */
  1170. /**
  1171. * \brief Checks cases with negative zero as base and an odd exponent.
  1172. */
  1173. static int
  1174. pow_baseNZeroExpOddCases(void *args)
  1175. {
  1176. double result;
  1177. result = SDL_pow(-0.0, -3.0);
  1178. SDLTest_AssertCheck(-INFINITY == result,
  1179. "Pow(%f,%f), expected %f, got %f",
  1180. -0.0, -3.0, -INFINITY, result);
  1181. result = SDL_pow(-0.0, 3.0);
  1182. SDLTest_AssertCheck(-0.0 == result,
  1183. "Pow(%f,%f), expected %f, got %f",
  1184. -0.0, 3.0, -0.0, result);
  1185. return TEST_COMPLETED;
  1186. }
  1187. /**
  1188. * \brief Checks cases with positive zero as base and an odd exponent.
  1189. */
  1190. static int
  1191. pow_basePZeroExpOddCases(void *args)
  1192. {
  1193. double result;
  1194. result = SDL_pow(0.0, -5.0);
  1195. SDLTest_AssertCheck(INFINITY == result,
  1196. "Pow(%f,%f), expected %f, got %f",
  1197. 0.0, -5.0, INFINITY, result);
  1198. result = SDL_pow(0.0, 5.0);
  1199. SDLTest_AssertCheck(0.0 == result,
  1200. "Pow(%f,%f), expected %f, got %f",
  1201. 0.0, 5.0, 0.0, result);
  1202. return TEST_COMPLETED;
  1203. }
  1204. /**
  1205. * \brief Checks cases with negative zero as base and the exponent is finite and even or non-integer.
  1206. */
  1207. static int
  1208. pow_baseNZeroCases(void *args)
  1209. {
  1210. double result;
  1211. result = SDL_pow(-0.0, -3.5);
  1212. SDLTest_AssertCheck(INFINITY == result,
  1213. "Pow(%f,%f), expected %f, got %f",
  1214. -0.0, -3.5, INFINITY, result);
  1215. result = SDL_pow(-0.0, -4.0);
  1216. SDLTest_AssertCheck(INFINITY == result,
  1217. "Pow(%f,%f), expected %f, got %f",
  1218. -0.0, -4.0, INFINITY, result);
  1219. result = SDL_pow(-0.0, 3.5);
  1220. SDLTest_AssertCheck(0.0 == result,
  1221. "Pow(%f,%f), expected %f, got %f",
  1222. -0.0, 3.5, 0.0, result);
  1223. result = SDL_pow(-0.0, 4.0);
  1224. SDLTest_AssertCheck(0.0 == result,
  1225. "Pow(%f,%f), expected %f, got %f",
  1226. -0.0, 4.0, 0.0, result);
  1227. return TEST_COMPLETED;
  1228. }
  1229. /**
  1230. * \brief Checks cases with positive zero as base and the exponent is finite and even or non-integer.
  1231. */
  1232. static int
  1233. pow_basePZeroCases(void *args)
  1234. {
  1235. double result;
  1236. result = SDL_pow(0.0, -3.5);
  1237. SDLTest_AssertCheck(INFINITY == result,
  1238. "Pow(%f,%f), expected %f, got %f",
  1239. 0.0, -3.5, INFINITY, result);
  1240. result = SDL_pow(0.0, -4.0);
  1241. SDLTest_AssertCheck(INFINITY == result,
  1242. "Pow(%f,%f), expected %f, got %f",
  1243. 0.0, -4.0, INFINITY, result);
  1244. result = SDL_pow(0.0, 3.5);
  1245. SDLTest_AssertCheck(0.0 == result,
  1246. "Pow(%f,%f), expected %f, got %f",
  1247. 0.0, 3.5, 0.0, result);
  1248. result = SDL_pow(0.0, 4.0);
  1249. SDLTest_AssertCheck(0.0 == result,
  1250. "Pow(%f,%f), expected %f, got %f",
  1251. 0.0, 4.0, 0.0, result);
  1252. return TEST_COMPLETED;
  1253. }
  1254. /* Remaining tests */
  1255. /**
  1256. * \brief Checks a set of regular values.
  1257. */
  1258. static int
  1259. pow_regularCases(void *args)
  1260. {
  1261. const dd_to_d regular_cases[] = {
  1262. { -391.25, -2.0, 0.00000653267870448815438463212659780943170062528224661946296691894531250 },
  1263. { -72.3, 12.0, 20401381050275984310272.0 },
  1264. { -5.0, 3.0, -125.0 },
  1265. { 3.0, 2.5, 15.58845726811989607085706666111946105957031250 },
  1266. { 39.23, -1.5, 0.0040697950366865498147972424192175822099670767784118652343750 },
  1267. { 478.972, 12.125, 315326359630449587856007411793920.0 }
  1268. };
  1269. return helper_ddtod("Pow", SDL_pow, regular_cases, SDL_arraysize(regular_cases));
  1270. }
  1271. /**
  1272. * \brief Checks the powers of two from 1 to 8.
  1273. */
  1274. static int
  1275. pow_powerOfTwo(void *args)
  1276. {
  1277. const dd_to_d power_of_two_cases[] = {
  1278. { 2.0, 1, 2.0 },
  1279. { 2.0, 2, 4.0 },
  1280. { 2.0, 3, 8.0 },
  1281. { 2.0, 4, 16.0 },
  1282. { 2.0, 5, 32.0 },
  1283. { 2.0, 6, 64.0 },
  1284. { 2.0, 7, 128.0 },
  1285. { 2.0, 8, 256.0 },
  1286. };
  1287. return helper_ddtod("Pow", SDL_pow, power_of_two_cases, SDL_arraysize(power_of_two_cases));
  1288. }
  1289. /**
  1290. * \brief Checks a range of values between 0 and UINT32_MAX to the power of 0.
  1291. */
  1292. static int
  1293. pow_rangeTest(void *args)
  1294. {
  1295. Uint32 i;
  1296. double test_value = 0.0;
  1297. SDLTest_AssertPass("Pow: Testing a range of %u values with steps of %u",
  1298. RANGE_TEST_ITERATIONS,
  1299. RANGE_TEST_STEP);
  1300. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  1301. double result;
  1302. /* These are tested elsewhere */
  1303. if (isnan(test_value) || isinf(test_value)) {
  1304. continue;
  1305. }
  1306. /* Only log failures to save performances */
  1307. result = SDL_pow(test_value, 0.0);
  1308. if (result != 1.0) {
  1309. SDLTest_AssertCheck(SDL_FALSE,
  1310. "Pow(%.1f,%.1f), expected %.1f, got %.1f",
  1311. test_value, 1.0, 1.0, result);
  1312. return TEST_ABORTED;
  1313. }
  1314. result = SDL_pow(test_value, -0.0);
  1315. if (result != 1.0) {
  1316. SDLTest_AssertCheck(SDL_FALSE,
  1317. "Pow(%.1f,%.1f), expected %.1f, got %.1f",
  1318. test_value, -0.0, 1.0, result);
  1319. return TEST_ABORTED;
  1320. }
  1321. }
  1322. return TEST_COMPLETED;
  1323. }
  1324. /* SDL_sqrt tests functions */
  1325. /**
  1326. * \brief Checks for positive infinity.
  1327. */
  1328. static int
  1329. sqrt_infCase(void *args)
  1330. {
  1331. const double result = SDL_sqrt(INFINITY);
  1332. SDLTest_AssertCheck(INFINITY == result,
  1333. "Sqrt(%f), expected %f, got %f",
  1334. INFINITY, INFINITY, result);
  1335. return TEST_COMPLETED;
  1336. }
  1337. /**
  1338. * \brief Checks for the nan case.
  1339. */
  1340. static int
  1341. sqrt_nanCase(void *args)
  1342. {
  1343. const double result = SDL_sqrt(NAN);
  1344. SDLTest_AssertCheck(isnan(result),
  1345. "Sqrt(%f), expected %f, got %f",
  1346. NAN, NAN, result);
  1347. return TEST_COMPLETED;
  1348. }
  1349. /**
  1350. * \brief Checks for out of domain values (<0).
  1351. */
  1352. static int
  1353. sqrt_outOfDomainCases(void *args)
  1354. {
  1355. double result;
  1356. result = SDL_sqrt(-1.0);
  1357. SDLTest_AssertCheck(isnan(result),
  1358. "Sqrt(%f), expected %f, got %f",
  1359. -1.0, NAN, result);
  1360. result = SDL_sqrt(-12345.6789);
  1361. SDLTest_AssertCheck(isnan(result),
  1362. "Sqrt(%f), expected %f, got %f",
  1363. -12345.6789, NAN, result);
  1364. result = SDL_sqrt(-INFINITY);
  1365. SDLTest_AssertCheck(isnan(result),
  1366. "Sqrt(%f), expected %f, got %f",
  1367. -INFINITY, NAN, result);
  1368. return TEST_COMPLETED;
  1369. }
  1370. /**
  1371. * \brief Checks a set of base cases.
  1372. */
  1373. static int
  1374. sqrt_baseCases(void *args)
  1375. {
  1376. const d_to_d base_cases[] = {
  1377. { -0.0, -0.0 },
  1378. { 0.0, 0.0 },
  1379. { 1.0, 1.0 }
  1380. };
  1381. return helper_dtod("Sqrt", SDL_sqrt, base_cases, SDL_arraysize(base_cases));
  1382. }
  1383. /**
  1384. * \brief Checks a set of regular cases.
  1385. */
  1386. static int
  1387. sqrt_regularCases(void *args)
  1388. {
  1389. const d_to_d regular_cases[] = {
  1390. { 4.0, 2.0 },
  1391. { 9.0, 3.0 },
  1392. { 27.2, 5.21536192416211896727418206864967942237854003906250 },
  1393. { 240.250, 15.5 },
  1394. { 1337.0, 36.565010597564445049556525191292166709899902343750 },
  1395. { 2887.12782400000014604302123188972473144531250, 53.732 },
  1396. { 65600.0156250, 256.125 }
  1397. };
  1398. return helper_dtod("Sqrt", SDL_sqrt, regular_cases, SDL_arraysize(regular_cases));
  1399. }
  1400. /* SDL_scalbn tests functions */
  1401. /**
  1402. * \brief Checks for positive and negative infinity arg.
  1403. */
  1404. static int
  1405. scalbn_infCases(void *args)
  1406. {
  1407. double result;
  1408. result = SDL_scalbn(INFINITY, 1);
  1409. SDLTest_AssertCheck(INFINITY == result,
  1410. "Scalbn(%f,%d), expected %f, got %f",
  1411. INFINITY, 1, INFINITY, result);
  1412. result = SDL_scalbn(-INFINITY, 1);
  1413. SDLTest_AssertCheck(-INFINITY == result,
  1414. "Scalbn(%f,%d), expected %f, got %f",
  1415. -INFINITY, 1, -INFINITY, result);
  1416. return TEST_COMPLETED;
  1417. }
  1418. /**
  1419. * \brief Checks for positive and negative zero arg.
  1420. */
  1421. static int
  1422. scalbn_baseZeroCases(void *args)
  1423. {
  1424. double result;
  1425. result = SDL_scalbn(0.0, 1);
  1426. SDLTest_AssertCheck(0.0 == result,
  1427. "Scalbn(%f,%d), expected %f, got %f",
  1428. 0.0, 1, 0.0, result);
  1429. result = SDL_scalbn(-0.0, 1);
  1430. SDLTest_AssertCheck(-0.0 == result,
  1431. "Scalbn(%f,%d), expected %f, got %f",
  1432. -0.0, 1, -0.0, result);
  1433. return TEST_COMPLETED;
  1434. }
  1435. /**
  1436. * \brief Checks for zero exp.
  1437. */
  1438. static int
  1439. scalbn_expZeroCase(void *args)
  1440. {
  1441. const double result = SDL_scalbn(42.0, 0);
  1442. SDLTest_AssertCheck(42.0 == result,
  1443. "Scalbn(%f,%d), expected %f, got %f",
  1444. 42.0, 0, 42.0, result);
  1445. return TEST_COMPLETED;
  1446. }
  1447. /**
  1448. * \brief Checks for NAN arg.
  1449. */
  1450. static int
  1451. scalbn_nanCase(void *args)
  1452. {
  1453. const double result = SDL_scalbn(NAN, 2);
  1454. SDLTest_AssertCheck(isnan(result),
  1455. "Scalbn(%f,%d), expected %f, got %f",
  1456. NAN, 2, NAN, result);
  1457. return TEST_COMPLETED;
  1458. }
  1459. /**
  1460. * \brief Checks a set of regular values.
  1461. *
  1462. * This test depends on SDL_pow functionning.
  1463. */
  1464. static int
  1465. scalbn_regularCases(void *args)
  1466. {
  1467. double result, expected;
  1468. result = SDL_scalbn(2.0, 2);
  1469. expected = 2.0 * SDL_pow(FLT_RADIX, 2);
  1470. SDLTest_AssertCheck(result == expected,
  1471. "Scalbn(%f,%d), expected %f, got %f",
  1472. 2.0, 2, expected, result);
  1473. result = SDL_scalbn(1.0, 13);
  1474. expected = 1.0 * SDL_pow(FLT_RADIX, 13);
  1475. SDLTest_AssertCheck(result == expected,
  1476. "Scalbn(%f,%d), expected %f, got %f",
  1477. 1.0, 13, expected, result);
  1478. result = SDL_scalbn(2.0, -5);
  1479. expected = 2.0 * SDL_pow(FLT_RADIX, -5);
  1480. SDLTest_AssertCheck(result == expected,
  1481. "Scalbn(%f,%d), expected %f, got %f",
  1482. 2.0, -5, expected, result);
  1483. result = SDL_scalbn(-1.0, -13);
  1484. expected = -1.0 * SDL_pow(FLT_RADIX, -13);
  1485. SDLTest_AssertCheck(result == expected,
  1486. "Scalbn(%f,%d), expected %f, got %f",
  1487. -1.0, -13, expected, result);
  1488. return TEST_COMPLETED;
  1489. }
  1490. /* SDL_cos tests functions */
  1491. /**
  1492. * \brief Checks positive and negative infinity.
  1493. */
  1494. static int
  1495. cos_infCases(void *args)
  1496. {
  1497. double result;
  1498. result = SDL_cos(INFINITY);
  1499. SDLTest_AssertCheck(isnan(result),
  1500. "Cos(%f), expected %f, got %f",
  1501. INFINITY, NAN, result);
  1502. result = SDL_cos(-INFINITY);
  1503. SDLTest_AssertCheck(isnan(result),
  1504. "Cos(%f), expected %f, got %f",
  1505. -INFINITY, NAN, result);
  1506. return TEST_COMPLETED;
  1507. }
  1508. /**
  1509. * \brief Checks for nan.
  1510. */
  1511. static int
  1512. cos_nanCase(void *args)
  1513. {
  1514. const double result = SDL_cos(NAN);
  1515. SDLTest_AssertCheck(isnan(result),
  1516. "Cos(%f), expected %f, got %f",
  1517. NAN, NAN, result);
  1518. return TEST_COMPLETED;
  1519. }
  1520. /**
  1521. * \brief Checks a set of regular values.
  1522. */
  1523. static int
  1524. cos_regularCases(void *args)
  1525. {
  1526. const d_to_d regular_cases[] = {
  1527. { -M_PI, -1.0 },
  1528. { -0.0, 1.0 },
  1529. { 0.0, 1.0 },
  1530. { M_PI, -1.0 }
  1531. };
  1532. return helper_dtod("Cos", SDL_cos, regular_cases, SDL_arraysize(regular_cases));
  1533. }
  1534. /**
  1535. * \brief Checks cosine precision for the first 10 decimals.
  1536. *
  1537. * This function depends on SDL_floor functioning.
  1538. */
  1539. static int
  1540. cos_precisionTest(void *args)
  1541. {
  1542. Uint32 i;
  1543. Uint32 iterations = 20;
  1544. double angle = 0.0;
  1545. double step = 2.0 * M_PI / iterations;
  1546. const double expected[] = {
  1547. 10000000000.0, 9510565162.0, 8090169943.0, 5877852522.0, 3090169943.0,
  1548. 0.0, -3090169943.0, -5877852522.0, -8090169943.0, -9510565162.0,
  1549. -10000000000.0, -9510565162.0, -8090169943.0, -5877852522.0, -3090169943.0,
  1550. 0.0, 3090169943.0, 5877852522.0, 8090169943.0, 9510565162.0
  1551. };
  1552. for (i = 0; i < iterations; i++, angle += step) {
  1553. double result = SDL_cos(angle) * 1.0E10;
  1554. SDLTest_AssertCheck(SDL_trunc(result) == expected[i],
  1555. "Cos(%f), expected %f, got %f",
  1556. angle, expected[i], result);
  1557. }
  1558. return TEST_COMPLETED;
  1559. }
  1560. /**
  1561. * \brief Checks a range of values between 0 and UINT32_MAX.
  1562. */
  1563. static int
  1564. cos_rangeTest(void *args)
  1565. {
  1566. Uint32 i;
  1567. double test_value = 0.0;
  1568. SDLTest_AssertPass("Cos: Testing a range of %u values with steps of %u",
  1569. RANGE_TEST_ITERATIONS,
  1570. RANGE_TEST_STEP);
  1571. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  1572. double result;
  1573. /* These are tested elsewhere */
  1574. if (isnan(test_value) || isinf(test_value)) {
  1575. continue;
  1576. }
  1577. /* Only log failures to save performances */
  1578. result = SDL_cos(test_value);
  1579. if (result < -1.0 || result > 1.0) {
  1580. SDLTest_AssertCheck(SDL_FALSE,
  1581. "Cos(%.1f), expected [%.1f,%.1f], got %.1f",
  1582. test_value, -1.0, 1.0, result);
  1583. return TEST_ABORTED;
  1584. }
  1585. }
  1586. return TEST_COMPLETED;
  1587. }
  1588. /* SDL_sin tests functions */
  1589. /**
  1590. * \brief Checks positive and negative infinity.
  1591. */
  1592. static int
  1593. sin_infCases(void *args)
  1594. {
  1595. double result;
  1596. result = SDL_sin(INFINITY);
  1597. SDLTest_AssertCheck(isnan(result),
  1598. "Sin(%f), expected %f, got %f",
  1599. INFINITY, NAN, result);
  1600. result = SDL_sin(-INFINITY);
  1601. SDLTest_AssertCheck(isnan(result),
  1602. "Sin(%f), expected %f, got %f",
  1603. -INFINITY, NAN, result);
  1604. return TEST_COMPLETED;
  1605. }
  1606. /**
  1607. * \brief Checks for nan.
  1608. */
  1609. static int
  1610. sin_nanCase(void *args)
  1611. {
  1612. const double result = SDL_sin(NAN);
  1613. SDLTest_AssertCheck(isnan(result),
  1614. "Sin(%f), expected %f, got %f",
  1615. NAN, NAN, result);
  1616. return TEST_COMPLETED;
  1617. }
  1618. /**
  1619. * \brief Checks a set of regular values.
  1620. */
  1621. static int
  1622. sin_regularCases(void *args)
  1623. {
  1624. const d_to_d regular_cases[] = {
  1625. { -M_PI / 2, -1.0 },
  1626. { -0.0, -0.0 },
  1627. { 0.0, 0.0 },
  1628. { M_PI / 2, 1.0 }
  1629. };
  1630. return helper_dtod("Sin", SDL_sin, regular_cases, SDL_arraysize(regular_cases));
  1631. }
  1632. /**
  1633. * \brief Checks sine precision for the first 10 decimals.
  1634. */
  1635. static int
  1636. sin_precisionTest(void *args)
  1637. {
  1638. Uint32 i;
  1639. Uint32 iterations = 20;
  1640. double angle = 0.0;
  1641. double step = 2.0 * M_PI / iterations;
  1642. const double expected[] = {
  1643. 0, 3090169943, 5877852522, 8090169943, 9510565162,
  1644. 10000000000, 9510565162, 8090169943, 5877852522, 3090169943,
  1645. 0, -3090169943, -5877852522, -8090169943, -9510565162,
  1646. -10000000000, -9510565162, -8090169943, -5877852522, -3090169943
  1647. };
  1648. for (i = 0; i < iterations; i++, angle += step) {
  1649. double result = SDL_sin(angle) * 1.0E10;
  1650. SDLTest_AssertCheck(SDL_trunc(result) == expected[i],
  1651. "Sin(%f), expected %f, got %f",
  1652. angle, expected[i], result);
  1653. }
  1654. return TEST_COMPLETED;
  1655. }
  1656. /**
  1657. * \brief Checks a range of values between 0 and UINT32_MAX.
  1658. */
  1659. static int
  1660. sin_rangeTest(void *args)
  1661. {
  1662. Uint32 i;
  1663. double test_value = 0.0;
  1664. SDLTest_AssertPass("Sin: Testing a range of %u values with steps of %u",
  1665. RANGE_TEST_ITERATIONS,
  1666. RANGE_TEST_STEP);
  1667. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  1668. double result;
  1669. /* These are tested elsewhere */
  1670. if (isnan(test_value) || isinf(test_value)) {
  1671. continue;
  1672. }
  1673. /* Only log failures to save performances */
  1674. result = SDL_sin(test_value);
  1675. if (result < -1.0 || result > 1.0) {
  1676. SDLTest_AssertCheck(SDL_FALSE,
  1677. "Sin(%.1f), expected [%.1f,%.1f], got %.1f",
  1678. test_value, -1.0, 1.0, result);
  1679. return TEST_ABORTED;
  1680. }
  1681. }
  1682. return TEST_COMPLETED;
  1683. }
  1684. /* ================= Test References ================== */
  1685. /* SDL_floor test cases */
  1686. static const SDLTest_TestCaseReference floorTestInf = {
  1687. (SDLTest_TestCaseFp) floor_infCases, "floor_infCases",
  1688. "Check positive and negative infinity", TEST_ENABLED
  1689. };
  1690. static const SDLTest_TestCaseReference floorTestZero = {
  1691. (SDLTest_TestCaseFp) floor_zeroCases, "floor_zeroCases",
  1692. "Check positive and negative zero", TEST_ENABLED
  1693. };
  1694. static const SDLTest_TestCaseReference floorTestNan = {
  1695. (SDLTest_TestCaseFp) floor_nanCase, "floor_nanCase",
  1696. "Check the NaN special case", TEST_ENABLED
  1697. };
  1698. static const SDLTest_TestCaseReference floorTestRound = {
  1699. (SDLTest_TestCaseFp) floor_roundNumbersCases, "floor_roundNumberCases",
  1700. "Check a set of round numbers", TEST_ENABLED
  1701. };
  1702. static const SDLTest_TestCaseReference floorTestFraction = {
  1703. (SDLTest_TestCaseFp) floor_fractionCases, "floor_fractionCases",
  1704. "Check a set of fractions", TEST_ENABLED
  1705. };
  1706. static const SDLTest_TestCaseReference floorTestRange = {
  1707. (SDLTest_TestCaseFp) floor_rangeTest, "floor_rangeTest",
  1708. "Check a range of positive integer", TEST_ENABLED
  1709. };
  1710. /* SDL_ceil test cases */
  1711. static const SDLTest_TestCaseReference ceilTestInf = {
  1712. (SDLTest_TestCaseFp) ceil_infCases, "ceil_infCases",
  1713. "Check positive and negative infinity", TEST_ENABLED
  1714. };
  1715. static const SDLTest_TestCaseReference ceilTestZero = {
  1716. (SDLTest_TestCaseFp) ceil_zeroCases, "ceil_zeroCases",
  1717. "Check positive and negative zero", TEST_ENABLED
  1718. };
  1719. static const SDLTest_TestCaseReference ceilTestNan = {
  1720. (SDLTest_TestCaseFp) ceil_nanCase, "ceil_nanCase",
  1721. "Check the NaN special case", TEST_ENABLED
  1722. };
  1723. static const SDLTest_TestCaseReference ceilTestRound = {
  1724. (SDLTest_TestCaseFp) ceil_roundNumbersCases, "ceil_roundNumberCases",
  1725. "Check a set of round numbers", TEST_ENABLED
  1726. };
  1727. static const SDLTest_TestCaseReference ceilTestFraction = {
  1728. (SDLTest_TestCaseFp) ceil_fractionCases, "ceil_fractionCases",
  1729. "Check a set of fractions", TEST_ENABLED
  1730. };
  1731. static const SDLTest_TestCaseReference ceilTestRange = {
  1732. (SDLTest_TestCaseFp) ceil_rangeTest, "ceil_rangeTest",
  1733. "Check a range of positive integer", TEST_ENABLED
  1734. };
  1735. /* SDL_trunc test cases */
  1736. static const SDLTest_TestCaseReference truncTestInf = {
  1737. (SDLTest_TestCaseFp) trunc_infCases, "trunc_infCases",
  1738. "Check positive and negative infinity", TEST_ENABLED
  1739. };
  1740. static const SDLTest_TestCaseReference truncTestZero = {
  1741. (SDLTest_TestCaseFp) trunc_zeroCases, "trunc_zeroCases",
  1742. "Check positive and negative zero", TEST_ENABLED
  1743. };
  1744. static const SDLTest_TestCaseReference truncTestNan = {
  1745. (SDLTest_TestCaseFp) trunc_nanCase, "trunc_nanCase",
  1746. "Check the NaN special case", TEST_ENABLED
  1747. };
  1748. static const SDLTest_TestCaseReference truncTestRound = {
  1749. (SDLTest_TestCaseFp) trunc_roundNumbersCases, "trunc_roundNumberCases",
  1750. "Check a set of round numbers", TEST_ENABLED
  1751. };
  1752. static const SDLTest_TestCaseReference truncTestFraction = {
  1753. (SDLTest_TestCaseFp) trunc_fractionCases, "trunc_fractionCases",
  1754. "Check a set of fractions", TEST_ENABLED
  1755. };
  1756. static const SDLTest_TestCaseReference truncTestRange = {
  1757. (SDLTest_TestCaseFp) trunc_rangeTest, "trunc_rangeTest",
  1758. "Check a range of positive integer", TEST_ENABLED
  1759. };
  1760. /* SDL_round test cases */
  1761. static const SDLTest_TestCaseReference roundTestInf = {
  1762. (SDLTest_TestCaseFp) round_infCases, "round_infCases",
  1763. "Check positive and negative infinity", TEST_ENABLED
  1764. };
  1765. static const SDLTest_TestCaseReference roundTestZero = {
  1766. (SDLTest_TestCaseFp) round_zeroCases, "round_zeroCases",
  1767. "Check positive and negative zero", TEST_ENABLED
  1768. };
  1769. static const SDLTest_TestCaseReference roundTestNan = {
  1770. (SDLTest_TestCaseFp) round_nanCase, "round_nanCase",
  1771. "Check the NaN special case", TEST_ENABLED
  1772. };
  1773. static const SDLTest_TestCaseReference roundTestRound = {
  1774. (SDLTest_TestCaseFp) round_roundNumbersCases, "round_roundNumberCases",
  1775. "Check a set of round numbers", TEST_ENABLED
  1776. };
  1777. static const SDLTest_TestCaseReference roundTestFraction = {
  1778. (SDLTest_TestCaseFp) round_fractionCases, "round_fractionCases",
  1779. "Check a set of fractions", TEST_ENABLED
  1780. };
  1781. static const SDLTest_TestCaseReference roundTestRange = {
  1782. (SDLTest_TestCaseFp) round_rangeTest, "round_rangeTest",
  1783. "Check a range of positive integer", TEST_ENABLED
  1784. };
  1785. /* SDL_fabs test cases */
  1786. static const SDLTest_TestCaseReference fabsTestInf = {
  1787. (SDLTest_TestCaseFp) fabs_infCases, "fabs_infCases",
  1788. "Check positive and negative infinity", TEST_ENABLED
  1789. };
  1790. static const SDLTest_TestCaseReference fabsTestZero = {
  1791. (SDLTest_TestCaseFp) fabs_zeroCases, "fabs_zeroCases",
  1792. "Check positive and negative zero", TEST_ENABLED
  1793. };
  1794. static const SDLTest_TestCaseReference fabsTestNan = {
  1795. (SDLTest_TestCaseFp) fabs_nanCase, "fabs_nanCase",
  1796. "Check the NaN special case", TEST_ENABLED
  1797. };
  1798. static const SDLTest_TestCaseReference fabsTestRange = {
  1799. (SDLTest_TestCaseFp) fabs_rangeTest, "fabs_rangeTest",
  1800. "Check a range of positive integer", TEST_ENABLED
  1801. };
  1802. /* SDL_copysign test cases */
  1803. static const SDLTest_TestCaseReference copysignTestInf = {
  1804. (SDLTest_TestCaseFp) copysign_infCases, "copysign_infCases",
  1805. "Check positive and negative infinity", TEST_ENABLED
  1806. };
  1807. static const SDLTest_TestCaseReference copysignTestZero = {
  1808. (SDLTest_TestCaseFp) copysign_zeroCases, "copysign_zeroCases",
  1809. "Check positive and negative zero", TEST_ENABLED
  1810. };
  1811. static const SDLTest_TestCaseReference copysignTestNan = {
  1812. (SDLTest_TestCaseFp) copysign_nanCases, "copysign_nanCases",
  1813. "Check the NaN special cases", TEST_ENABLED
  1814. };
  1815. static const SDLTest_TestCaseReference copysignTestRange = {
  1816. (SDLTest_TestCaseFp) copysign_rangeTest, "copysign_rangeTest",
  1817. "Check a range of positive integer", TEST_ENABLED
  1818. };
  1819. /* SDL_fmod test cases */
  1820. static const SDLTest_TestCaseReference fmodTestDivOfInf = {
  1821. (SDLTest_TestCaseFp) fmod_divOfInfCases, "fmod_divOfInfCases",
  1822. "Check division of positive and negative infinity", TEST_ENABLED
  1823. };
  1824. static const SDLTest_TestCaseReference fmodTestDivByInf = {
  1825. (SDLTest_TestCaseFp) fmod_divByInfCases, "fmod_divByInfCases",
  1826. "Check division by positive and negative infinity", TEST_ENABLED
  1827. };
  1828. static const SDLTest_TestCaseReference fmodTestDivOfZero = {
  1829. (SDLTest_TestCaseFp) fmod_divOfZeroCases, "fmod_divOfZeroCases",
  1830. "Check division of positive and negative zero", TEST_ENABLED
  1831. };
  1832. static const SDLTest_TestCaseReference fmodTestDivByZero = {
  1833. (SDLTest_TestCaseFp) fmod_divByZeroCases, "fmod_divByZeroCases",
  1834. "Check division by positive and negative zero", TEST_ENABLED
  1835. };
  1836. static const SDLTest_TestCaseReference fmodTestNan = {
  1837. (SDLTest_TestCaseFp) fmod_nanCases, "fmod_nanCases",
  1838. "Check the NaN special cases", TEST_ENABLED
  1839. };
  1840. static const SDLTest_TestCaseReference fmodTestRegular = {
  1841. (SDLTest_TestCaseFp) fmod_regularCases, "fmod_regularCases",
  1842. "Check a set of regular values", TEST_ENABLED
  1843. };
  1844. static const SDLTest_TestCaseReference fmodTestRange = {
  1845. (SDLTest_TestCaseFp) fmod_rangeTest, "fmod_rangeTest",
  1846. "Check a range of positive integer", TEST_ENABLED
  1847. };
  1848. /* SDL_exp test cases */
  1849. static const SDLTest_TestCaseReference expTestInf = {
  1850. (SDLTest_TestCaseFp) exp_infCases, "exp_infCases",
  1851. "Check positive and negative infinity", TEST_ENABLED
  1852. };
  1853. static const SDLTest_TestCaseReference expTestZero = {
  1854. (SDLTest_TestCaseFp) exp_zeroCases, "exp_zeroCases",
  1855. "Check for positive and negative zero", TEST_ENABLED
  1856. };
  1857. static const SDLTest_TestCaseReference expTestOverflow = {
  1858. (SDLTest_TestCaseFp) exp_overflowCase, "exp_overflowCase",
  1859. "Check for overflow", TEST_ENABLED
  1860. };
  1861. static const SDLTest_TestCaseReference expTestBase = {
  1862. (SDLTest_TestCaseFp) exp_baseCase, "exp_baseCase",
  1863. "Check the base case of 1.0", TEST_ENABLED
  1864. };
  1865. static const SDLTest_TestCaseReference expTestRegular = {
  1866. (SDLTest_TestCaseFp) exp_regularCases, "exp_regularCases",
  1867. "Check a set of regular values", TEST_ENABLED
  1868. };
  1869. /* SDL_log test cases */
  1870. static const SDLTest_TestCaseReference logTestLimit = {
  1871. (SDLTest_TestCaseFp) log_limitCases, "log_limitCases",
  1872. "Check for limits", TEST_ENABLED
  1873. };
  1874. static const SDLTest_TestCaseReference logTestNan = {
  1875. (SDLTest_TestCaseFp) log_nanCases, "log_nanCases",
  1876. "Check for the nan cases", TEST_ENABLED
  1877. };
  1878. static const SDLTest_TestCaseReference logTestBase = {
  1879. (SDLTest_TestCaseFp) log_baseCases, "log_baseCases",
  1880. "Check for base cases", TEST_ENABLED
  1881. };
  1882. static const SDLTest_TestCaseReference logTestRegular = {
  1883. (SDLTest_TestCaseFp) log_regularCases, "log_regularCases",
  1884. "Check a set of regular values", TEST_ENABLED
  1885. };
  1886. /* SDL_log10 test cases */
  1887. static const SDLTest_TestCaseReference log10TestLimit = {
  1888. (SDLTest_TestCaseFp) log10_limitCases, "log10_limitCases",
  1889. "Check for limits", TEST_ENABLED
  1890. };
  1891. static const SDLTest_TestCaseReference log10TestNan = {
  1892. (SDLTest_TestCaseFp) log10_nanCases, "log10_nanCases",
  1893. "Check for the nan cases", TEST_ENABLED
  1894. };
  1895. static const SDLTest_TestCaseReference log10TestBase = {
  1896. (SDLTest_TestCaseFp) log10_baseCases, "log10_baseCases",
  1897. "Check for base cases", TEST_ENABLED
  1898. };
  1899. static const SDLTest_TestCaseReference log10TestRegular = {
  1900. (SDLTest_TestCaseFp) log10_regularCases, "log10_regularCases",
  1901. "Check a set of regular values", TEST_ENABLED
  1902. };
  1903. /* SDL_pow test cases */
  1904. static const SDLTest_TestCaseReference powTestExpInf1 = {
  1905. (SDLTest_TestCaseFp) pow_baseNOneExpInfCases, "pow_baseNOneExpInfCases",
  1906. "Check for pow(-1, +/-inf)", TEST_ENABLED
  1907. };
  1908. static const SDLTest_TestCaseReference powTestExpInf2 = {
  1909. (SDLTest_TestCaseFp) pow_baseZeroExpNInfCases, "pow_baseZeroExpNInfCases",
  1910. "Check for pow(+/-0, -inf)", TEST_ENABLED
  1911. };
  1912. static const SDLTest_TestCaseReference powTestExpInf3 = {
  1913. (SDLTest_TestCaseFp) pow_expInfCases, "pow_expInfCases",
  1914. "Check for pow(x, +/-inf)", TEST_ENABLED
  1915. };
  1916. static const SDLTest_TestCaseReference powTestBaseInf1 = {
  1917. (SDLTest_TestCaseFp) pow_basePInfCases, "pow_basePInfCases",
  1918. "Check for pow(inf, x)", TEST_ENABLED
  1919. };
  1920. static const SDLTest_TestCaseReference powTestBaseInf2 = {
  1921. (SDLTest_TestCaseFp) pow_baseNInfCases, "pow_baseNInfCases",
  1922. "Check for pow(-inf, x)", TEST_ENABLED
  1923. };
  1924. static const SDLTest_TestCaseReference powTestNan1 = {
  1925. (SDLTest_TestCaseFp) pow_badOperationCase, "pow_badOperationCase",
  1926. "Check for negative finite base and non-integer finite exponent", TEST_ENABLED
  1927. };
  1928. static const SDLTest_TestCaseReference powTestNan2 = {
  1929. (SDLTest_TestCaseFp) pow_base1ExpNanCase, "pow_base1ExpNanCase",
  1930. "Check for pow(1.0, nan)", TEST_ENABLED
  1931. };
  1932. static const SDLTest_TestCaseReference powTestNan3 = {
  1933. (SDLTest_TestCaseFp) pow_baseNanExp0Cases, "pow_baseNanExp0Cases",
  1934. "Check for pow(nan, +/-0)", TEST_ENABLED
  1935. };
  1936. static const SDLTest_TestCaseReference powTestNan4 = {
  1937. (SDLTest_TestCaseFp) pow_nanArgsCases, "pow_nanArgsCases",
  1938. "Check for pow(x, y) with either x or y being nan", TEST_ENABLED
  1939. };
  1940. static const SDLTest_TestCaseReference powTestZero1 = {
  1941. (SDLTest_TestCaseFp) pow_baseNZeroExpOddCases, "pow_baseNZeroExpOddCases",
  1942. "Check for pow(-0.0, y), with y an odd integer.", TEST_ENABLED
  1943. };
  1944. static const SDLTest_TestCaseReference powTestZero2 = {
  1945. (SDLTest_TestCaseFp) pow_basePZeroExpOddCases, "pow_basePZeroExpOddCases",
  1946. "Check for pow(0.0, y), with y an odd integer.", TEST_ENABLED
  1947. };
  1948. static const SDLTest_TestCaseReference powTestZero3 = {
  1949. (SDLTest_TestCaseFp) pow_baseNZeroCases, "pow_baseNZeroCases",
  1950. "Check for pow(-0.0, y), with y finite and even or non-integer number", TEST_ENABLED
  1951. };
  1952. static const SDLTest_TestCaseReference powTestZero4 = {
  1953. (SDLTest_TestCaseFp) pow_basePZeroCases, "pow_basePZeroCases",
  1954. "Check for pow(0.0, y), with y finite and even or non-integer number", TEST_ENABLED
  1955. };
  1956. static const SDLTest_TestCaseReference powTestRegular = {
  1957. (SDLTest_TestCaseFp) pow_regularCases, "pow_regularCases",
  1958. "Check a set of regular values", TEST_ENABLED
  1959. };
  1960. static const SDLTest_TestCaseReference powTestPowOf2 = {
  1961. (SDLTest_TestCaseFp) pow_powerOfTwo, "pow_powerOfTwo",
  1962. "Check the powers of two from 1 to 8", TEST_ENABLED
  1963. };
  1964. static const SDLTest_TestCaseReference powTestRange = {
  1965. (SDLTest_TestCaseFp) pow_rangeTest, "pow_rangeTest",
  1966. "Check a range of positive integer to the power of 0", TEST_ENABLED
  1967. };
  1968. /* SDL_sqrt test cases */
  1969. static const SDLTest_TestCaseReference sqrtTestInf = {
  1970. (SDLTest_TestCaseFp) sqrt_infCase, "sqrt_infCase",
  1971. "Check positive infinity", TEST_ENABLED
  1972. };
  1973. static const SDLTest_TestCaseReference sqrtTestNan = {
  1974. (SDLTest_TestCaseFp) sqrt_nanCase, "sqrt_nanCase",
  1975. "Check the NaN special case", TEST_ENABLED
  1976. };
  1977. static const SDLTest_TestCaseReference sqrtTestDomain = {
  1978. (SDLTest_TestCaseFp) sqrt_outOfDomainCases, "sqrt_outOfDomainCases",
  1979. "Check for out of domain values", TEST_ENABLED
  1980. };
  1981. static const SDLTest_TestCaseReference sqrtTestBase = {
  1982. (SDLTest_TestCaseFp) sqrt_baseCases, "sqrt_baseCases",
  1983. "Check the base cases", TEST_ENABLED
  1984. };
  1985. static const SDLTest_TestCaseReference sqrtTestRegular = {
  1986. (SDLTest_TestCaseFp) sqrt_regularCases, "sqrt_regularCases",
  1987. "Check a set of regular values", TEST_ENABLED
  1988. };
  1989. /* SDL_scalbn test cases */
  1990. static const SDLTest_TestCaseReference scalbnTestInf = {
  1991. (SDLTest_TestCaseFp) scalbn_infCases, "scalbn_infCases",
  1992. "Check positive and negative infinity arg", TEST_ENABLED
  1993. };
  1994. static const SDLTest_TestCaseReference scalbnTestBaseZero = {
  1995. (SDLTest_TestCaseFp) scalbn_baseZeroCases, "scalbn_baseZeroCases",
  1996. "Check for positive and negative zero arg", TEST_ENABLED
  1997. };
  1998. static const SDLTest_TestCaseReference scalbnTestExpZero = {
  1999. (SDLTest_TestCaseFp) scalbn_expZeroCase, "scalbn_expZeroCase",
  2000. "Check for zero exp", TEST_ENABLED
  2001. };
  2002. static const SDLTest_TestCaseReference scalbnTestNan = {
  2003. (SDLTest_TestCaseFp) scalbn_nanCase, "scalbn_nanCase",
  2004. "Check the NaN special case", TEST_ENABLED
  2005. };
  2006. static const SDLTest_TestCaseReference scalbnTestRegular = {
  2007. (SDLTest_TestCaseFp) scalbn_regularCases, "scalbn_regularCases",
  2008. "Check a set of regular cases", TEST_ENABLED
  2009. };
  2010. /* SDL_cos test cases */
  2011. static const SDLTest_TestCaseReference cosTestInf = {
  2012. (SDLTest_TestCaseFp) cos_infCases, "cos_infCases",
  2013. "Check for positive and negative infinity", TEST_ENABLED
  2014. };
  2015. static const SDLTest_TestCaseReference cosTestNan = {
  2016. (SDLTest_TestCaseFp) cos_nanCase, "cos_nanCase",
  2017. "Check the NaN special case", TEST_ENABLED
  2018. };
  2019. static const SDLTest_TestCaseReference cosTestRegular = {
  2020. (SDLTest_TestCaseFp) cos_regularCases, "cos_regularCases",
  2021. "Check a set of regular cases", TEST_ENABLED
  2022. };
  2023. static const SDLTest_TestCaseReference cosTestPrecision = {
  2024. (SDLTest_TestCaseFp) cos_precisionTest, "cos_precisionTest",
  2025. "Check cosine precision to the tenth decimal", TEST_ENABLED
  2026. };
  2027. static const SDLTest_TestCaseReference cosTestRange = {
  2028. (SDLTest_TestCaseFp) cos_rangeTest, "cos_rangeTest",
  2029. "Check a range of positive integer", TEST_ENABLED
  2030. };
  2031. /* SDL_sin test cases */
  2032. static const SDLTest_TestCaseReference sinTestInf = {
  2033. (SDLTest_TestCaseFp) sin_infCases, "sin_infCases",
  2034. "Check for positive and negative infinity", TEST_ENABLED
  2035. };
  2036. static const SDLTest_TestCaseReference sinTestNan = {
  2037. (SDLTest_TestCaseFp) sin_nanCase, "sin_nanCase",
  2038. "Check the NaN special case", TEST_ENABLED
  2039. };
  2040. static const SDLTest_TestCaseReference sinTestRegular = {
  2041. (SDLTest_TestCaseFp) sin_regularCases, "sin_regularCases",
  2042. "Check a set of regular cases", TEST_ENABLED
  2043. };
  2044. static const SDLTest_TestCaseReference sinTestPrecision = {
  2045. (SDLTest_TestCaseFp) sin_precisionTest, "sin_precisionTest",
  2046. "Check sine precision to the tenth decimal", TEST_ENABLED
  2047. };
  2048. static const SDLTest_TestCaseReference sinTestRange = {
  2049. (SDLTest_TestCaseFp) sin_rangeTest, "sin_rangeTest",
  2050. "Check a range of positive integer", TEST_ENABLED
  2051. };
  2052. static const SDLTest_TestCaseReference *mathTests[] = {
  2053. &floorTestInf, &floorTestZero, &floorTestNan,
  2054. &floorTestRound, &floorTestFraction, &floorTestRange,
  2055. &ceilTestInf, &ceilTestZero, &ceilTestNan,
  2056. &ceilTestRound, &ceilTestFraction, &ceilTestRange,
  2057. &truncTestInf, &truncTestZero, &truncTestNan,
  2058. &truncTestRound, &truncTestFraction, &truncTestRange,
  2059. &roundTestInf, &roundTestZero, &roundTestNan,
  2060. &roundTestRound, &roundTestFraction, &roundTestRange,
  2061. &fabsTestInf, &fabsTestZero, &fabsTestNan, &fabsTestRange,
  2062. &copysignTestInf, &copysignTestZero, &copysignTestNan, &copysignTestRange,
  2063. &fmodTestDivOfInf, &fmodTestDivByInf, &fmodTestDivOfZero, &fmodTestDivByZero,
  2064. &fmodTestNan, &fmodTestRegular, &fmodTestRange,
  2065. &expTestInf, &expTestZero, &expTestOverflow,
  2066. &expTestBase, &expTestRegular,
  2067. &logTestLimit, &logTestNan,
  2068. &logTestBase, &logTestRegular,
  2069. &log10TestLimit, &log10TestNan,
  2070. &log10TestBase, &log10TestRegular,
  2071. &powTestExpInf1, &powTestExpInf2, &powTestExpInf3,
  2072. &powTestBaseInf1, &powTestBaseInf2,
  2073. &powTestNan1, &powTestNan2, &powTestNan3, &powTestNan4,
  2074. &powTestZero1, &powTestZero2, &powTestZero3, &powTestZero4,
  2075. &powTestRegular, &powTestPowOf2, &powTestRange,
  2076. &sqrtTestInf, &sqrtTestNan, &sqrtTestDomain,
  2077. &sqrtTestBase, &sqrtTestRegular,
  2078. &scalbnTestInf, &scalbnTestBaseZero, &scalbnTestExpZero,
  2079. &scalbnTestNan, &scalbnTestRegular,
  2080. &cosTestInf, &cosTestNan, &cosTestRegular,
  2081. &cosTestPrecision, &cosTestRange,
  2082. &sinTestInf, &sinTestNan, &sinTestRegular,
  2083. &sinTestPrecision, &sinTestRange,
  2084. NULL
  2085. };
  2086. SDLTest_TestSuiteReference mathTestSuite = { "Math", NULL, mathTests, NULL };