testautomation_math.c 100 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449
  1. /**
  2. * Math test suite
  3. */
  4. #include <float.h>
  5. #include <math.h>
  6. #include <SDL3/SDL.h>
  7. #include <SDL3/SDL_test.h>
  8. #include "testautomation_suites.h"
  9. /* ================= Test Constants ================== */
  10. /* Range tests parameters */
  11. #define RANGE_TEST_ITERATIONS 10000000
  12. #define RANGE_TEST_STEP ((Uint32)(SDL_MAX_UINT32 / RANGE_TEST_ITERATIONS))
  13. /* Margin of error for imprecise tests */
  14. #define EPSILON 1.0E-10
  15. /* Euler constant (used in exp/log) */
  16. #ifndef M_E
  17. #define EULER 2.7182818284590450907955982984276488423347473144531250
  18. #else
  19. #define EULER M_E
  20. #endif
  21. #define IS_INFINITY(V) fpclassify(V) == FP_INFINITE
  22. /* Square root of 3 (used in atan2) */
  23. #define SQRT3 1.7320508075688771931766041234368458390235900878906250
  24. /* ================= Test Structs ================== */
  25. /**
  26. * Stores a single input and the expected result
  27. */
  28. typedef struct
  29. {
  30. double input;
  31. double expected;
  32. } d_to_d;
  33. /**
  34. * Stores a pair of inputs and the expected result
  35. */
  36. typedef struct
  37. {
  38. double x_input, y_input;
  39. double expected;
  40. } dd_to_d;
  41. /*
  42. NB: You cannot create an array of these structures containing INFINITY or NAN.
  43. On platforms such as OS/2, they are defined as 'extern const double' making them
  44. not compile-time constant.
  45. */
  46. /* ================= Test Helpers ================== */
  47. typedef double(SDLCALL *d_to_d_func)(double);
  48. typedef double(SDLCALL *dd_to_d_func)(double, double);
  49. /**
  50. * \brief Runs all the cases on a given function with a signature double -> double.
  51. * The result is expected to be exact.
  52. *
  53. * \param func_name a printable name for the tested function.
  54. * \param func the function to call.
  55. * \param cases an array of all the cases.
  56. * \param cases_size the size of the cases array.
  57. */
  58. static int
  59. helper_dtod(const char *func_name, d_to_d_func func,
  60. const d_to_d *cases, const size_t cases_size)
  61. {
  62. Uint32 i;
  63. for (i = 0; i < cases_size; i++) {
  64. const double result = func(cases[i].input);
  65. SDLTest_AssertCheck(result == cases[i].expected,
  66. "%s(%f), expected %f, got %f",
  67. func_name,
  68. cases[i].input,
  69. cases[i].expected, result);
  70. }
  71. return TEST_COMPLETED;
  72. }
  73. /**
  74. * \brief Runs all the cases on a given function with a signature double -> double.
  75. * Checks if the result between expected +/- EPSILON.
  76. *
  77. * \param func_name a printable name for the tested function.
  78. * \param func the function to call.
  79. * \param cases an array of all the cases.
  80. * \param cases_size the size of the cases array.
  81. */
  82. static int
  83. helper_dtod_inexact(const char *func_name, d_to_d_func func,
  84. const d_to_d *cases, const size_t cases_size)
  85. {
  86. Uint32 i;
  87. for (i = 0; i < cases_size; i++) {
  88. const double result = func(cases[i].input);
  89. SDLTest_AssertCheck(result >= cases[i].expected - EPSILON &&
  90. result <= cases[i].expected + EPSILON,
  91. "%s(%f), expected [%f,%f], got %f",
  92. func_name,
  93. cases[i].input,
  94. cases[i].expected - EPSILON,
  95. cases[i].expected + EPSILON,
  96. result);
  97. }
  98. return TEST_COMPLETED;
  99. }
  100. /**
  101. * \brief Runs all the cases on a given function with a signature
  102. * (double, double) -> double. The result is expected to be exact.
  103. *
  104. * \param func_name a printable name for the tested function.
  105. * \param func the function to call.
  106. * \param cases an array of all the cases.
  107. * \param cases_size the size of the cases array.
  108. */
  109. static int
  110. helper_ddtod(const char *func_name, dd_to_d_func func,
  111. const dd_to_d *cases, const size_t cases_size)
  112. {
  113. Uint32 i;
  114. for (i = 0; i < cases_size; i++) {
  115. const double result = func(cases[i].x_input, cases[i].y_input);
  116. SDLTest_AssertCheck(result == cases[i].expected,
  117. "%s(%f,%f), expected %f, got %f",
  118. func_name,
  119. cases[i].x_input, cases[i].y_input,
  120. cases[i].expected, result);
  121. }
  122. return TEST_COMPLETED;
  123. }
  124. /**
  125. * \brief Runs all the cases on a given function with a signature
  126. * (double, double) -> double. Checks if the result between expected +/- EPSILON.
  127. *
  128. * \param func_name a printable name for the tested function.
  129. * \param func the function to call.
  130. * \param cases an array of all the cases.
  131. * \param cases_size the size of the cases array.
  132. */
  133. static int
  134. helper_ddtod_inexact(const char *func_name, dd_to_d_func func,
  135. const dd_to_d *cases, const size_t cases_size)
  136. {
  137. Uint32 i;
  138. for (i = 0; i < cases_size; i++) {
  139. const double result = func(cases[i].x_input, cases[i].y_input);
  140. SDLTest_AssertCheck(result >= cases[i].expected - EPSILON &&
  141. result <= cases[i].expected + EPSILON,
  142. "%s(%f,%f), expected [%f,%f], got %f",
  143. func_name,
  144. cases[i].x_input, cases[i].y_input,
  145. cases[i].expected - EPSILON,
  146. cases[i].expected + EPSILON,
  147. result);
  148. }
  149. return TEST_COMPLETED;
  150. }
  151. /**
  152. * \brief Runs a range of values on a given function with a signature double -> double
  153. *
  154. * This function is only meant to test functions that returns the input value if it is
  155. * integral: f(x) -> x for x in N.
  156. *
  157. * \param func_name a printable name for the tested function.
  158. * \param func the function to call.
  159. */
  160. static int
  161. helper_range(const char *func_name, d_to_d_func func)
  162. {
  163. Uint32 i;
  164. double test_value = 0.0;
  165. SDLTest_AssertPass("%s: Testing a range of %u values with steps of %" SDL_PRIu32,
  166. func_name,
  167. RANGE_TEST_ITERATIONS,
  168. RANGE_TEST_STEP);
  169. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  170. double result;
  171. /* These are tested elsewhere */
  172. if (isnan(test_value) || isinf(test_value)) {
  173. continue;
  174. }
  175. result = func(test_value);
  176. if (result != test_value) { /* Only log failures to save performances */
  177. SDLTest_AssertCheck(SDL_FALSE,
  178. "%s(%.1f), expected %.1f, got %.1f",
  179. func_name, test_value,
  180. test_value, result);
  181. return TEST_ABORTED;
  182. }
  183. }
  184. return TEST_COMPLETED;
  185. }
  186. /* ================= Test Case Implementation ================== */
  187. /* SDL_floor tests functions */
  188. /**
  189. * Inputs: +/-Infinity.
  190. * Expected: Infinity is returned as-is.
  191. */
  192. static int
  193. floor_infCases(void *args)
  194. {
  195. double result;
  196. result = SDL_floor(INFINITY);
  197. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  198. "Floor(%f), expected %f, got %f",
  199. INFINITY, INFINITY, result);
  200. result = SDL_floor(-INFINITY);
  201. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  202. "Floor(%f), expected %f, got %f",
  203. -INFINITY, -INFINITY, result);
  204. return TEST_COMPLETED;
  205. }
  206. /**
  207. * Inputs: +/-0.0.
  208. * Expected: Zero is returned as-is.
  209. */
  210. static int
  211. floor_zeroCases(void *args)
  212. {
  213. const d_to_d zero_cases[] = {
  214. { 0.0, 0.0 },
  215. { -0.0, -0.0 }
  216. };
  217. return helper_dtod("Floor", SDL_floor, zero_cases, SDL_arraysize(zero_cases));
  218. }
  219. /**
  220. * Input: NAN.
  221. * Expected: NAN is returned.
  222. */
  223. static int
  224. floor_nanCase(void *args)
  225. {
  226. const double result = SDL_floor(NAN);
  227. SDLTest_AssertCheck(isnan(result),
  228. "Floor(nan), expected nan, got %f",
  229. result);
  230. return TEST_COMPLETED;
  231. }
  232. /**
  233. * Inputs: integral values.
  234. * Expected: the input value is returned as-is.
  235. */
  236. static int
  237. floor_roundNumbersCases(void *args)
  238. {
  239. const d_to_d round_cases[] = {
  240. { 1.0, 1.0 },
  241. { -1.0, -1.0 },
  242. { 15.0, 15.0 },
  243. { -15.0, -15.0 },
  244. { 125.0, 125.0 },
  245. { -125.0, -125.0 },
  246. { 1024.0, 1024.0 },
  247. { -1024.0, -1024.0 }
  248. };
  249. return helper_dtod("Floor", SDL_floor, round_cases, SDL_arraysize(round_cases));
  250. }
  251. /**
  252. * Inputs: fractional values.
  253. * Expected: the lower integral value is returned.
  254. */
  255. static int
  256. floor_fractionCases(void *args)
  257. {
  258. const d_to_d frac_cases[] = {
  259. { 1.0 / 2.0, 0.0 },
  260. { -1.0 / 2.0, -1.0 },
  261. { 4.0 / 3.0, 1.0 },
  262. { -4.0 / 3.0, -2.0 },
  263. { 76.0 / 7.0, 10.0 },
  264. { -76.0 / 7.0, -11.0 },
  265. { 535.0 / 8.0, 66.0 },
  266. { -535.0 / 8.0, -67.0 },
  267. { 19357.0 / 53.0, 365.0 },
  268. { -19357.0 / 53.0, -366.0 }
  269. };
  270. return helper_dtod("Floor", SDL_floor, frac_cases, SDL_arraysize(frac_cases));
  271. }
  272. /**
  273. * Inputs: values in the range [0, UINT32_MAX].
  274. * Expected: the input value is returned as-is.
  275. */
  276. static int
  277. floor_rangeTest(void *args)
  278. {
  279. return helper_range("Floor", SDL_floor);
  280. }
  281. /* SDL_ceil tests functions */
  282. /**
  283. * Inputs: +/-Infinity.
  284. * Expected: Infinity is returned as-is.
  285. */
  286. static int
  287. ceil_infCases(void *args)
  288. {
  289. double result;
  290. result = SDL_ceil(INFINITY);
  291. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  292. "Ceil(%f), expected %f, got %f",
  293. INFINITY, INFINITY, result);
  294. result = SDL_ceil(-INFINITY);
  295. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  296. "Ceil(%f), expected %f, got %f",
  297. -INFINITY, -INFINITY, result);
  298. return TEST_COMPLETED;
  299. }
  300. /**
  301. * Inputs: +/-0.0.
  302. * Expected: Zero is returned as-is.
  303. */
  304. static int
  305. ceil_zeroCases(void *args)
  306. {
  307. const d_to_d zero_cases[] = {
  308. { 0.0, 0.0 },
  309. { -0.0, -0.0 }
  310. };
  311. return helper_dtod("Ceil", SDL_ceil, zero_cases, SDL_arraysize(zero_cases));
  312. }
  313. /**
  314. * Input: NAN.
  315. * Expected: NAN is returned.
  316. */
  317. static int
  318. ceil_nanCase(void *args)
  319. {
  320. const double result = SDL_ceil(NAN);
  321. SDLTest_AssertCheck(isnan(result),
  322. "Ceil(nan), expected nan, got %f",
  323. result);
  324. return TEST_COMPLETED;
  325. }
  326. /**
  327. * Inputs: integral values.
  328. * Expected: the input value is returned as-is.
  329. */
  330. static int
  331. ceil_roundNumbersCases(void *args)
  332. {
  333. const d_to_d round_cases[] = {
  334. { 1.0, 1.0 },
  335. { -1.0, -1.0 },
  336. { 15.0, 15.0 },
  337. { -15.0, -15.0 },
  338. { 125.0, 125.0 },
  339. { -125.0, -125.0 },
  340. { 1024.0, 1024.0 },
  341. { -1024.0, -1024.0 }
  342. };
  343. return helper_dtod("Ceil", SDL_ceil, round_cases, SDL_arraysize(round_cases));
  344. }
  345. /**
  346. * Inputs: fractional values.
  347. * Expected: the higher integral value is returned.
  348. */
  349. static int
  350. ceil_fractionCases(void *args)
  351. {
  352. const d_to_d frac_cases[] = {
  353. { 1.0 / 2.0, 1.0 },
  354. { -1.0 / 2.0, -0.0 },
  355. { 4.0 / 3.0, 2.0 },
  356. { -4.0 / 3.0, -1.0 },
  357. { 76.0 / 7.0, 11.0 },
  358. { -76.0 / 7.0, -10.0 },
  359. { 535.0 / 8.0, 67.0 },
  360. { -535.0 / 8.0, -66.0 },
  361. { 19357.0 / 53.0, 366.0 },
  362. { -19357.0 / 53.0, -365.0 }
  363. };
  364. return helper_dtod("Ceil", SDL_ceil, frac_cases, SDL_arraysize(frac_cases));
  365. }
  366. /**
  367. * Inputs: values in the range [0, UINT32_MAX].
  368. * Expected: the input value is returned as-is.
  369. */
  370. static int
  371. ceil_rangeTest(void *args)
  372. {
  373. return helper_range("Ceil", SDL_ceil);
  374. }
  375. /* SDL_trunc tests functions */
  376. /**
  377. * Inputs: +/-Infinity.
  378. * Expected: Infinity is returned as-is.
  379. */
  380. static int
  381. trunc_infCases(void *args)
  382. {
  383. double result;
  384. result = SDL_trunc(INFINITY);
  385. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  386. "Trunc(%f), expected %f, got %f",
  387. INFINITY, INFINITY, result);
  388. result = SDL_trunc(-INFINITY);
  389. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  390. "Trunc(%f), expected %f, got %f",
  391. -INFINITY, -INFINITY, result);
  392. return TEST_COMPLETED;
  393. }
  394. /**
  395. * Inputs: +/-0.0.
  396. * Expected: Zero is returned as-is.
  397. */
  398. static int
  399. trunc_zeroCases(void *args)
  400. {
  401. const d_to_d zero_cases[] = {
  402. { 0.0, 0.0 },
  403. { -0.0, -0.0 }
  404. };
  405. return helper_dtod("Trunc", SDL_trunc, zero_cases, SDL_arraysize(zero_cases));
  406. }
  407. /**
  408. * Input: NAN.
  409. * Expected: NAN is returned.
  410. */
  411. static int
  412. trunc_nanCase(void *args)
  413. {
  414. const double result = SDL_trunc(NAN);
  415. SDLTest_AssertCheck(isnan(result),
  416. "Trunc(nan), expected nan, got %f",
  417. result);
  418. return TEST_COMPLETED;
  419. }
  420. /**
  421. * Inputs: integral values.
  422. * Expected: the input value is returned as-is.
  423. */
  424. static int
  425. trunc_roundNumbersCases(void *args)
  426. {
  427. const d_to_d round_cases[] = {
  428. { 1.0, 1.0 },
  429. { -1.0, -1.0 },
  430. { 15.0, 15.0 },
  431. { -15.0, -15.0 },
  432. { 125.0, 125.0 },
  433. { -125.0, -125.0 },
  434. { 1024.0, 1024.0 },
  435. { -1024.0, -1024.0 }
  436. };
  437. return helper_dtod("Trunc", SDL_trunc, round_cases, SDL_arraysize(round_cases));
  438. }
  439. /**
  440. * Inputs: fractional values.
  441. * Expected: the integral part is returned.
  442. */
  443. static int
  444. trunc_fractionCases(void *args)
  445. {
  446. const d_to_d frac_cases[] = {
  447. { 1.0 / 2.0, 0.0 },
  448. { -1.0 / 2.0, -0.0 },
  449. { 4.0 / 3.0, 1.0 },
  450. { -4.0 / 3.0, -1.0 },
  451. { 76.0 / 7.0, 10.0 },
  452. { -76.0 / 7.0, -10.0 },
  453. { 535.0 / 8.0, 66.0 },
  454. { -535.0 / 8.0, -66.0 },
  455. { 19357.0 / 53.0, 365.0 },
  456. { -19357.0 / 53.0, -365.0 }
  457. };
  458. return helper_dtod("Trunc", SDL_trunc, frac_cases, SDL_arraysize(frac_cases));
  459. }
  460. /**
  461. * Inputs: values in the range [0, UINT32_MAX].
  462. * Expected: the input value is returned as-is.
  463. */
  464. static int
  465. trunc_rangeTest(void *args)
  466. {
  467. return helper_range("Trunc", SDL_trunc);
  468. }
  469. /* SDL_round tests functions */
  470. /**
  471. * Inputs: +/-Infinity.
  472. * Expected: Infinity is returned as-is.
  473. */
  474. static int
  475. round_infCases(void *args)
  476. {
  477. double result;
  478. result = SDL_round(INFINITY);
  479. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  480. "Round(%f), expected %f, got %f",
  481. INFINITY, INFINITY, result);
  482. result = SDL_round(-INFINITY);
  483. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  484. "Round(%f), expected %f, got %f",
  485. -INFINITY, -INFINITY, result);
  486. return TEST_COMPLETED;
  487. }
  488. /**
  489. * Inputs: +/-0.0.
  490. * Expected: Zero is returned as-is.
  491. */
  492. static int
  493. round_zeroCases(void *args)
  494. {
  495. const d_to_d zero_cases[] = {
  496. { 0.0, 0.0 },
  497. { -0.0, -0.0 }
  498. };
  499. return helper_dtod("Round", SDL_round, zero_cases, SDL_arraysize(zero_cases));
  500. }
  501. /**
  502. * Input: NAN.
  503. * Expected: NAN is returned.
  504. */
  505. static int
  506. round_nanCase(void *args)
  507. {
  508. const double result = SDL_round(NAN);
  509. SDLTest_AssertCheck(isnan(result),
  510. "Round(nan), expected nan, got %f",
  511. result);
  512. return TEST_COMPLETED;
  513. }
  514. /**
  515. * Inputs: integral values.
  516. * Expected: the input value is returned as-is.
  517. */
  518. static int
  519. round_roundNumbersCases(void *args)
  520. {
  521. const d_to_d round_cases[] = {
  522. { 1.0, 1.0 },
  523. { -1.0, -1.0 },
  524. { 15.0, 15.0 },
  525. { -15.0, -15.0 },
  526. { 125.0, 125.0 },
  527. { -125.0, -125.0 },
  528. { 1024.0, 1024.0 },
  529. { -1024.0, -1024.0 }
  530. };
  531. return helper_dtod("Round", SDL_round, round_cases, SDL_arraysize(round_cases));
  532. }
  533. /**
  534. * Inputs: fractional values.
  535. * Expected: the nearest integral value is returned.
  536. */
  537. static int
  538. round_fractionCases(void *args)
  539. {
  540. const d_to_d frac_cases[] = {
  541. { 1.0 / 2.0, 1.0 },
  542. { -1.0 / 2.0, -1.0 },
  543. { 4.0 / 3.0, 1.0 },
  544. { -4.0 / 3.0, -1.0 },
  545. { 76.0 / 7.0, 11.0 },
  546. { -76.0 / 7.0, -11.0 },
  547. { 535.0 / 8.0, 67.0 },
  548. { -535.0 / 8.0, -67.0 },
  549. { 19357.0 / 53.0, 365.0 },
  550. { -19357.0 / 53.0, -365.0 }
  551. };
  552. return helper_dtod("Round", SDL_round, frac_cases, SDL_arraysize(frac_cases));
  553. }
  554. /**
  555. * Inputs: values in the range [0, UINT32_MAX].
  556. * Expected: the input value is returned as-is.
  557. */
  558. static int
  559. round_rangeTest(void *args)
  560. {
  561. return helper_range("Round", SDL_round);
  562. }
  563. /* SDL_fabs tests functions */
  564. /**
  565. * Inputs: +/-Infinity.
  566. * Expected: Positive Infinity is returned.
  567. */
  568. static int
  569. fabs_infCases(void *args)
  570. {
  571. double result;
  572. result = SDL_fabs(INFINITY);
  573. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  574. "Fabs(%f), expected %f, got %f",
  575. INFINITY, INFINITY, result);
  576. result = SDL_fabs(-INFINITY);
  577. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  578. "Fabs(%f), expected %f, got %f",
  579. -INFINITY, INFINITY, result);
  580. return TEST_COMPLETED;
  581. }
  582. /**
  583. * Inputs: +/-0.0.
  584. * Expected: Positive zero is returned.
  585. */
  586. static int
  587. fabs_zeroCases(void *args)
  588. {
  589. const d_to_d zero_cases[] = {
  590. { 0.0, 0.0 },
  591. { -0.0, 0.0 }
  592. };
  593. return helper_dtod("Fabs", SDL_fabs, zero_cases, SDL_arraysize(zero_cases));
  594. }
  595. /**
  596. * Input: NAN.
  597. * Expected: NAN is returned.
  598. */
  599. static int
  600. fabs_nanCase(void *args)
  601. {
  602. const double result = SDL_fabs(NAN);
  603. SDLTest_AssertCheck(isnan(result),
  604. "Fabs(nan), expected nan, got %f",
  605. result);
  606. return TEST_COMPLETED;
  607. }
  608. /**
  609. * Inputs: values in the range [0, UINT32_MAX].
  610. * Expected: the input value is returned as-is.
  611. */
  612. static int
  613. fabs_rangeTest(void *args)
  614. {
  615. return helper_range("Fabs", SDL_fabs);
  616. }
  617. /* SDL_copysign tests functions */
  618. /**
  619. * Inputs: (+/-Infinity, +/-1.0).
  620. * Expected: Infinity with the sign of 1.0 is returned.
  621. */
  622. static int
  623. copysign_infCases(void *args)
  624. {
  625. double result;
  626. result = SDL_copysign(INFINITY, -1.0);
  627. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  628. "Copysign(%f,%.1f), expected %f, got %f",
  629. INFINITY, -1.0, -INFINITY, result);
  630. result = SDL_copysign(INFINITY, 1.0);
  631. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  632. "Copysign(%f,%.1f), expected %f, got %f",
  633. INFINITY, 1.0, INFINITY, result);
  634. result = SDL_copysign(-INFINITY, -1.0);
  635. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  636. "Copysign(%f,%.1f), expected %f, got %f",
  637. -INFINITY, -1.0, -INFINITY, result);
  638. result = SDL_copysign(-INFINITY, 1.0);
  639. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  640. "Copysign(%f,%.1f), expected %f, got %f",
  641. -INFINITY, 1.0, INFINITY, result);
  642. return TEST_COMPLETED;
  643. }
  644. /**
  645. * Inputs: (+/-0.0, +/-1.0).
  646. * Expected: 0.0 with the sign of 1.0 is returned.
  647. */
  648. static int
  649. copysign_zeroCases(void *args)
  650. {
  651. const dd_to_d zero_cases[] = {
  652. { 0.0, 1.0, 0.0 },
  653. { 0.0, -1.0, -0.0 },
  654. { -0.0, 1.0, 0.0 },
  655. { -0.0, -1.0, -0.0 }
  656. };
  657. return helper_ddtod("Copysign", SDL_copysign, zero_cases, SDL_arraysize(zero_cases));
  658. }
  659. /**
  660. * Inputs: (NAN, +/-1.0).
  661. * Expected: NAN with the sign of 1.0 is returned.
  662. * NOTE: On some platforms signed NAN is not supported, so we only check if the result is still NAN.
  663. */
  664. static int
  665. copysign_nanCases(void *args)
  666. {
  667. double result;
  668. result = SDL_copysign(NAN, 1.0);
  669. SDLTest_AssertCheck(isnan(result),
  670. "Copysign(nan,1.0), expected nan, got %f",
  671. result);
  672. result = SDL_copysign(NAN, -1.0);
  673. SDLTest_AssertCheck(isnan(result),
  674. "Copysign(nan,-1.0), expected nan, got %f",
  675. result);
  676. return TEST_COMPLETED;
  677. }
  678. /**
  679. * Inputs: values in the range [0, UINT32_MAX], +/-1.0.
  680. * Expected: the input value with the sign of 1.0 is returned.
  681. */
  682. static int
  683. copysign_rangeTest(void *args)
  684. {
  685. Uint32 i;
  686. double test_value = 0.0;
  687. SDLTest_AssertPass("Copysign: Testing a range of %u values with steps of %" SDL_PRIu32,
  688. RANGE_TEST_ITERATIONS,
  689. RANGE_TEST_STEP);
  690. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  691. double result;
  692. /* These are tested elsewhere */
  693. if (isnan(test_value) || isinf(test_value)) {
  694. continue;
  695. }
  696. /* Only log failures to save performances */
  697. result = SDL_copysign(test_value, 1.0);
  698. if (result != test_value) {
  699. SDLTest_AssertCheck(SDL_FALSE,
  700. "Copysign(%.1f,%.1f), expected %.1f, got %.1f",
  701. test_value, 1.0, test_value, result);
  702. return TEST_ABORTED;
  703. }
  704. result = SDL_copysign(test_value, -1.0);
  705. if (result != -test_value) {
  706. SDLTest_AssertCheck(SDL_FALSE,
  707. "Copysign(%.1f,%.1f), expected %.1f, got %.1f",
  708. test_value, -1.0, -test_value, result);
  709. return TEST_ABORTED;
  710. }
  711. }
  712. return TEST_COMPLETED;
  713. }
  714. /* SDL_fmod tests functions */
  715. /**
  716. * Inputs: (+/-Infinity, +/-1.0).
  717. * Expected: NAN is returned.
  718. */
  719. static int
  720. fmod_divOfInfCases(void *args)
  721. {
  722. double result;
  723. result = SDL_fmod(INFINITY, -1.0);
  724. SDLTest_AssertCheck(isnan(result),
  725. "Fmod(%f,%.1f), expected %f, got %f",
  726. INFINITY, -1.0, NAN, result);
  727. result = SDL_fmod(INFINITY, 1.0);
  728. SDLTest_AssertCheck(isnan(result),
  729. "Fmod(%f,%.1f), expected %f, got %f",
  730. INFINITY, 1.0, NAN, result);
  731. result = SDL_fmod(-INFINITY, -1.0);
  732. SDLTest_AssertCheck(isnan(result),
  733. "Fmod(%f,%.1f), expected %f, got %f",
  734. -INFINITY, -1.0, NAN, result);
  735. result = SDL_fmod(-INFINITY, 1.0);
  736. SDLTest_AssertCheck(isnan(result),
  737. "Fmod(%f,%.1f), expected %f, got %f",
  738. -INFINITY, 1.0, NAN, result);
  739. return TEST_COMPLETED;
  740. }
  741. /**
  742. * Inputs: (+/-1.0, +/-Infinity).
  743. * Expected: 1.0 is returned as-is.
  744. */
  745. static int
  746. fmod_divByInfCases(void *args)
  747. {
  748. double result;
  749. result = SDL_fmod(1.0, INFINITY);
  750. SDLTest_AssertCheck(1.0 == result,
  751. "Fmod(%.1f,%f), expected %f, got %f",
  752. 1.0, INFINITY, 1.0, result);
  753. result = SDL_fmod(-1.0, INFINITY);
  754. SDLTest_AssertCheck(-1.0 == result,
  755. "Fmod(%.1f,%f), expected %f, got %f",
  756. -1.0, INFINITY, -1.0, result);
  757. result = SDL_fmod(1.0, -INFINITY);
  758. SDLTest_AssertCheck(1.0 == result,
  759. "Fmod(%.1f,%f), expected %f, got %f",
  760. 1.0, -INFINITY, 1.0, result);
  761. result = SDL_fmod(-1.0, -INFINITY);
  762. SDLTest_AssertCheck(-1.0 == result,
  763. "Fmod(%.1f,%f), expected %f, got %f",
  764. -1.0, -INFINITY, -1.0, result);
  765. return TEST_COMPLETED;
  766. }
  767. /**
  768. * Inputs: (+/-0.0, +/-1.0).
  769. * Expected: Zero is returned as-is.
  770. */
  771. static int
  772. fmod_divOfZeroCases(void *args)
  773. {
  774. const dd_to_d zero_cases[] = {
  775. { 0.0, 1.0, 0.0 },
  776. { 0.0, -1.0, 0.0 },
  777. { -0.0, 1.0, -0.0 },
  778. { -0.0, -1.0, -0.0 }
  779. };
  780. return helper_ddtod("Fmod", SDL_fmod, zero_cases, SDL_arraysize(zero_cases));
  781. }
  782. /**
  783. * Inputs: (+/-1.0, +/-0.0).
  784. * Expected: NAN is returned.
  785. */
  786. static int
  787. fmod_divByZeroCases(void *args)
  788. {
  789. double result;
  790. result = SDL_fmod(1.0, 0.0);
  791. SDLTest_AssertCheck(isnan(result),
  792. "Fmod(1.0,0.0), expected nan, got %f",
  793. result);
  794. result = SDL_fmod(-1.0, 0.0);
  795. SDLTest_AssertCheck(isnan(result),
  796. "Fmod(-1.0,0.0), expected nan, got %f",
  797. result);
  798. result = SDL_fmod(1.0, -0.0);
  799. SDLTest_AssertCheck(isnan(result),
  800. "Fmod(1.0,-0.0), expected nan, got %f",
  801. result);
  802. result = SDL_fmod(-1.0, -0.0);
  803. SDLTest_AssertCheck(isnan(result),
  804. "Fmod(-1.0,-0.0), expected nan, got %f",
  805. result);
  806. return TEST_COMPLETED;
  807. }
  808. /**
  809. * Inputs: all permutation of NAN and +/-1.0.
  810. * Expected: NAN is returned.
  811. */
  812. static int
  813. fmod_nanCases(void *args)
  814. {
  815. double result;
  816. result = SDL_fmod(NAN, 1.0);
  817. SDLTest_AssertCheck(isnan(result),
  818. "Fmod(nan,1.0), expected nan, got %f",
  819. result);
  820. result = SDL_fmod(NAN, -1.0);
  821. SDLTest_AssertCheck(isnan(result),
  822. "Fmod(nan,-1.0), expected nan, got %f",
  823. result);
  824. result = SDL_fmod(1.0, NAN);
  825. SDLTest_AssertCheck(isnan(result),
  826. "Fmod(1.0,nan), expected nan, got %f",
  827. result);
  828. result = SDL_fmod(-1.0, NAN);
  829. SDLTest_AssertCheck(isnan(result),
  830. "Fmod(-1.0,nan), expected nan, got %f",
  831. result);
  832. return TEST_COMPLETED;
  833. }
  834. /**
  835. * Inputs: values within the domain of the function.
  836. * Expected: the correct result is returned.
  837. */
  838. static int
  839. fmod_regularCases(void *args)
  840. {
  841. const dd_to_d regular_cases[] = {
  842. { 3.5, 2.0, 1.5 },
  843. { -6.25, 3.0, -0.25 },
  844. { 7.5, 2.5, 0.0 },
  845. { 2.0 / 3.0, -1.0 / 3.0, 0.0 }
  846. };
  847. return helper_ddtod("Fmod", SDL_fmod, regular_cases, SDL_arraysize(regular_cases));
  848. }
  849. /**
  850. * Inputs: values in the range [0, UINT32_MAX] divided by 1.0.
  851. * Expected: Positive zero is always returned.
  852. */
  853. static int
  854. fmod_rangeTest(void *args)
  855. {
  856. Uint32 i;
  857. double test_value = 0.0;
  858. SDLTest_AssertPass("Fmod: Testing a range of %u values with steps of %" SDL_PRIu32,
  859. RANGE_TEST_ITERATIONS,
  860. RANGE_TEST_STEP);
  861. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  862. double result;
  863. /* These are tested elsewhere */
  864. if (isnan(test_value) || isinf(test_value)) {
  865. continue;
  866. }
  867. /* Only log failures to save performances */
  868. result = SDL_fmod(test_value, 1.0);
  869. if (0.0 != result) {
  870. SDLTest_AssertCheck(SDL_FALSE,
  871. "Fmod(%.1f,%.1f), expected %.1f, got %.1f",
  872. test_value, 1.0, 0.0, result);
  873. return TEST_ABORTED;
  874. }
  875. }
  876. return TEST_COMPLETED;
  877. }
  878. /* SDL_exp tests functions */
  879. /**
  880. * Inputs: +/-Infinity.
  881. * Expected: Infinity is returned as-is.
  882. */
  883. static int
  884. exp_infCases(void *args)
  885. {
  886. double result;
  887. result = SDL_exp(INFINITY);
  888. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  889. "Exp(%f), expected %f, got %f",
  890. INFINITY, INFINITY, result);
  891. result = SDL_exp(-INFINITY);
  892. SDLTest_AssertCheck(0.0 == result,
  893. "Exp(%f), expected %f, got %f",
  894. -INFINITY, 0.0, result);
  895. return TEST_COMPLETED;
  896. }
  897. /**
  898. * Inputs: +/-0.0.
  899. * Expected: 1.0 is returned.
  900. */
  901. static int
  902. exp_zeroCases(void *args)
  903. {
  904. const d_to_d zero_cases[] = {
  905. { 0.0, 1.0 },
  906. { -0.0, 1.0 }
  907. };
  908. return helper_dtod("Exp", SDL_exp, zero_cases, SDL_arraysize(zero_cases));
  909. }
  910. /**
  911. * Input: 710.0 (overflows for 64bits double).
  912. * Expected: Infinity is returned.
  913. * NOTE: This test is skipped for double types larger than 64 bits.
  914. */
  915. static int
  916. exp_overflowCase(void *args)
  917. {
  918. double result;
  919. if (sizeof(double) > 8) {
  920. return TEST_SKIPPED;
  921. }
  922. result = SDL_exp(710.0);
  923. SDLTest_AssertCheck(isinf(result),
  924. "Exp(%f), expected %f, got %f",
  925. 710.0, INFINITY, result);
  926. return TEST_COMPLETED;
  927. }
  928. /**
  929. * Input: 1.0
  930. * Expected: The euler constant.
  931. */
  932. static int
  933. exp_baseCase(void *args)
  934. {
  935. const double result = SDL_exp(1.0);
  936. SDLTest_AssertCheck(result >= EULER - EPSILON &&
  937. result <= EULER + EPSILON,
  938. "Exp(%f), expected [%f,%f], got %f",
  939. 1.0, EULER - EPSILON, EULER + EPSILON, result);
  940. return TEST_COMPLETED;
  941. }
  942. /**
  943. * Inputs: values within the domain of the function.
  944. * Expected: the correct result is returned.
  945. */
  946. static int
  947. exp_regularCases(void *args)
  948. {
  949. /* Hexadecimal floating constants are not supported on C89 compilers */
  950. const d_to_d regular_cases[] = {
  951. { -101.0, 1.36853947117385291381565719268793547578002532127613087E-44 },
  952. { -15.73, 0.00000014741707833928422931856502906683425990763681 },
  953. { -1.0, 0.36787944117144233402427744294982403516769409179688 },
  954. { -0.5, 0.60653065971263342426311737654032185673713684082031 },
  955. { 0.5, 1.64872127070012819416433558217249810695648193359375 },
  956. { 2.25, 9.48773583635852624240669683786109089851379394531250 },
  957. { 34.125, 661148770968660.375 },
  958. { 112.89, 10653788283588960962604279261058893737879589093376.0 },
  959. { 539.483, 1970107755334319939701129934673541628417235942656909222826926175622435588279443011110464355295725187195188154768877850257012251677751742837992843520967922303961718983154427294786640886286983037548604937796221048661733679844353544028160.0 },
  960. };
  961. return helper_dtod("Exp", SDL_exp, regular_cases, SDL_arraysize(regular_cases));
  962. }
  963. /* SDL_log tests functions */
  964. /**
  965. * Inputs: Positive Infinity and +/-0.0.
  966. * Expected: Positive and negative Infinity respectively.
  967. */
  968. static int
  969. log_limitCases(void *args)
  970. {
  971. double result;
  972. result = SDL_log(INFINITY);
  973. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  974. "Log(%f), expected %f, got %f",
  975. INFINITY, INFINITY, result);
  976. result = SDL_log(0.0);
  977. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  978. "Log(%f), expected %f, got %f",
  979. 0.0, -INFINITY, result);
  980. result = SDL_log(-0.0);
  981. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  982. "Log(%f), expected %f, got %f",
  983. -0.0, -INFINITY, result);
  984. return TEST_COMPLETED;
  985. }
  986. /**
  987. * Inputs: 1.0 and the Euler constant.
  988. * Expected: 0.0 and 1.0 respectively.
  989. */
  990. static int
  991. log_baseCases(void *args)
  992. {
  993. double result;
  994. result = SDL_log(1.0);
  995. SDLTest_AssertCheck(0.0 == result,
  996. "Log(%f), expected %f, got %f",
  997. 1.0, 0.0, result);
  998. result = SDL_log(EULER);
  999. SDLTest_AssertCheck(1.0 == result,
  1000. "Log(%f), expected %f, got %f",
  1001. EULER, 1.0, result);
  1002. return TEST_COMPLETED;
  1003. }
  1004. /**
  1005. * Inputs: NAN and a negative value.
  1006. * Expected: NAN is returned.
  1007. */
  1008. static int
  1009. log_nanCases(void *args)
  1010. {
  1011. double result;
  1012. result = SDL_log(NAN);
  1013. SDLTest_AssertCheck(isnan(result),
  1014. "Log(%f), expected %f, got %f",
  1015. NAN, NAN, result);
  1016. result = SDL_log(-1234.5678);
  1017. SDLTest_AssertCheck(isnan(result),
  1018. "Log(%f), expected %f, got %f",
  1019. -1234.5678, NAN, result);
  1020. return TEST_COMPLETED;
  1021. }
  1022. /**
  1023. * Inputs: values within the domain of the function.
  1024. * Expected: the correct result is returned.
  1025. */
  1026. static int
  1027. log_regularCases(void *args)
  1028. {
  1029. const d_to_d regular_cases[] = {
  1030. { 5.0, 1.60943791243410028179994242236716672778129577636718750 },
  1031. { 10.0, 2.302585092994045901093613792909309267997741699218750 },
  1032. { 56.32, 4.031049711849786554296315443934872746467590332031250 },
  1033. { 789.123, 6.670922202231861497523368598194792866706848144531250 },
  1034. { 2734.876324, 7.91384149408957959792587644187733530998229980468750 }
  1035. };
  1036. return helper_dtod("Log", SDL_log, regular_cases, SDL_arraysize(regular_cases));
  1037. }
  1038. /* SDL_log10 tests functions */
  1039. /**
  1040. * Inputs: Positive Infinity and +/-0.0.
  1041. * Expected: Positive and negative Infinity respectively.
  1042. */
  1043. static int
  1044. log10_limitCases(void *args)
  1045. {
  1046. double result;
  1047. result = SDL_log10(INFINITY);
  1048. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1049. "Log10(%f), expected %f, got %f",
  1050. INFINITY, INFINITY, result);
  1051. result = SDL_log10(0.0);
  1052. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  1053. "Log10(%f), expected %f, got %f",
  1054. 0.0, -INFINITY, result);
  1055. result = SDL_log10(-0.0);
  1056. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  1057. "Log10(%f), expected %f, got %f",
  1058. -0.0, -INFINITY, result);
  1059. return TEST_COMPLETED;
  1060. }
  1061. /**
  1062. * Inputs: Powers of ten from 0 to 9.
  1063. * Expected: the exact power of ten is returned.
  1064. */
  1065. static int
  1066. log10_baseCases(void *args)
  1067. {
  1068. const d_to_d base_cases[] = {
  1069. { 1.0, 0.0 },
  1070. { 10.0, 1.0 },
  1071. { 100.0, 2.0 },
  1072. { 1000.0, 3.0 },
  1073. { 10000.0, 4.0 },
  1074. { 100000.0, 5.0 },
  1075. { 1000000.0, 6.0 },
  1076. { 10000000.0, 7.0 },
  1077. { 100000000.0, 8.0 },
  1078. { 1000000000.0, 9.0 },
  1079. };
  1080. return helper_dtod("Log10", SDL_log10, base_cases, SDL_arraysize(base_cases));
  1081. }
  1082. /**
  1083. * Inputs: NAN and a negative value.
  1084. * Expected: NAN is returned.
  1085. */
  1086. static int
  1087. log10_nanCases(void *args)
  1088. {
  1089. double result;
  1090. result = SDL_log10(NAN);
  1091. SDLTest_AssertCheck(isnan(result),
  1092. "Log10(%f), expected %f, got %f",
  1093. NAN, NAN, result);
  1094. result = SDL_log10(-1234.5678);
  1095. SDLTest_AssertCheck(isnan(result),
  1096. "Log10(%f), expected %f, got %f",
  1097. -1234.5678, NAN, result);
  1098. return TEST_COMPLETED;
  1099. }
  1100. /**
  1101. * Inputs: values within the domain of the function.
  1102. * Expected: the correct result is returned.
  1103. */
  1104. static int
  1105. log10_regularCases(void *args)
  1106. {
  1107. const d_to_d regular_cases[] = {
  1108. { 5.0, 0.698970004336018857493684208748163655400276184082031250 },
  1109. { 12.5, 1.09691001300805646145875016372883692383766174316406250 },
  1110. { 56.32, 1.750662646134055755453573510749265551567077636718750 },
  1111. { 789.123, 2.8971447016351858927407647570362314581871032714843750 },
  1112. { 2734.876324, 3.436937691540090433761633903486654162406921386718750 }
  1113. };
  1114. return helper_dtod_inexact("Log10", SDL_log10, regular_cases, SDL_arraysize(regular_cases));
  1115. }
  1116. /* SDL_modf tests functions */
  1117. static int
  1118. modf_baseCases(void *args)
  1119. {
  1120. double fractional, integral;
  1121. fractional = SDL_modf(1.25, &integral);
  1122. SDLTest_AssertCheck(integral == 1.0,
  1123. "modf(%f), expected integral %f, got %f",
  1124. 1.25, 1.0, integral);
  1125. SDLTest_AssertCheck(fractional == 0.25,
  1126. "modf(%f), expected fractional %f, got %f",
  1127. 1.25, 0.25, fractional);
  1128. return TEST_COMPLETED;
  1129. }
  1130. /* SDL_nextafter tests functions */
  1131. static int
  1132. nextafter_baseCases(void *args)
  1133. {
  1134. double value, expected;
  1135. value = SDL_nextafter(0.0, 1.0);
  1136. expected = 4.940656458412e-324;
  1137. SDLTest_AssertCheck(value == expected,
  1138. "nextafter(%f), expected %f, got %f",
  1139. 0.0, expected, value);
  1140. value = SDL_nextafter(1.0, 2.0);
  1141. expected = 1.0000000000000002;
  1142. SDLTest_AssertCheck(value == expected,
  1143. "nextafter(%f), expected %f, got %f",
  1144. 1.0, expected, value);
  1145. return TEST_COMPLETED;
  1146. }
  1147. /* SDL_nextafterf tests functions */
  1148. static int
  1149. nextafterf_baseCases(void *args)
  1150. {
  1151. float value, expected;
  1152. #if 0 /* Some compilers truncate this to zero */
  1153. value = SDL_nextafterf(0.0f, 1.0f);
  1154. expected = 1.401e-45f;
  1155. SDLTest_AssertCheck(value == expected,
  1156. "nextafterf(%f), expected %f, got %f",
  1157. 0.0, expected, value);
  1158. #endif
  1159. value = SDL_nextafterf(1.0f, 2.0f);
  1160. expected = 1.00000012f;
  1161. SDLTest_AssertCheck(value == expected,
  1162. "nextafterf(%f), expected %f, got %f",
  1163. 1.0, expected, value);
  1164. return TEST_COMPLETED;
  1165. }
  1166. /* SDL_pow tests functions */
  1167. /* Tests with positive and negative infinities as exponents */
  1168. /**
  1169. * Inputs: (-1.0, +/-Infinity).
  1170. * Expected: 1.0 is returned.
  1171. */
  1172. static int
  1173. pow_baseNOneExpInfCases(void *args)
  1174. {
  1175. double result;
  1176. result = SDL_pow(-1.0, INFINITY);
  1177. SDLTest_AssertCheck(1.0 == result,
  1178. "Pow(%f,%f), expected %f, got %f",
  1179. -1.0, INFINITY, 1.0, result);
  1180. result = SDL_pow(-1.0, -INFINITY);
  1181. SDLTest_AssertCheck(1.0 == result,
  1182. "Pow(%f,%f), expected %f, got %f",
  1183. -1.0, -INFINITY, 1.0, result);
  1184. return TEST_COMPLETED;
  1185. }
  1186. /**
  1187. * Inputs: (+/-0.0, -Infinity).
  1188. * Expected: Infinity is returned.
  1189. */
  1190. static int
  1191. pow_baseZeroExpNInfCases(void *args)
  1192. {
  1193. double result;
  1194. result = SDL_pow(0.0, -INFINITY);
  1195. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1196. "Pow(%f,%f), expected %f, got %f",
  1197. 0.0, -INFINITY, INFINITY, result);
  1198. result = SDL_pow(-0.0, -INFINITY);
  1199. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1200. "Pow(%f,%f), expected %f, got %f",
  1201. -0.0, -INFINITY, INFINITY, result);
  1202. return TEST_COMPLETED;
  1203. }
  1204. /**
  1205. * Inputs: (x, +/-Infinity) where x is not +/-0.0.
  1206. * Expected: 0.0 when x < 1, Infinity when x > 1.
  1207. */
  1208. static int
  1209. pow_expInfCases(void *args)
  1210. {
  1211. double result;
  1212. result = SDL_pow(0.5, INFINITY);
  1213. SDLTest_AssertCheck(0.0 == result,
  1214. "Pow(%f,%f), expected %f, got %f",
  1215. 0.5, INFINITY, 0.0, result);
  1216. result = SDL_pow(1.5, INFINITY);
  1217. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1218. "Pow(%f,%f), expected %f, got %f",
  1219. 1.5, INFINITY, INFINITY, result);
  1220. result = SDL_pow(0.5, -INFINITY);
  1221. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1222. "Pow(%f,%f), expected %f, got %f",
  1223. 0.5, INFINITY, INFINITY, result);
  1224. result = SDL_pow(1.5, -INFINITY);
  1225. SDLTest_AssertCheck(0.0 == result,
  1226. "Pow(%f,%f), expected %f, got %f",
  1227. 1.5, -INFINITY, 0.0, result);
  1228. return TEST_COMPLETED;
  1229. }
  1230. /* Tests with positive and negative infinities as base */
  1231. /**
  1232. * Inputs: (Positive Infinity, x) where x is not +/-0.0.
  1233. * Expected: 0.0 when x is < 0, positive Infinity when x > 0.
  1234. */
  1235. static int
  1236. pow_basePInfCases(void *args)
  1237. {
  1238. double result;
  1239. result = SDL_pow(INFINITY, -3.0);
  1240. SDLTest_AssertCheck(0.0 == result,
  1241. "Pow(%f,%f), expected %f, got %f",
  1242. INFINITY, -3.0, 0.0, result);
  1243. result = SDL_pow(INFINITY, 2.0);
  1244. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1245. "Pow(%f,%f), expected %f, got %f",
  1246. INFINITY, 2.0, INFINITY, result);
  1247. result = SDL_pow(INFINITY, -2.12345);
  1248. SDLTest_AssertCheck(0.0 == result,
  1249. "Pow(%f,%f), expected %f, got %f",
  1250. INFINITY, -2.12345, 0.0, result);
  1251. result = SDL_pow(INFINITY, 3.1345);
  1252. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1253. "Pow(%f,%f), expected %f, got %f",
  1254. INFINITY, 3.12345, INFINITY, result);
  1255. return TEST_COMPLETED;
  1256. }
  1257. /**
  1258. * Inputs: (Negative Infinity, x) where x is not +/-0.0.
  1259. * Expected:
  1260. * - -0.0 when x is a negative odd integer,
  1261. * - 0.0 when x is a negative even integer or negative non-integer,
  1262. * - Negative Infinity when x is a positive odd integer,
  1263. * - Positive Infinity when x is a positive even integer or positive non-integer.
  1264. */
  1265. static int
  1266. pow_baseNInfCases(void *args)
  1267. {
  1268. double result;
  1269. result = SDL_pow(-INFINITY, -3.0);
  1270. SDLTest_AssertCheck(-0.0 == result,
  1271. "Pow(%f,%f), expected %f, got %f",
  1272. -INFINITY, -3.0, -0.0, result);
  1273. result = SDL_pow(-INFINITY, -2.0);
  1274. SDLTest_AssertCheck(0.0 == result,
  1275. "Pow(%f,%f), expected %f, got %f",
  1276. -INFINITY, -2.0, 0.0, result);
  1277. result = SDL_pow(-INFINITY, -5.5);
  1278. SDLTest_AssertCheck(0.0 == result,
  1279. "Pow(%f,%f), expected %f, got %f",
  1280. -INFINITY, -5.5, 0.0, result);
  1281. result = SDL_pow(-INFINITY, 3.0);
  1282. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  1283. "Pow(%f,%f), expected %f, got %f",
  1284. -INFINITY, 3.0, -INFINITY, result);
  1285. result = SDL_pow(-INFINITY, 2.0);
  1286. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1287. "Pow(%f,%f), expected %f, got %f",
  1288. -INFINITY, 2.0, INFINITY, result);
  1289. result = SDL_pow(-INFINITY, 5.5);
  1290. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1291. "Pow(%f,%f), expected %f, got %f",
  1292. -INFINITY, 5.5, INFINITY, result);
  1293. return TEST_COMPLETED;
  1294. }
  1295. /* Tests related to NAN */
  1296. /**
  1297. * Inputs:
  1298. * - finite and negative base,
  1299. * - finite and non-integer exponent.
  1300. * Expected: NAN is returned.
  1301. */
  1302. static int
  1303. pow_badOperationCase(void *args)
  1304. {
  1305. const double result = SDL_pow(-2.0, 4.2);
  1306. SDLTest_AssertCheck(isnan(result),
  1307. "Pow(%f,%f), expected %f, got %f",
  1308. -2.0, 4.2, NAN, result);
  1309. return TEST_COMPLETED;
  1310. }
  1311. /**
  1312. * Inputs: (1.0, NAN)
  1313. * Expected: 1.0 is returned.
  1314. */
  1315. static int
  1316. pow_base1ExpNanCase(void *args)
  1317. {
  1318. const double result = SDL_pow(1.0, NAN);
  1319. SDLTest_AssertCheck(1.0 == result,
  1320. "Pow(%f,%f), expected %f, got %f",
  1321. 1.0, NAN, 1.0, result);
  1322. return TEST_COMPLETED;
  1323. }
  1324. /**
  1325. * Inputs: (NAN, +/-0.0)
  1326. * Expected: 1.0 is returned.
  1327. */
  1328. static int
  1329. pow_baseNanExp0Cases(void *args)
  1330. {
  1331. double result;
  1332. result = SDL_pow(NAN, 0.0);
  1333. SDLTest_AssertCheck(1.0 == result,
  1334. "Pow(%f,%f), expected %f, got %f",
  1335. NAN, 0.0, 1.0, result);
  1336. result = SDL_pow(NAN, -0.0);
  1337. SDLTest_AssertCheck(1.0 == result,
  1338. "Pow(%f,%f), expected %f, got %f",
  1339. NAN, -0.0, 1.0, result);
  1340. return TEST_COMPLETED;
  1341. }
  1342. /**
  1343. * Inputs: NAN as base, exponent or both.
  1344. * Expected: NAN is returned.
  1345. */
  1346. static int
  1347. pow_nanArgsCases(void *args)
  1348. {
  1349. double result;
  1350. result = SDL_pow(7.8, NAN);
  1351. SDLTest_AssertCheck(isnan(result),
  1352. "Pow(%f,%f), expected %f, got %f",
  1353. 7.8, NAN, NAN, result);
  1354. result = SDL_pow(NAN, 10.0);
  1355. SDLTest_AssertCheck(isnan(result),
  1356. "Pow(%f,%f), expected %f, got %f",
  1357. NAN, 10.0, NAN, result);
  1358. result = SDL_pow(NAN, NAN);
  1359. SDLTest_AssertCheck(isnan(result),
  1360. "Pow(%f,%f), expected %f, got %f",
  1361. NAN, NAN, NAN, result);
  1362. return TEST_COMPLETED;
  1363. }
  1364. /* Tests with positive and negative zeros as base */
  1365. /**
  1366. * Inputs: (-0.0, x) where x is an odd integer.
  1367. * Expected:
  1368. * - Negative Infinity with a negative exponent,
  1369. * - -0.0 with a positive exponent.
  1370. */
  1371. static int
  1372. pow_baseNZeroExpOddCases(void *args)
  1373. {
  1374. double result;
  1375. result = SDL_pow(-0.0, -3.0);
  1376. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  1377. "Pow(%f,%f), expected %f, got %f",
  1378. -0.0, -3.0, -INFINITY, result);
  1379. result = SDL_pow(-0.0, 3.0);
  1380. SDLTest_AssertCheck(-0.0 == result,
  1381. "Pow(%f,%f), expected %f, got %f",
  1382. -0.0, 3.0, -0.0, result);
  1383. return TEST_COMPLETED;
  1384. }
  1385. /**
  1386. * Inputs: (0.0, x) where x is an odd integer.
  1387. * Expected:
  1388. * - 0.0 with a positive exponent,
  1389. * - Positive Infinity with a negative exponent.
  1390. */
  1391. static int
  1392. pow_basePZeroExpOddCases(void *args)
  1393. {
  1394. double result;
  1395. result = SDL_pow(0.0, -5.0);
  1396. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1397. "Pow(%f,%f), expected %f, got %f",
  1398. 0.0, -5.0, INFINITY, result);
  1399. result = SDL_pow(0.0, 5.0);
  1400. SDLTest_AssertCheck(0.0 == result,
  1401. "Pow(%f,%f), expected %f, got %f",
  1402. 0.0, 5.0, 0.0, result);
  1403. return TEST_COMPLETED;
  1404. }
  1405. /**
  1406. * Inputs: (-0.0, x), with x either:
  1407. * - finite and even,
  1408. * - finite and non-integer.
  1409. * Expected:
  1410. * - Positive Infinity if the exponent is negative,
  1411. * - 0.0 if the exponent is positive.
  1412. */
  1413. static int
  1414. pow_baseNZeroCases(void *args)
  1415. {
  1416. double result;
  1417. result = SDL_pow(-0.0, -3.5);
  1418. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1419. "Pow(%f,%f), expected %f, got %f",
  1420. -0.0, -3.5, INFINITY, result);
  1421. result = SDL_pow(-0.0, -4.0);
  1422. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1423. "Pow(%f,%f), expected %f, got %f",
  1424. -0.0, -4.0, INFINITY, result);
  1425. result = SDL_pow(-0.0, 3.5);
  1426. SDLTest_AssertCheck(0.0 == result,
  1427. "Pow(%f,%f), expected %f, got %f",
  1428. -0.0, 3.5, 0.0, result);
  1429. result = SDL_pow(-0.0, 4.0);
  1430. SDLTest_AssertCheck(0.0 == result,
  1431. "Pow(%f,%f), expected %f, got %f",
  1432. -0.0, 4.0, 0.0, result);
  1433. return TEST_COMPLETED;
  1434. }
  1435. /**
  1436. * Inputs: (0.0, x), with x either:
  1437. * - finite and even,
  1438. * - finite and non-integer.
  1439. * Expected:
  1440. * - Positive Infinity if the exponent is negative,
  1441. * - 0.0 if the exponent is positive.
  1442. */
  1443. static int
  1444. pow_basePZeroCases(void *args)
  1445. {
  1446. double result;
  1447. result = SDL_pow(0.0, -3.5);
  1448. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1449. "Pow(%f,%f), expected %f, got %f",
  1450. 0.0, -3.5, INFINITY, result);
  1451. result = SDL_pow(0.0, -4.0);
  1452. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1453. "Pow(%f,%f), expected %f, got %f",
  1454. 0.0, -4.0, INFINITY, result);
  1455. result = SDL_pow(0.0, 3.5);
  1456. SDLTest_AssertCheck(0.0 == result,
  1457. "Pow(%f,%f), expected %f, got %f",
  1458. 0.0, 3.5, 0.0, result);
  1459. result = SDL_pow(0.0, 4.0);
  1460. SDLTest_AssertCheck(0.0 == result,
  1461. "Pow(%f,%f), expected %f, got %f",
  1462. 0.0, 4.0, 0.0, result);
  1463. return TEST_COMPLETED;
  1464. }
  1465. /* Remaining tests */
  1466. /**
  1467. * Inputs: values within the domain of the function.
  1468. * Expected: the correct result is returned.
  1469. */
  1470. static int
  1471. pow_regularCases(void *args)
  1472. {
  1473. const dd_to_d regular_cases[] = {
  1474. { -391.25, -2.0, 0.00000653267870448815438463212659780943170062528224661946296691894531250 },
  1475. { -72.3, 12.0, 20401381050275984310272.0 },
  1476. { -5.0, 3.0, -125.0 },
  1477. { 3.0, 2.5, 15.58845726811989607085706666111946105957031250 },
  1478. { 39.23, -1.5, 0.0040697950366865498147972424192175822099670767784118652343750 },
  1479. { 478.972, 12.125, 315326359630449587856007411793920.0 }
  1480. };
  1481. return helper_ddtod("Pow", SDL_pow, regular_cases, SDL_arraysize(regular_cases));
  1482. }
  1483. /**
  1484. * Inputs: (2.0, x), with x in range [0, 8].
  1485. * Expected: the correct result is returned.
  1486. */
  1487. static int
  1488. pow_powerOfTwo(void *args)
  1489. {
  1490. const dd_to_d power_of_two_cases[] = {
  1491. { 2.0, 1.0, 2.0 },
  1492. { 2.0, 2.0, 4.0 },
  1493. { 2.0, 3.0, 8.0 },
  1494. { 2.0, 4.0, 16.0 },
  1495. { 2.0, 5.0, 32.0 },
  1496. { 2.0, 6.0, 64.0 },
  1497. { 2.0, 7.0, 128.0 },
  1498. { 2.0, 8.0, 256.0 },
  1499. };
  1500. return helper_ddtod("Pow", SDL_pow, power_of_two_cases, SDL_arraysize(power_of_two_cases));
  1501. }
  1502. /**
  1503. * Inputs: values in the range [0, UINT32_MAX] to the power of +/-0.0.
  1504. * Expected: 1.0 is always returned.
  1505. */
  1506. static int
  1507. pow_rangeTest(void *args)
  1508. {
  1509. Uint32 i;
  1510. double test_value = 0.0;
  1511. SDLTest_AssertPass("Pow: Testing a range of %u values with steps of %" SDL_PRIu32,
  1512. RANGE_TEST_ITERATIONS,
  1513. RANGE_TEST_STEP);
  1514. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  1515. double result;
  1516. /* These are tested elsewhere */
  1517. if (isnan(test_value) || isinf(test_value)) {
  1518. continue;
  1519. }
  1520. /* Only log failures to save performances */
  1521. result = SDL_pow(test_value, 0.0);
  1522. if (result != 1.0) {
  1523. SDLTest_AssertCheck(SDL_FALSE,
  1524. "Pow(%.1f,%.1f), expected %.1f, got %.1f",
  1525. test_value, 1.0, 1.0, result);
  1526. return TEST_ABORTED;
  1527. }
  1528. result = SDL_pow(test_value, -0.0);
  1529. if (result != 1.0) {
  1530. SDLTest_AssertCheck(SDL_FALSE,
  1531. "Pow(%.1f,%.1f), expected %.1f, got %.1f",
  1532. test_value, -0.0, 1.0, result);
  1533. return TEST_ABORTED;
  1534. }
  1535. }
  1536. return TEST_COMPLETED;
  1537. }
  1538. /* SDL_sqrt tests functions */
  1539. /**
  1540. * Input: Positive Infinity.
  1541. * Expected: Positive Infinity is returned.
  1542. */
  1543. static int
  1544. sqrt_infCase(void *args)
  1545. {
  1546. const double result = SDL_sqrt(INFINITY);
  1547. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1548. "Sqrt(%f), expected %f, got %f",
  1549. INFINITY, INFINITY, result);
  1550. return TEST_COMPLETED;
  1551. }
  1552. /**
  1553. * Input: NAN.
  1554. * Expected: NAN is returned.
  1555. */
  1556. static int
  1557. sqrt_nanCase(void *args)
  1558. {
  1559. const double result = SDL_sqrt(NAN);
  1560. SDLTest_AssertCheck(isnan(result),
  1561. "Sqrt(%f), expected %f, got %f",
  1562. NAN, NAN, result);
  1563. return TEST_COMPLETED;
  1564. }
  1565. /**
  1566. * Inputs: values outside the domain of the function.
  1567. * Expected: NAN is returned.
  1568. */
  1569. static int
  1570. sqrt_outOfDomainCases(void *args)
  1571. {
  1572. double result;
  1573. result = SDL_sqrt(-1.0);
  1574. SDLTest_AssertCheck(isnan(result),
  1575. "Sqrt(%f), expected %f, got %f",
  1576. -1.0, NAN, result);
  1577. result = SDL_sqrt(-12345.6789);
  1578. SDLTest_AssertCheck(isnan(result),
  1579. "Sqrt(%f), expected %f, got %f",
  1580. -12345.6789, NAN, result);
  1581. result = SDL_sqrt(-INFINITY);
  1582. SDLTest_AssertCheck(isnan(result),
  1583. "Sqrt(%f), expected %f, got %f",
  1584. -INFINITY, NAN, result);
  1585. return TEST_COMPLETED;
  1586. }
  1587. /**
  1588. * Inputs: +/-0.0 and 1.0.
  1589. * Expected: the input value is returned as-is.
  1590. */
  1591. static int
  1592. sqrt_baseCases(void *args)
  1593. {
  1594. const d_to_d base_cases[] = {
  1595. { -0.0, -0.0 },
  1596. { 0.0, 0.0 },
  1597. { 1.0, 1.0 }
  1598. };
  1599. return helper_dtod("Sqrt", SDL_sqrt, base_cases, SDL_arraysize(base_cases));
  1600. }
  1601. /**
  1602. * Inputs: values within the domain of the function.
  1603. * Expected: the correct result is returned.
  1604. */
  1605. static int
  1606. sqrt_regularCases(void *args)
  1607. {
  1608. const d_to_d regular_cases[] = {
  1609. { 4.0, 2.0 },
  1610. { 9.0, 3.0 },
  1611. { 27.2, 5.21536192416211896727418206864967942237854003906250 },
  1612. { 240.250, 15.5 },
  1613. { 1337.0, 36.565010597564445049556525191292166709899902343750 },
  1614. { 2887.12782400000014604302123188972473144531250, 53.732 },
  1615. { 65600.0156250, 256.125 }
  1616. };
  1617. return helper_dtod_inexact("Sqrt", SDL_sqrt, regular_cases, SDL_arraysize(regular_cases));
  1618. }
  1619. /* SDL_scalbn tests functions */
  1620. /**
  1621. * Input: (+/-Infinity, 1).
  1622. * Expected: Infinity is returned as-is.
  1623. */
  1624. static int
  1625. scalbn_infCases(void *args)
  1626. {
  1627. double result;
  1628. result = SDL_scalbn(INFINITY, 1);
  1629. SDLTest_AssertCheck(IS_INFINITY(result) && result > 0,
  1630. "Scalbn(%f,%d), expected %f, got %f",
  1631. INFINITY, 1, INFINITY, result);
  1632. result = SDL_scalbn(-INFINITY, 1);
  1633. SDLTest_AssertCheck(IS_INFINITY(result) && result < 0,
  1634. "Scalbn(%f,%d), expected %f, got %f",
  1635. -INFINITY, 1, -INFINITY, result);
  1636. return TEST_COMPLETED;
  1637. }
  1638. /**
  1639. * Inputs: (+/-0.0, 1).
  1640. * Expected: Zero is returned as-is.
  1641. */
  1642. static int
  1643. scalbn_baseZeroCases(void *args)
  1644. {
  1645. double result;
  1646. result = SDL_scalbn(0.0, 1);
  1647. SDLTest_AssertCheck(0.0 == result,
  1648. "Scalbn(%f,%d), expected %f, got %f",
  1649. 0.0, 1, 0.0, result);
  1650. result = SDL_scalbn(-0.0, 1);
  1651. SDLTest_AssertCheck(-0.0 == result,
  1652. "Scalbn(%f,%d), expected %f, got %f",
  1653. -0.0, 1, -0.0, result);
  1654. return TEST_COMPLETED;
  1655. }
  1656. /**
  1657. * Input: (x, 0)
  1658. * Expected: x is returned as-is.
  1659. */
  1660. static int
  1661. scalbn_expZeroCase(void *args)
  1662. {
  1663. const double result = SDL_scalbn(42.0, 0);
  1664. SDLTest_AssertCheck(42.0 == result,
  1665. "Scalbn(%f,%d), expected %f, got %f",
  1666. 42.0, 0, 42.0, result);
  1667. return TEST_COMPLETED;
  1668. }
  1669. /**
  1670. * Input: (NAN, x).
  1671. * Expected: NAN is returned.
  1672. */
  1673. static int
  1674. scalbn_nanCase(void *args)
  1675. {
  1676. const double result = SDL_scalbn(NAN, 2);
  1677. SDLTest_AssertCheck(isnan(result),
  1678. "Scalbn(%f,%d), expected %f, got %f",
  1679. NAN, 2, NAN, result);
  1680. return TEST_COMPLETED;
  1681. }
  1682. /**
  1683. * Inputs: values inside the domain of the function.
  1684. * Expected: the correct result is returned.
  1685. * NOTE: This test depends on SDL_pow and FLT_RADIX.
  1686. */
  1687. static int
  1688. scalbn_regularCases(void *args)
  1689. {
  1690. double result, expected;
  1691. result = SDL_scalbn(2.0, 2);
  1692. expected = 2.0 * SDL_pow(FLT_RADIX, 2);
  1693. SDLTest_AssertCheck(result == expected,
  1694. "Scalbn(%f,%d), expected %f, got %f",
  1695. 2.0, 2, expected, result);
  1696. result = SDL_scalbn(1.0, 13);
  1697. expected = 1.0 * SDL_pow(FLT_RADIX, 13);
  1698. SDLTest_AssertCheck(result == expected,
  1699. "Scalbn(%f,%d), expected %f, got %f",
  1700. 1.0, 13, expected, result);
  1701. result = SDL_scalbn(2.0, -5);
  1702. expected = 2.0 * SDL_pow(FLT_RADIX, -5);
  1703. SDLTest_AssertCheck(result == expected,
  1704. "Scalbn(%f,%d), expected %f, got %f",
  1705. 2.0, -5, expected, result);
  1706. result = SDL_scalbn(-1.0, -13);
  1707. expected = -1.0 * SDL_pow(FLT_RADIX, -13);
  1708. SDLTest_AssertCheck(result == expected,
  1709. "Scalbn(%f,%d), expected %f, got %f",
  1710. -1.0, -13, expected, result);
  1711. return TEST_COMPLETED;
  1712. }
  1713. /* SDL_cos tests functions */
  1714. /**
  1715. * Inputs: +/-Infinity.
  1716. * Expected: NAN is returned.
  1717. */
  1718. static int
  1719. cos_infCases(void *args)
  1720. {
  1721. double result;
  1722. result = SDL_cos(INFINITY);
  1723. SDLTest_AssertCheck(isnan(result),
  1724. "Cos(%f), expected %f, got %f",
  1725. INFINITY, NAN, result);
  1726. result = SDL_cos(-INFINITY);
  1727. SDLTest_AssertCheck(isnan(result),
  1728. "Cos(%f), expected %f, got %f",
  1729. -INFINITY, NAN, result);
  1730. return TEST_COMPLETED;
  1731. }
  1732. /**
  1733. * Input: NAN.
  1734. * Expected: NAN is returned.
  1735. */
  1736. static int
  1737. cos_nanCase(void *args)
  1738. {
  1739. const double result = SDL_cos(NAN);
  1740. SDLTest_AssertCheck(isnan(result),
  1741. "Cos(%f), expected %f, got %f",
  1742. NAN, NAN, result);
  1743. return TEST_COMPLETED;
  1744. }
  1745. /**
  1746. * Inputs: +/-0.0 and +/-Pi.
  1747. * Expected: +1.0 and -1.0 respectively.
  1748. */
  1749. static int
  1750. cos_regularCases(void *args)
  1751. {
  1752. const d_to_d regular_cases[] = {
  1753. { -SDL_PI_D, -1.0 },
  1754. { -0.0, 1.0 },
  1755. { 0.0, 1.0 },
  1756. { SDL_PI_D, -1.0 }
  1757. };
  1758. return helper_dtod("Cos", SDL_cos, regular_cases, SDL_arraysize(regular_cases));
  1759. }
  1760. /**
  1761. * Inputs: Angles between 1/10 and 9/10 of Pi (positive and negative).
  1762. * Expected: The correct result is returned (+/-EPSILON).
  1763. */
  1764. static int
  1765. cos_precisionTest(void *args)
  1766. {
  1767. const d_to_d precision_cases[] = {
  1768. { SDL_PI_D * 1.0 / 10.0, 0.9510565162 },
  1769. { SDL_PI_D * 2.0 / 10.0, 0.8090169943 },
  1770. { SDL_PI_D * 3.0 / 10.0, 0.5877852522 },
  1771. { SDL_PI_D * 4.0 / 10.0, 0.3090169943 },
  1772. { SDL_PI_D * 5.0 / 10.0, 0.0 },
  1773. { SDL_PI_D * 6.0 / 10.0, -0.3090169943 },
  1774. { SDL_PI_D * 7.0 / 10.0, -0.5877852522 },
  1775. { SDL_PI_D * 8.0 / 10.0, -0.8090169943 },
  1776. { SDL_PI_D * 9.0 / 10.0, -0.9510565162 },
  1777. { SDL_PI_D * -1.0 / 10.0, 0.9510565162 },
  1778. { SDL_PI_D * -2.0 / 10.0, 0.8090169943 },
  1779. { SDL_PI_D * -3.0 / 10.0, 0.5877852522 },
  1780. { SDL_PI_D * -4.0 / 10.0, 0.3090169943 },
  1781. { SDL_PI_D * -5.0 / 10.0, 0.0 },
  1782. { SDL_PI_D * -6.0 / 10.0, -0.3090169943 },
  1783. { SDL_PI_D * -7.0 / 10.0, -0.5877852522 },
  1784. { SDL_PI_D * -8.0 / 10.0, -0.8090169943 },
  1785. { SDL_PI_D * -9.0 / 10.0, -0.9510565162 }
  1786. };
  1787. return helper_dtod_inexact("Cos", SDL_cos, precision_cases, SDL_arraysize(precision_cases));
  1788. }
  1789. /**
  1790. * Inputs: Values in the range [0, UINT32_MAX].
  1791. * Expected: A value between 0 and 1 is returned.
  1792. */
  1793. static int
  1794. cos_rangeTest(void *args)
  1795. {
  1796. Uint32 i;
  1797. double test_value = 0.0;
  1798. SDLTest_AssertPass("Cos: Testing a range of %u values with steps of %" SDL_PRIu32,
  1799. RANGE_TEST_ITERATIONS,
  1800. RANGE_TEST_STEP);
  1801. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  1802. double result;
  1803. /* These are tested elsewhere */
  1804. if (isnan(test_value) || isinf(test_value)) {
  1805. continue;
  1806. }
  1807. /* Only log failures to save performances */
  1808. result = SDL_cos(test_value);
  1809. if (result < -1.0 || result > 1.0) {
  1810. SDLTest_AssertCheck(SDL_FALSE,
  1811. "Cos(%.1f), expected [%.1f,%.1f], got %.1f",
  1812. test_value, -1.0, 1.0, result);
  1813. return TEST_ABORTED;
  1814. }
  1815. }
  1816. return TEST_COMPLETED;
  1817. }
  1818. /* SDL_sin tests functions */
  1819. /**
  1820. * Inputs: +/-Infinity.
  1821. * Expected: NAN is returned.
  1822. */
  1823. static int
  1824. sin_infCases(void *args)
  1825. {
  1826. double result;
  1827. result = SDL_sin(INFINITY);
  1828. SDLTest_AssertCheck(isnan(result),
  1829. "Sin(%f), expected %f, got %f",
  1830. INFINITY, NAN, result);
  1831. result = SDL_sin(-INFINITY);
  1832. SDLTest_AssertCheck(isnan(result),
  1833. "Sin(%f), expected %f, got %f",
  1834. -INFINITY, NAN, result);
  1835. return TEST_COMPLETED;
  1836. }
  1837. /**
  1838. * Input: NAN.
  1839. * Expected: NAN is returned.
  1840. */
  1841. static int
  1842. sin_nanCase(void *args)
  1843. {
  1844. const double result = SDL_sin(NAN);
  1845. SDLTest_AssertCheck(isnan(result),
  1846. "Sin(%f), expected %f, got %f",
  1847. NAN, NAN, result);
  1848. return TEST_COMPLETED;
  1849. }
  1850. /**
  1851. * Inputs: +/-0.0 and +/-Pi/2.
  1852. * Expected: +/-0.0 and +/-1.0 respectively.
  1853. */
  1854. static int
  1855. sin_regularCases(void *args)
  1856. {
  1857. const d_to_d regular_cases[] = {
  1858. { -SDL_PI_D / 2, -1.0 },
  1859. { -0.0, -0.0 },
  1860. { 0.0, 0.0 },
  1861. { SDL_PI_D / 2, 1.0 }
  1862. };
  1863. return helper_dtod("Sin", SDL_sin, regular_cases, SDL_arraysize(regular_cases));
  1864. }
  1865. /**
  1866. * Inputs: Angles between 1/10 and 10/10 of Pi (positive and negative).
  1867. * Expected: The correct result is returned (+/-EPSILON).
  1868. * NOTE: +/-Pi/2 is tested in the regular cases.
  1869. */
  1870. static int
  1871. sin_precisionTest(void *args)
  1872. {
  1873. const d_to_d precision_cases[] = {
  1874. { SDL_PI_D * 1.0 / 10.0, 0.3090169943 },
  1875. { SDL_PI_D * 2.0 / 10.0, 0.5877852522 },
  1876. { SDL_PI_D * 3.0 / 10.0, 0.8090169943 },
  1877. { SDL_PI_D * 4.0 / 10.0, 0.9510565162 },
  1878. { SDL_PI_D * 6.0 / 10.0, 0.9510565162 },
  1879. { SDL_PI_D * 7.0 / 10.0, 0.8090169943 },
  1880. { SDL_PI_D * 8.0 / 10.0, 0.5877852522 },
  1881. { SDL_PI_D * 9.0 / 10.0, 0.3090169943 },
  1882. { SDL_PI_D, 0.0 },
  1883. { SDL_PI_D * -1.0 / 10.0, -0.3090169943 },
  1884. { SDL_PI_D * -2.0 / 10.0, -0.5877852522 },
  1885. { SDL_PI_D * -3.0 / 10.0, -0.8090169943 },
  1886. { SDL_PI_D * -4.0 / 10.0, -0.9510565162 },
  1887. { SDL_PI_D * -6.0 / 10.0, -0.9510565162 },
  1888. { SDL_PI_D * -7.0 / 10.0, -0.8090169943 },
  1889. { SDL_PI_D * -8.0 / 10.0, -0.5877852522 },
  1890. { SDL_PI_D * -9.0 / 10.0, -0.3090169943 },
  1891. { -SDL_PI_D, 0.0 },
  1892. };
  1893. return helper_dtod_inexact("Sin", SDL_sin, precision_cases, SDL_arraysize(precision_cases));
  1894. }
  1895. /**
  1896. * Inputs: Values in the range [0, UINT32_MAX].
  1897. * Expected: A value between 0 and 1 is returned.
  1898. */
  1899. static int
  1900. sin_rangeTest(void *args)
  1901. {
  1902. Uint32 i;
  1903. double test_value = 0.0;
  1904. SDLTest_AssertPass("Sin: Testing a range of %u values with steps of %" SDL_PRIu32,
  1905. RANGE_TEST_ITERATIONS,
  1906. RANGE_TEST_STEP);
  1907. for (i = 0; i < RANGE_TEST_ITERATIONS; i++, test_value += RANGE_TEST_STEP) {
  1908. double result;
  1909. /* These are tested elsewhere */
  1910. if (isnan(test_value) || isinf(test_value)) {
  1911. continue;
  1912. }
  1913. /* Only log failures to save performances */
  1914. result = SDL_sin(test_value);
  1915. if (result < -1.0 || result > 1.0) {
  1916. SDLTest_AssertCheck(SDL_FALSE,
  1917. "Sin(%.1f), expected [%.1f,%.1f], got %.1f",
  1918. test_value, -1.0, 1.0, result);
  1919. return TEST_ABORTED;
  1920. }
  1921. }
  1922. return TEST_COMPLETED;
  1923. }
  1924. /* SDL_tan tests functions */
  1925. /**
  1926. * Inputs: +/-Infinity.
  1927. * Expected: NAN is returned.
  1928. */
  1929. static int
  1930. tan_infCases(void *args)
  1931. {
  1932. double result;
  1933. result = SDL_tan(INFINITY);
  1934. SDLTest_AssertCheck(isnan(result),
  1935. "Tan(%f), expected %f, got %f",
  1936. INFINITY, NAN, result);
  1937. result = SDL_tan(-INFINITY);
  1938. SDLTest_AssertCheck(isnan(result),
  1939. "Tan(%f), expected %f, got %f",
  1940. -INFINITY, NAN, result);
  1941. return TEST_COMPLETED;
  1942. }
  1943. /**
  1944. * Input: NAN.
  1945. * Expected: NAN is returned.
  1946. */
  1947. static int
  1948. tan_nanCase(void *args)
  1949. {
  1950. const double result = SDL_tan(NAN);
  1951. SDLTest_AssertCheck(isnan(result),
  1952. "Tan(%f), expected %f, got %f",
  1953. NAN, NAN, result);
  1954. return TEST_COMPLETED;
  1955. }
  1956. /**
  1957. * Inputs: +/-0.0.
  1958. * Expected: Zero is returned as-is.
  1959. */
  1960. static int
  1961. tan_zeroCases(void *args)
  1962. {
  1963. const d_to_d regular_cases[] = {
  1964. { -0.0, -0.0 },
  1965. { 0.0, 0.0 }
  1966. };
  1967. return helper_dtod("Tan", SDL_tan, regular_cases, SDL_arraysize(regular_cases));
  1968. }
  1969. /**
  1970. * Inputs: Angles between 1/11 and 10/11 of Pi (positive and negative).
  1971. * Expected: The correct result is returned (+/-EPSILON).
  1972. * NOTE: +/-Pi/2 is intentionally avoided as it returns garbage values.
  1973. */
  1974. static int
  1975. tan_precisionTest(void *args)
  1976. {
  1977. const d_to_d precision_cases[] = {
  1978. { SDL_PI_D * 1.0 / 11.0, 0.2936264929 },
  1979. { SDL_PI_D * 2.0 / 11.0, 0.6426609771 },
  1980. { SDL_PI_D * 3.0 / 11.0, 1.1540615205 },
  1981. { SDL_PI_D * 4.0 / 11.0, 2.1896945629 },
  1982. { SDL_PI_D * 5.0 / 11.0, 6.9551527717 },
  1983. { SDL_PI_D * 6.0 / 11.0, -6.9551527717 },
  1984. { SDL_PI_D * 7.0 / 11.0, -2.1896945629 },
  1985. { SDL_PI_D * 8.0 / 11.0, -1.1540615205 },
  1986. { SDL_PI_D * 9.0 / 11.0, -0.6426609771 },
  1987. { SDL_PI_D * 10.0 / 11.0, -0.2936264929 },
  1988. { SDL_PI_D * -1.0 / 11.0, -0.2936264929 },
  1989. { SDL_PI_D * -2.0 / 11.0, -0.6426609771 },
  1990. { SDL_PI_D * -3.0 / 11.0, -1.1540615205 },
  1991. { SDL_PI_D * -4.0 / 11.0, -2.1896945629 },
  1992. { SDL_PI_D * -5.0 / 11.0, -6.9551527717 },
  1993. { SDL_PI_D * -6.0 / 11.0, 6.9551527717 },
  1994. { SDL_PI_D * -7.0 / 11.0, 2.1896945629 },
  1995. { SDL_PI_D * -8.0 / 11.0, 1.1540615205 },
  1996. { SDL_PI_D * -9.0 / 11.0, 0.6426609771 },
  1997. { SDL_PI_D * -10.0 / 11.0, 0.2936264929 }
  1998. };
  1999. return helper_dtod_inexact("Tan", SDL_tan, precision_cases, SDL_arraysize(precision_cases));
  2000. }
  2001. /* SDL_acos tests functions */
  2002. /**
  2003. * Inputs: +/-1.0.
  2004. * Expected: 0.0 and Pi respectively.
  2005. */
  2006. static int
  2007. acos_limitCases(void *args)
  2008. {
  2009. double result;
  2010. result = SDL_acos(1.0);
  2011. SDLTest_AssertCheck(0.0 == result,
  2012. "Acos(%f), expected %f, got %f",
  2013. 1.0, 0.0, result);
  2014. result = SDL_acos(-1.0);
  2015. SDLTest_AssertCheck(SDL_PI_D == result,
  2016. "Acos(%f), expected %f, got %f",
  2017. -1.0, SDL_PI_D, result);
  2018. return TEST_COMPLETED;
  2019. }
  2020. /**
  2021. * Inputs: Values outside the domain of [-1, 1].
  2022. * Expected: NAN is returned.
  2023. */
  2024. static int
  2025. acos_outOfDomainCases(void *args)
  2026. {
  2027. double result;
  2028. result = SDL_acos(1.1);
  2029. SDLTest_AssertCheck(isnan(result),
  2030. "Acos(%f), expected %f, got %f",
  2031. 1.1, NAN, result);
  2032. result = SDL_acos(-1.1);
  2033. SDLTest_AssertCheck(isnan(result),
  2034. "Acos(%f), expected %f, got %f",
  2035. -1.1, NAN, result);
  2036. return TEST_COMPLETED;
  2037. }
  2038. /**
  2039. * Input: NAN.
  2040. * Expected: NAN is returned.
  2041. */
  2042. static int
  2043. acos_nanCase(void *args)
  2044. {
  2045. const double result = SDL_acos(NAN);
  2046. SDLTest_AssertCheck(isnan(result),
  2047. "Acos(%f), expected %f, got %f",
  2048. NAN, NAN, result);
  2049. return TEST_COMPLETED;
  2050. }
  2051. /**
  2052. * Inputs: Values between -0.9 and 0.9 with steps of 0.1.
  2053. * Expected: The correct result is returned (+/-EPSILON).
  2054. */
  2055. static int
  2056. acos_precisionTest(void *args)
  2057. {
  2058. const d_to_d precision_cases[] = {
  2059. { 0.9, 0.4510268117 },
  2060. { 0.8, 0.6435011087 },
  2061. { 0.7, 0.7953988301 },
  2062. { 0.6, 0.9272952180 },
  2063. { 0.5, 1.0471975511 },
  2064. { 0.4, 1.1592794807 },
  2065. { 0.3, 1.2661036727 },
  2066. { 0.2, 1.3694384060 },
  2067. { 0.1, 1.4706289056 },
  2068. { 0.0, 1.5707963267 },
  2069. { -0.0, 1.5707963267 },
  2070. { -0.1, 1.6709637479 },
  2071. { -0.2, 1.7721542475 },
  2072. { -0.3, 1.8754889808 },
  2073. { -0.4, 1.9823131728 },
  2074. { -0.5, 2.0943951023 },
  2075. { -0.6, 2.2142974355 },
  2076. { -0.7, 2.3461938234 },
  2077. { -0.8, 2.4980915447 },
  2078. { -0.9, 2.6905658417 },
  2079. };
  2080. return helper_dtod_inexact("Acos", SDL_acos, precision_cases, SDL_arraysize(precision_cases));
  2081. }
  2082. /* SDL_asin tests functions */
  2083. /**
  2084. * Inputs: +/-1.0.
  2085. * Expected: +/-Pi/2 is returned.
  2086. */
  2087. static int
  2088. asin_limitCases(void *args)
  2089. {
  2090. double result;
  2091. result = SDL_asin(1.0);
  2092. SDLTest_AssertCheck(SDL_PI_D / 2.0 == result,
  2093. "Asin(%f), expected %f, got %f",
  2094. 1.0, SDL_PI_D / 2.0, result);
  2095. result = SDL_asin(-1.0);
  2096. SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result,
  2097. "Asin(%f), expected %f, got %f",
  2098. -1.0, -SDL_PI_D / 2.0, result);
  2099. return TEST_COMPLETED;
  2100. }
  2101. /**
  2102. * Inputs: Values outside the domain of [-1, 1].
  2103. * Expected: NAN is returned.
  2104. */
  2105. static int
  2106. asin_outOfDomainCases(void *args)
  2107. {
  2108. double result;
  2109. result = SDL_asin(1.1);
  2110. SDLTest_AssertCheck(isnan(result),
  2111. "Asin(%f), expected %f, got %f",
  2112. 1.1, NAN, result);
  2113. result = SDL_asin(-1.1);
  2114. SDLTest_AssertCheck(isnan(result),
  2115. "Asin(%f), expected %f, got %f",
  2116. -1.1, NAN, result);
  2117. return TEST_COMPLETED;
  2118. }
  2119. /**
  2120. * Input: NAN.
  2121. * Expected: NAN is returned.
  2122. */
  2123. static int
  2124. asin_nanCase(void *args)
  2125. {
  2126. const double result = SDL_asin(NAN);
  2127. SDLTest_AssertCheck(isnan(result),
  2128. "Asin(%f), expected %f, got %f",
  2129. NAN, NAN, result);
  2130. return TEST_COMPLETED;
  2131. }
  2132. /**
  2133. * Inputs: Values between -0.9 and 0.9 with steps of 0.1.
  2134. * Expected: The correct result is returned (+/-EPSILON).
  2135. */
  2136. static int
  2137. asin_precisionTest(void *args)
  2138. {
  2139. const d_to_d precision_cases[] = {
  2140. { 0.9, 1.1197695149 },
  2141. { 0.8, 0.9272952180 },
  2142. { 0.7, 0.7753974966 },
  2143. { 0.6, 0.6435011087 },
  2144. { 0.5, 0.5235987755 },
  2145. { 0.4, 0.4115168460 },
  2146. { 0.3, 0.3046926540 },
  2147. { 0.2, 0.2013579207 },
  2148. { 0.1, 0.1001674211 },
  2149. { 0.0, 0.0 },
  2150. { -0.0, -0.0 },
  2151. { -0.1, -0.1001674211 },
  2152. { -0.2, -0.2013579207 },
  2153. { -0.3, -0.3046926540 },
  2154. { -0.4, -0.4115168460 },
  2155. { -0.5, -0.5235987755 },
  2156. { -0.6, -0.6435011087 },
  2157. { -0.7, -0.7753974966 },
  2158. { -0.8, -0.9272952180 },
  2159. { -0.9, -1.1197695149 }
  2160. };
  2161. return helper_dtod_inexact("Asin", SDL_asin, precision_cases, SDL_arraysize(precision_cases));
  2162. }
  2163. /* SDL_atan tests functions */
  2164. /**
  2165. * Inputs: +/-Infinity.
  2166. * Expected: +/-Pi/2 is returned.
  2167. */
  2168. static int
  2169. atan_limitCases(void *args)
  2170. {
  2171. double result;
  2172. result = SDL_atan(INFINITY);
  2173. SDLTest_AssertCheck((SDL_PI_D / 2.0) - EPSILON <= result &&
  2174. result <= (SDL_PI_D / 2.0) + EPSILON,
  2175. "Atan(%f), expected %f, got %f",
  2176. INFINITY, SDL_PI_D / 2.0, result);
  2177. result = SDL_atan(-INFINITY);
  2178. SDLTest_AssertCheck((-SDL_PI_D / 2.0) - EPSILON <= result &&
  2179. result <= (-SDL_PI_D / 2.0) + EPSILON,
  2180. "Atan(%f), expected %f, got %f",
  2181. -INFINITY, -SDL_PI_D / 2.0, result);
  2182. return TEST_COMPLETED;
  2183. }
  2184. /**
  2185. * Inputs: +/-0.0.
  2186. * Expected: Zero is returned as-is.
  2187. */
  2188. static int
  2189. atan_zeroCases(void *args)
  2190. {
  2191. double result;
  2192. result = SDL_atan(0.0);
  2193. SDLTest_AssertCheck(0.0 == result,
  2194. "Atan(%f), expected %f, got %f",
  2195. 0.0, 0.0, result);
  2196. result = SDL_atan(-0.0);
  2197. SDLTest_AssertCheck(-0.0 == result,
  2198. "Atan(%f), expected %f, got %f",
  2199. -0.0, -0.0, result);
  2200. return TEST_COMPLETED;
  2201. }
  2202. /**
  2203. * Input: NAN.
  2204. * Expected: NAN is returned.
  2205. */
  2206. static int
  2207. atan_nanCase(void *args)
  2208. {
  2209. const double result = SDL_atan(NAN);
  2210. SDLTest_AssertCheck(isnan(result),
  2211. "Atan(%f), expected %f, got %f",
  2212. NAN, NAN, result);
  2213. return TEST_COMPLETED;
  2214. }
  2215. /**
  2216. * Inputs: Values corresponding to angles between 9Pi/20 and -9Pi/20 with steps of Pi/20.
  2217. * Expected: The correct result is returned (+/-EPSILON).
  2218. */
  2219. static int
  2220. atan_precisionTest(void *args)
  2221. {
  2222. const d_to_d precision_cases[] = {
  2223. { 6.313751514675041, 1.4137166941 },
  2224. { 3.0776835371752527, 1.2566370614 },
  2225. { 1.9626105055051504, 1.0995574287 },
  2226. { 1.3763819204711734, 0.9424777960 },
  2227. { 1.0, 0.7853981633 },
  2228. { 0.7265425280053609, 0.6283185307 },
  2229. { 0.5095254494944288, 0.4712388980 },
  2230. { 0.3249196962329063, 0.3141592653 },
  2231. { 0.15838444032453627, 0.1570796326 },
  2232. { -0.15838444032453627, -0.1570796326 },
  2233. { -0.3249196962329063, -0.3141592653 },
  2234. { -0.5095254494944288, -0.4712388980 },
  2235. { -0.7265425280053609, -0.6283185307 },
  2236. { -1.0, -0.7853981633 },
  2237. { -1.3763819204711734, -0.9424777960 },
  2238. { -1.9626105055051504, -1.0995574287 },
  2239. { -3.0776835371752527, -1.2566370614 },
  2240. { -6.313751514675041, -1.4137166941 },
  2241. };
  2242. return helper_dtod_inexact("Atan", SDL_atan, precision_cases, SDL_arraysize(precision_cases));
  2243. }
  2244. /* SDL_atan2 tests functions */
  2245. /* Zero cases */
  2246. /**
  2247. * Inputs: (+/-0.0, +/-0.0).
  2248. * Expected:
  2249. * - Zero if the second argument is positive zero.
  2250. * - Pi if the second argument is negative zero.
  2251. * - The sign is inherited from the first argument.
  2252. */
  2253. static int
  2254. atan2_bothZeroCases(void *args)
  2255. {
  2256. const dd_to_d cases[] = {
  2257. { 0.0, 0.0, 0.0 },
  2258. { -0.0, 0.0, -0.0 },
  2259. { 0.0, -0.0, SDL_PI_D },
  2260. { -0.0, -0.0, -SDL_PI_D },
  2261. };
  2262. return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
  2263. }
  2264. /**
  2265. * Inputs: (+/-0.0, +/-1.0).
  2266. * Expected:
  2267. * - Zero if the second argument is positive.
  2268. * - Pi if the second argument is negative.
  2269. * - The sign is inherited from the first argument.
  2270. */
  2271. static int
  2272. atan2_yZeroCases(void *args)
  2273. {
  2274. const dd_to_d cases[] = {
  2275. { 0.0, 1.0, 0.0 },
  2276. { 0.0, -1.0, SDL_PI_D },
  2277. { -0.0, 1.0, -0.0 },
  2278. { -0.0, -1.0, -SDL_PI_D }
  2279. };
  2280. return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
  2281. }
  2282. /**
  2283. * Inputs: (+/-1.0, +/-0.0).
  2284. * Expected: Pi/2 with the sign of the first argument.
  2285. */
  2286. static int
  2287. atan2_xZeroCases(void *args)
  2288. {
  2289. const dd_to_d cases[] = {
  2290. { 1.0, 0.0, SDL_PI_D / 2.0 },
  2291. { -1.0, 0.0, -SDL_PI_D / 2.0 },
  2292. { 1.0, -0.0, SDL_PI_D / 2.0 },
  2293. { -1.0, -0.0, -SDL_PI_D / 2.0 }
  2294. };
  2295. return helper_ddtod("SDL_atan2", SDL_atan2, cases, SDL_arraysize(cases));
  2296. }
  2297. /* Infinity cases */
  2298. /**
  2299. * Inputs: (+/-Infinity, +/-Infinity).
  2300. * Expected:
  2301. * - (+int, +inf) -> Pi/4,
  2302. * - (+int, -inf) -> 3Pi/4,
  2303. * - (-int, +inf) -> -Pi/4,
  2304. * - (-int, -inf) -> Pi.
  2305. */
  2306. static int
  2307. atan2_bothInfCases(void *args)
  2308. {
  2309. double result;
  2310. result = SDL_atan2(INFINITY, INFINITY);
  2311. SDLTest_AssertCheck(SDL_PI_D / 4.0 == result,
  2312. "Atan2(%f,%f), expected %f, got %f",
  2313. INFINITY, INFINITY, SDL_PI_D / 4.0, result);
  2314. result = SDL_atan2(INFINITY, -INFINITY);
  2315. SDLTest_AssertCheck(3.0 * SDL_PI_D / 4.0 == result,
  2316. "Atan2(%f,%f), expected %f, got %f",
  2317. INFINITY, -INFINITY, 3.0 * SDL_PI_D / 4.0, result);
  2318. result = SDL_atan2(-INFINITY, INFINITY);
  2319. SDLTest_AssertCheck(-SDL_PI_D / 4.0 == result,
  2320. "Atan2(%f,%f), expected %f, got %f",
  2321. -INFINITY, INFINITY, -SDL_PI_D / 4.0, result);
  2322. result = SDL_atan2(-INFINITY, -INFINITY);
  2323. SDLTest_AssertCheck(-3.0 * SDL_PI_D / 4.0 == result,
  2324. "Atan2(%f,%f), expected %f, got %f",
  2325. -INFINITY, -INFINITY, -3.0 * SDL_PI_D / 4.0, result);
  2326. return TEST_COMPLETED;
  2327. }
  2328. /**
  2329. * Inputs: (+/-Infinity, +/-1.0).
  2330. * Expected: Pi/2 with the sign of the first argument.
  2331. */
  2332. static int
  2333. atan2_yInfCases(void *args)
  2334. {
  2335. double result;
  2336. result = SDL_atan2(INFINITY, 1.0);
  2337. SDLTest_AssertCheck(SDL_PI_D / 2.0 == result,
  2338. "Atan2(%f,%f), expected %f, got %f",
  2339. INFINITY, 1.0, SDL_PI_D / 2.0, result);
  2340. result = SDL_atan2(INFINITY, -1.0);
  2341. SDLTest_AssertCheck(SDL_PI_D / 2.0 == result,
  2342. "Atan2(%f,%f), expected %f, got %f",
  2343. INFINITY, -1.0, SDL_PI_D / 2.0, result);
  2344. result = SDL_atan2(-INFINITY, 1.0);
  2345. SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result,
  2346. "Atan2(%f,%f), expected %f, got %f",
  2347. -INFINITY, 1.0, -SDL_PI_D / 2.0, result);
  2348. result = SDL_atan2(-INFINITY, -1.0);
  2349. SDLTest_AssertCheck(-SDL_PI_D / 2.0 == result,
  2350. "Atan2(%f,%f), expected %f, got %f",
  2351. -INFINITY, -1.0, -SDL_PI_D / 2.0, result);
  2352. return TEST_COMPLETED;
  2353. }
  2354. /**
  2355. * Inputs: (+/-1.0, +/-Infinity).
  2356. * Expected:
  2357. * - (+/-1.0, +inf) -> +/-0.0
  2358. * - (+/-1.0, -inf) -> +/-Pi.
  2359. */
  2360. static int
  2361. atan2_xInfCases(void *args)
  2362. {
  2363. double result;
  2364. result = SDL_atan2(1.0, INFINITY);
  2365. SDLTest_AssertCheck(0.0 == result,
  2366. "Atan2(%f,%f), expected %f, got %f",
  2367. 1.0, INFINITY, 0.0, result);
  2368. result = SDL_atan2(-1.0, INFINITY);
  2369. SDLTest_AssertCheck(-0.0 == result,
  2370. "Atan2(%f,%f), expected %f, got %f",
  2371. -1.0, INFINITY, -0.0, result);
  2372. result = SDL_atan2(1.0, -INFINITY);
  2373. SDLTest_AssertCheck(SDL_PI_D == result,
  2374. "Atan2(%f,%f), expected %f, got %f",
  2375. 1.0, -INFINITY, SDL_PI_D, result);
  2376. result = SDL_atan2(-1.0, -INFINITY);
  2377. SDLTest_AssertCheck(-SDL_PI_D == result,
  2378. "Atan2(%f,%f), expected %f, got %f",
  2379. -1.0, -INFINITY, -SDL_PI_D, result);
  2380. return TEST_COMPLETED;
  2381. }
  2382. /* Miscelanious cases */
  2383. /**
  2384. * Inputs: NAN as either or both of the arguments.
  2385. * Expected: NAN is returned.
  2386. */
  2387. static int
  2388. atan2_nanCases(void *args)
  2389. {
  2390. double result;
  2391. result = SDL_atan2(NAN, NAN);
  2392. SDLTest_AssertCheck(isnan(result),
  2393. "Atan2(%f,%f), expected %f, got %f",
  2394. NAN, NAN, NAN, result);
  2395. result = SDL_atan2(NAN, 1.0);
  2396. SDLTest_AssertCheck(isnan(result),
  2397. "Atan2(%f,%f), expected %f, got %f",
  2398. NAN, 1.0, NAN, result);
  2399. result = SDL_atan2(1.0, NAN);
  2400. SDLTest_AssertCheck(isnan(result),
  2401. "Atan2(%f,%f), expected %f, got %f",
  2402. 1.0, NAN, NAN, result);
  2403. return TEST_COMPLETED;
  2404. }
  2405. /**
  2406. * Inputs: (y, x) with x and y positive.
  2407. * Expected: Angle in the top right quadrant.
  2408. */
  2409. static int
  2410. atan2_topRightQuadrantTest(void *args)
  2411. {
  2412. const dd_to_d top_right_cases[] = {
  2413. { 1.0, 1.0, SDL_PI_D / 4.0 },
  2414. { SQRT3, 3.0, SDL_PI_D / 6.0 },
  2415. { SQRT3, 1.0, SDL_PI_D / 3.0 }
  2416. };
  2417. return helper_ddtod_inexact("SDL_atan2", SDL_atan2, top_right_cases, SDL_arraysize(top_right_cases));
  2418. }
  2419. /**
  2420. * Inputs: (y, x) with x negative and y positive.
  2421. * Expected: Angle in the top left quadrant.
  2422. */
  2423. static int
  2424. atan2_topLeftQuadrantTest(void *args)
  2425. {
  2426. const dd_to_d top_left_cases[] = {
  2427. { 1.0, -1.0, 3.0 * SDL_PI_D / 4.0 },
  2428. { SQRT3, -3.0, 5.0 * SDL_PI_D / 6.0 },
  2429. { SQRT3, -1.0, 2.0 * SDL_PI_D / 3.0 }
  2430. };
  2431. return helper_ddtod_inexact("SDL_atan2", SDL_atan2, top_left_cases, SDL_arraysize(top_left_cases));
  2432. }
  2433. /**
  2434. * Inputs: (y, x) with x positive and y negative.
  2435. * Expected: Angle in the bottom right quadrant.
  2436. */
  2437. static int
  2438. atan2_bottomRightQuadrantTest(void *args)
  2439. {
  2440. const dd_to_d bottom_right_cases[] = {
  2441. { -1.0, 1.0, -SDL_PI_D / 4 },
  2442. { -SQRT3, 3.0, -SDL_PI_D / 6.0 },
  2443. { -SQRT3, 1.0, -SDL_PI_D / 3.0 }
  2444. };
  2445. return helper_ddtod_inexact("SDL_atan2", SDL_atan2, bottom_right_cases, SDL_arraysize(bottom_right_cases));
  2446. }
  2447. /**
  2448. * Inputs: (y, x) with x and y negative.
  2449. * Expected: Angle in the bottom left quadrant.
  2450. */
  2451. static int
  2452. atan2_bottomLeftQuadrantTest(void *args)
  2453. {
  2454. const dd_to_d bottom_left_cases[] = {
  2455. { -1.0, -1.0, -3.0 * SDL_PI_D / 4.0 },
  2456. { -SQRT3, -3.0, -5.0 * SDL_PI_D / 6.0 },
  2457. { -SQRT3, -1.0, -4.0 * SDL_PI_D / 6.0 }
  2458. };
  2459. return helper_ddtod_inexact("SDL_atan2", SDL_atan2, bottom_left_cases, SDL_arraysize(bottom_left_cases));
  2460. }
  2461. /* ================= Test References ================== */
  2462. /* SDL_floor test cases */
  2463. static const SDLTest_TestCaseReference floorTestInf = {
  2464. (SDLTest_TestCaseFp)floor_infCases, "floor_infCases",
  2465. "Checks positive and negative infinity", TEST_ENABLED
  2466. };
  2467. static const SDLTest_TestCaseReference floorTestZero = {
  2468. (SDLTest_TestCaseFp)floor_zeroCases, "floor_zeroCases",
  2469. "Checks positive and negative zero", TEST_ENABLED
  2470. };
  2471. static const SDLTest_TestCaseReference floorTestNan = {
  2472. (SDLTest_TestCaseFp)floor_nanCase, "floor_nanCase",
  2473. "Checks NAN", TEST_ENABLED
  2474. };
  2475. static const SDLTest_TestCaseReference floorTestRound = {
  2476. (SDLTest_TestCaseFp)floor_roundNumbersCases, "floor_roundNumberCases",
  2477. "Checks a set of integral values", TEST_ENABLED
  2478. };
  2479. static const SDLTest_TestCaseReference floorTestFraction = {
  2480. (SDLTest_TestCaseFp)floor_fractionCases, "floor_fractionCases",
  2481. "Checks a set of fractions", TEST_ENABLED
  2482. };
  2483. static const SDLTest_TestCaseReference floorTestRange = {
  2484. (SDLTest_TestCaseFp)floor_rangeTest, "floor_rangeTest",
  2485. "Checks a range of positive integer", TEST_ENABLED
  2486. };
  2487. /* SDL_ceil test cases */
  2488. static const SDLTest_TestCaseReference ceilTestInf = {
  2489. (SDLTest_TestCaseFp)ceil_infCases, "ceil_infCases",
  2490. "Checks positive and negative infinity", TEST_ENABLED
  2491. };
  2492. static const SDLTest_TestCaseReference ceilTestZero = {
  2493. (SDLTest_TestCaseFp)ceil_zeroCases, "ceil_zeroCases",
  2494. "Checks positive and negative zero", TEST_ENABLED
  2495. };
  2496. static const SDLTest_TestCaseReference ceilTestNan = {
  2497. (SDLTest_TestCaseFp)ceil_nanCase, "ceil_nanCase",
  2498. "Checks NAN", TEST_ENABLED
  2499. };
  2500. static const SDLTest_TestCaseReference ceilTestRound = {
  2501. (SDLTest_TestCaseFp)ceil_roundNumbersCases, "ceil_roundNumberCases",
  2502. "Checks a set of integral values", TEST_ENABLED
  2503. };
  2504. static const SDLTest_TestCaseReference ceilTestFraction = {
  2505. (SDLTest_TestCaseFp)ceil_fractionCases, "ceil_fractionCases",
  2506. "Checks a set of fractions", TEST_ENABLED
  2507. };
  2508. static const SDLTest_TestCaseReference ceilTestRange = {
  2509. (SDLTest_TestCaseFp)ceil_rangeTest, "ceil_rangeTest",
  2510. "Checks a range of positive integer", TEST_ENABLED
  2511. };
  2512. /* SDL_trunc test cases */
  2513. static const SDLTest_TestCaseReference truncTestInf = {
  2514. (SDLTest_TestCaseFp)trunc_infCases, "trunc_infCases",
  2515. "Checks positive and negative infinity", TEST_ENABLED
  2516. };
  2517. static const SDLTest_TestCaseReference truncTestZero = {
  2518. (SDLTest_TestCaseFp)trunc_zeroCases, "trunc_zeroCases",
  2519. "Checks positive and negative zero", TEST_ENABLED
  2520. };
  2521. static const SDLTest_TestCaseReference truncTestNan = {
  2522. (SDLTest_TestCaseFp)trunc_nanCase, "trunc_nanCase",
  2523. "Checks NAN", TEST_ENABLED
  2524. };
  2525. static const SDLTest_TestCaseReference truncTestRound = {
  2526. (SDLTest_TestCaseFp)trunc_roundNumbersCases, "trunc_roundNumberCases",
  2527. "Checks a set of integral values", TEST_ENABLED
  2528. };
  2529. static const SDLTest_TestCaseReference truncTestFraction = {
  2530. (SDLTest_TestCaseFp)trunc_fractionCases, "trunc_fractionCases",
  2531. "Checks a set of fractions", TEST_ENABLED
  2532. };
  2533. static const SDLTest_TestCaseReference truncTestRange = {
  2534. (SDLTest_TestCaseFp)trunc_rangeTest, "trunc_rangeTest",
  2535. "Checks a range of positive integer", TEST_ENABLED
  2536. };
  2537. /* SDL_round test cases */
  2538. static const SDLTest_TestCaseReference roundTestInf = {
  2539. (SDLTest_TestCaseFp)round_infCases, "round_infCases",
  2540. "Checks positive and negative infinity", TEST_ENABLED
  2541. };
  2542. static const SDLTest_TestCaseReference roundTestZero = {
  2543. (SDLTest_TestCaseFp)round_zeroCases, "round_zeroCases",
  2544. "Checks positive and negative zero", TEST_ENABLED
  2545. };
  2546. static const SDLTest_TestCaseReference roundTestNan = {
  2547. (SDLTest_TestCaseFp)round_nanCase, "round_nanCase",
  2548. "Checks NAN", TEST_ENABLED
  2549. };
  2550. static const SDLTest_TestCaseReference roundTestRound = {
  2551. (SDLTest_TestCaseFp)round_roundNumbersCases, "round_roundNumberCases",
  2552. "Checks a set of integral values", TEST_ENABLED
  2553. };
  2554. static const SDLTest_TestCaseReference roundTestFraction = {
  2555. (SDLTest_TestCaseFp)round_fractionCases, "round_fractionCases",
  2556. "Checks a set of fractions", TEST_ENABLED
  2557. };
  2558. static const SDLTest_TestCaseReference roundTestRange = {
  2559. (SDLTest_TestCaseFp)round_rangeTest, "round_rangeTest",
  2560. "Checks a range of positive integer", TEST_ENABLED
  2561. };
  2562. /* SDL_fabs test cases */
  2563. static const SDLTest_TestCaseReference fabsTestInf = {
  2564. (SDLTest_TestCaseFp)fabs_infCases, "fabs_infCases",
  2565. "Checks positive and negative infinity", TEST_ENABLED
  2566. };
  2567. static const SDLTest_TestCaseReference fabsTestZero = {
  2568. (SDLTest_TestCaseFp)fabs_zeroCases, "fabs_zeroCases",
  2569. "Checks positive and negative zero", TEST_ENABLED
  2570. };
  2571. static const SDLTest_TestCaseReference fabsTestNan = {
  2572. (SDLTest_TestCaseFp)fabs_nanCase, "fabs_nanCase",
  2573. "Checks NAN", TEST_ENABLED
  2574. };
  2575. static const SDLTest_TestCaseReference fabsTestRange = {
  2576. (SDLTest_TestCaseFp)fabs_rangeTest, "fabs_rangeTest",
  2577. "Checks a range of positive integer", TEST_ENABLED
  2578. };
  2579. /* SDL_copysign test cases */
  2580. static const SDLTest_TestCaseReference copysignTestInf = {
  2581. (SDLTest_TestCaseFp)copysign_infCases, "copysign_infCases",
  2582. "Checks positive and negative infinity", TEST_ENABLED
  2583. };
  2584. static const SDLTest_TestCaseReference copysignTestZero = {
  2585. (SDLTest_TestCaseFp)copysign_zeroCases, "copysign_zeroCases",
  2586. "Checks positive and negative zero", TEST_ENABLED
  2587. };
  2588. static const SDLTest_TestCaseReference copysignTestNan = {
  2589. (SDLTest_TestCaseFp)copysign_nanCases, "copysign_nanCases",
  2590. "Checks NANs", TEST_ENABLED
  2591. };
  2592. static const SDLTest_TestCaseReference copysignTestRange = {
  2593. (SDLTest_TestCaseFp)copysign_rangeTest, "copysign_rangeTest",
  2594. "Checks a range of positive integer", TEST_ENABLED
  2595. };
  2596. /* SDL_fmod test cases */
  2597. static const SDLTest_TestCaseReference fmodTestDivOfInf = {
  2598. (SDLTest_TestCaseFp)fmod_divOfInfCases, "fmod_divOfInfCases",
  2599. "Checks division of positive and negative infinity", TEST_ENABLED
  2600. };
  2601. static const SDLTest_TestCaseReference fmodTestDivByInf = {
  2602. (SDLTest_TestCaseFp)fmod_divByInfCases, "fmod_divByInfCases",
  2603. "Checks division by positive and negative infinity", TEST_ENABLED
  2604. };
  2605. static const SDLTest_TestCaseReference fmodTestDivOfZero = {
  2606. (SDLTest_TestCaseFp)fmod_divOfZeroCases, "fmod_divOfZeroCases",
  2607. "Checks division of positive and negative zero", TEST_ENABLED
  2608. };
  2609. static const SDLTest_TestCaseReference fmodTestDivByZero = {
  2610. (SDLTest_TestCaseFp)fmod_divByZeroCases, "fmod_divByZeroCases",
  2611. "Checks division by positive and negative zero", TEST_ENABLED
  2612. };
  2613. static const SDLTest_TestCaseReference fmodTestNan = {
  2614. (SDLTest_TestCaseFp)fmod_nanCases, "fmod_nanCases",
  2615. "Checks NANs", TEST_ENABLED
  2616. };
  2617. static const SDLTest_TestCaseReference fmodTestRegular = {
  2618. (SDLTest_TestCaseFp)fmod_regularCases, "fmod_regularCases",
  2619. "Checks a set of regular values", TEST_ENABLED
  2620. };
  2621. static const SDLTest_TestCaseReference fmodTestRange = {
  2622. (SDLTest_TestCaseFp)fmod_rangeTest, "fmod_rangeTest",
  2623. "Checks a range of positive integer", TEST_ENABLED
  2624. };
  2625. /* SDL_exp test cases */
  2626. static const SDLTest_TestCaseReference expTestInf = {
  2627. (SDLTest_TestCaseFp)exp_infCases, "exp_infCases",
  2628. "Checks positive and negative infinity", TEST_ENABLED
  2629. };
  2630. static const SDLTest_TestCaseReference expTestZero = {
  2631. (SDLTest_TestCaseFp)exp_zeroCases, "exp_zeroCases",
  2632. "Checks for positive and negative zero", TEST_ENABLED
  2633. };
  2634. static const SDLTest_TestCaseReference expTestOverflow = {
  2635. (SDLTest_TestCaseFp)exp_overflowCase, "exp_overflowCase",
  2636. "Checks for overflow", TEST_ENABLED
  2637. };
  2638. static const SDLTest_TestCaseReference expTestBase = {
  2639. (SDLTest_TestCaseFp)exp_baseCase, "exp_baseCase",
  2640. "Checks the base case", TEST_ENABLED
  2641. };
  2642. static const SDLTest_TestCaseReference expTestRegular = {
  2643. (SDLTest_TestCaseFp)exp_regularCases, "exp_regularCases",
  2644. "Checks a set of regular values", TEST_ENABLED
  2645. };
  2646. /* SDL_log test cases */
  2647. static const SDLTest_TestCaseReference logTestLimit = {
  2648. (SDLTest_TestCaseFp)log_limitCases, "log_limitCases",
  2649. "Checks the domain limits", TEST_ENABLED
  2650. };
  2651. static const SDLTest_TestCaseReference logTestNan = {
  2652. (SDLTest_TestCaseFp)log_nanCases, "log_nanCases",
  2653. "Checks NAN and negative values", TEST_ENABLED
  2654. };
  2655. static const SDLTest_TestCaseReference logTestBase = {
  2656. (SDLTest_TestCaseFp)log_baseCases, "log_baseCases",
  2657. "Checks the base cases", TEST_ENABLED
  2658. };
  2659. static const SDLTest_TestCaseReference logTestRegular = {
  2660. (SDLTest_TestCaseFp)log_regularCases, "log_regularCases",
  2661. "Checks a set of regular values", TEST_ENABLED
  2662. };
  2663. /* SDL_log10 test cases */
  2664. static const SDLTest_TestCaseReference log10TestLimit = {
  2665. (SDLTest_TestCaseFp)log10_limitCases, "log10_limitCases",
  2666. "Checks the domain limits", TEST_ENABLED
  2667. };
  2668. static const SDLTest_TestCaseReference log10TestNan = {
  2669. (SDLTest_TestCaseFp)log10_nanCases, "log10_nanCases",
  2670. "Checks NAN and negative values", TEST_ENABLED
  2671. };
  2672. static const SDLTest_TestCaseReference log10TestBase = {
  2673. (SDLTest_TestCaseFp)log10_baseCases, "log10_baseCases",
  2674. "Checks the base cases", TEST_ENABLED
  2675. };
  2676. static const SDLTest_TestCaseReference log10TestRegular = {
  2677. (SDLTest_TestCaseFp)log10_regularCases, "log10_regularCases",
  2678. "Checks a set of regular values", TEST_ENABLED
  2679. };
  2680. /* SDL_modf test cases */
  2681. static const SDLTest_TestCaseReference modfTestBase = {
  2682. (SDLTest_TestCaseFp)modf_baseCases, "modf_baseCases",
  2683. "Checks the base cases", TEST_ENABLED
  2684. };
  2685. /* SDL_nextafter test cases */
  2686. static const SDLTest_TestCaseReference nextafterTestBase = {
  2687. (SDLTest_TestCaseFp)nextafter_baseCases, "nextafter_baseCases",
  2688. "Checks the base cases", TEST_ENABLED
  2689. };
  2690. /* SDL_nextafterf test cases */
  2691. static const SDLTest_TestCaseReference nextafterfTestBase = {
  2692. (SDLTest_TestCaseFp)nextafterf_baseCases, "nextafterf_baseCases",
  2693. "Checks the base cases", TEST_ENABLED
  2694. };
  2695. /* SDL_pow test cases */
  2696. static const SDLTest_TestCaseReference powTestExpInf1 = {
  2697. (SDLTest_TestCaseFp)pow_baseNOneExpInfCases, "pow_baseNOneExpInfCases",
  2698. "Checks for pow(-1, +/-inf)", TEST_ENABLED
  2699. };
  2700. static const SDLTest_TestCaseReference powTestExpInf2 = {
  2701. (SDLTest_TestCaseFp)pow_baseZeroExpNInfCases, "pow_baseZeroExpNInfCases",
  2702. "Checks for pow(+/-0, -inf)", TEST_ENABLED
  2703. };
  2704. static const SDLTest_TestCaseReference powTestExpInf3 = {
  2705. (SDLTest_TestCaseFp)pow_expInfCases, "pow_expInfCases",
  2706. "Checks for pow(x, +/-inf)", TEST_ENABLED
  2707. };
  2708. static const SDLTest_TestCaseReference powTestBaseInf1 = {
  2709. (SDLTest_TestCaseFp)pow_basePInfCases, "pow_basePInfCases",
  2710. "Checks for pow(inf, x)", TEST_ENABLED
  2711. };
  2712. static const SDLTest_TestCaseReference powTestBaseInf2 = {
  2713. (SDLTest_TestCaseFp)pow_baseNInfCases, "pow_baseNInfCases",
  2714. "Checks for pow(-inf, x)", TEST_ENABLED
  2715. };
  2716. static const SDLTest_TestCaseReference powTestNan1 = {
  2717. (SDLTest_TestCaseFp)pow_badOperationCase, "pow_badOperationCase",
  2718. "Checks for negative finite base and non-integer finite exponent", TEST_ENABLED
  2719. };
  2720. static const SDLTest_TestCaseReference powTestNan2 = {
  2721. (SDLTest_TestCaseFp)pow_base1ExpNanCase, "pow_base1ExpNanCase",
  2722. "Checks for pow(1.0, NAN)", TEST_ENABLED
  2723. };
  2724. static const SDLTest_TestCaseReference powTestNan3 = {
  2725. (SDLTest_TestCaseFp)pow_baseNanExp0Cases, "pow_baseNanExp0Cases",
  2726. "Checks for pow(NAN, +/-0)", TEST_ENABLED
  2727. };
  2728. static const SDLTest_TestCaseReference powTestNan4 = {
  2729. (SDLTest_TestCaseFp)pow_nanArgsCases, "pow_nanArgsCases",
  2730. "Checks for pow(x, y) with either x or y being NAN", TEST_ENABLED
  2731. };
  2732. static const SDLTest_TestCaseReference powTestZero1 = {
  2733. (SDLTest_TestCaseFp)pow_baseNZeroExpOddCases, "pow_baseNZeroExpOddCases",
  2734. "Checks for pow(-0.0, y), with y an odd integer.", TEST_ENABLED
  2735. };
  2736. static const SDLTest_TestCaseReference powTestZero2 = {
  2737. (SDLTest_TestCaseFp)pow_basePZeroExpOddCases, "pow_basePZeroExpOddCases",
  2738. "Checks for pow(0.0, y), with y an odd integer.", TEST_ENABLED
  2739. };
  2740. static const SDLTest_TestCaseReference powTestZero3 = {
  2741. (SDLTest_TestCaseFp)pow_baseNZeroCases, "pow_baseNZeroCases",
  2742. "Checks for pow(-0.0, y), with y finite and even or non-integer number", TEST_ENABLED
  2743. };
  2744. static const SDLTest_TestCaseReference powTestZero4 = {
  2745. (SDLTest_TestCaseFp)pow_basePZeroCases, "pow_basePZeroCases",
  2746. "Checks for pow(0.0, y), with y finite and even or non-integer number", TEST_ENABLED
  2747. };
  2748. static const SDLTest_TestCaseReference powTestRegular = {
  2749. (SDLTest_TestCaseFp)pow_regularCases, "pow_regularCases",
  2750. "Checks a set of regular values", TEST_ENABLED
  2751. };
  2752. static const SDLTest_TestCaseReference powTestPowOf2 = {
  2753. (SDLTest_TestCaseFp)pow_powerOfTwo, "pow_powerOfTwo",
  2754. "Checks the powers of two from 1 to 8", TEST_ENABLED
  2755. };
  2756. static const SDLTest_TestCaseReference powTestRange = {
  2757. (SDLTest_TestCaseFp)pow_rangeTest, "pow_rangeTest",
  2758. "Checks a range of positive integer to the power of 0", TEST_ENABLED
  2759. };
  2760. /* SDL_sqrt test cases */
  2761. static const SDLTest_TestCaseReference sqrtTestInf = {
  2762. (SDLTest_TestCaseFp)sqrt_infCase, "sqrt_infCase",
  2763. "Checks positive infinity", TEST_ENABLED
  2764. };
  2765. static const SDLTest_TestCaseReference sqrtTestNan = {
  2766. (SDLTest_TestCaseFp)sqrt_nanCase, "sqrt_nanCase",
  2767. "Checks NAN", TEST_ENABLED
  2768. };
  2769. static const SDLTest_TestCaseReference sqrtTestDomain = {
  2770. (SDLTest_TestCaseFp)sqrt_outOfDomainCases, "sqrt_outOfDomainCases",
  2771. "Checks for values out of the domain", TEST_ENABLED
  2772. };
  2773. static const SDLTest_TestCaseReference sqrtTestBase = {
  2774. (SDLTest_TestCaseFp)sqrt_baseCases, "sqrt_baseCases",
  2775. "Checks the base cases", TEST_ENABLED
  2776. };
  2777. static const SDLTest_TestCaseReference sqrtTestRegular = {
  2778. (SDLTest_TestCaseFp)sqrt_regularCases, "sqrt_regularCases",
  2779. "Checks a set of regular values", TEST_ENABLED
  2780. };
  2781. /* SDL_scalbn test cases */
  2782. static const SDLTest_TestCaseReference scalbnTestInf = {
  2783. (SDLTest_TestCaseFp)scalbn_infCases, "scalbn_infCases",
  2784. "Checks positive and negative infinity arg", TEST_ENABLED
  2785. };
  2786. static const SDLTest_TestCaseReference scalbnTestBaseZero = {
  2787. (SDLTest_TestCaseFp)scalbn_baseZeroCases, "scalbn_baseZeroCases",
  2788. "Checks for positive and negative zero arg", TEST_ENABLED
  2789. };
  2790. static const SDLTest_TestCaseReference scalbnTestExpZero = {
  2791. (SDLTest_TestCaseFp)scalbn_expZeroCase, "scalbn_expZeroCase",
  2792. "Checks for zero exp", TEST_ENABLED
  2793. };
  2794. static const SDLTest_TestCaseReference scalbnTestNan = {
  2795. (SDLTest_TestCaseFp)scalbn_nanCase, "scalbn_nanCase",
  2796. "Checks NAN", TEST_ENABLED
  2797. };
  2798. static const SDLTest_TestCaseReference scalbnTestRegular = {
  2799. (SDLTest_TestCaseFp)scalbn_regularCases, "scalbn_regularCases",
  2800. "Checks a set of regular cases", TEST_ENABLED
  2801. };
  2802. /* SDL_cos test cases */
  2803. static const SDLTest_TestCaseReference cosTestInf = {
  2804. (SDLTest_TestCaseFp)cos_infCases, "cos_infCases",
  2805. "Checks for positive and negative infinity", TEST_ENABLED
  2806. };
  2807. static const SDLTest_TestCaseReference cosTestNan = {
  2808. (SDLTest_TestCaseFp)cos_nanCase, "cos_nanCase",
  2809. "Checks NAN", TEST_ENABLED
  2810. };
  2811. static const SDLTest_TestCaseReference cosTestRegular = {
  2812. (SDLTest_TestCaseFp)cos_regularCases, "cos_regularCases",
  2813. "Checks a set of regular cases", TEST_ENABLED
  2814. };
  2815. static const SDLTest_TestCaseReference cosTestPrecision = {
  2816. (SDLTest_TestCaseFp)cos_precisionTest, "cos_precisionTest",
  2817. "Checks cosine precision", TEST_ENABLED
  2818. };
  2819. static const SDLTest_TestCaseReference cosTestRange = {
  2820. (SDLTest_TestCaseFp)cos_rangeTest, "cos_rangeTest",
  2821. "Checks a range of positive integer", TEST_ENABLED
  2822. };
  2823. /* SDL_sin test cases */
  2824. static const SDLTest_TestCaseReference sinTestInf = {
  2825. (SDLTest_TestCaseFp)sin_infCases, "sin_infCases",
  2826. "Checks for positive and negative infinity", TEST_ENABLED
  2827. };
  2828. static const SDLTest_TestCaseReference sinTestNan = {
  2829. (SDLTest_TestCaseFp)sin_nanCase, "sin_nanCase",
  2830. "Checks NAN", TEST_ENABLED
  2831. };
  2832. static const SDLTest_TestCaseReference sinTestRegular = {
  2833. (SDLTest_TestCaseFp)sin_regularCases, "sin_regularCases",
  2834. "Checks a set of regular cases", TEST_ENABLED
  2835. };
  2836. static const SDLTest_TestCaseReference sinTestPrecision = {
  2837. (SDLTest_TestCaseFp)sin_precisionTest, "sin_precisionTest",
  2838. "Checks sine precision", TEST_ENABLED
  2839. };
  2840. static const SDLTest_TestCaseReference sinTestRange = {
  2841. (SDLTest_TestCaseFp)sin_rangeTest, "sin_rangeTest",
  2842. "Checks a range of positive integer", TEST_ENABLED
  2843. };
  2844. /* SDL_tan test cases */
  2845. static const SDLTest_TestCaseReference tanTestInf = {
  2846. (SDLTest_TestCaseFp)tan_infCases, "tan_infCases",
  2847. "Checks for positive and negative infinity", TEST_ENABLED
  2848. };
  2849. static const SDLTest_TestCaseReference tanTestNan = {
  2850. (SDLTest_TestCaseFp)tan_nanCase, "tan_nanCase",
  2851. "Checks NAN", TEST_ENABLED
  2852. };
  2853. static const SDLTest_TestCaseReference tanTestZero = {
  2854. (SDLTest_TestCaseFp)tan_zeroCases, "tan_zeroCases",
  2855. "Checks a set of regular cases", TEST_ENABLED
  2856. };
  2857. static const SDLTest_TestCaseReference tanTestPrecision = {
  2858. (SDLTest_TestCaseFp)tan_precisionTest, "tan_precisionTest",
  2859. "Checks tangent precision", TEST_ENABLED
  2860. };
  2861. /* SDL_acos test cases */
  2862. static const SDLTest_TestCaseReference acosTestLimit = {
  2863. (SDLTest_TestCaseFp)acos_limitCases, "acos_limitCases",
  2864. "Checks the edge of the domain (+/-1)", TEST_ENABLED
  2865. };
  2866. static const SDLTest_TestCaseReference acosTestOutOfDomain = {
  2867. (SDLTest_TestCaseFp)acos_outOfDomainCases, "acos_outOfDomainCases",
  2868. "Checks values outside the domain", TEST_ENABLED
  2869. };
  2870. static const SDLTest_TestCaseReference acosTestNan = {
  2871. (SDLTest_TestCaseFp)acos_nanCase, "acos_nanCase",
  2872. "Checks NAN", TEST_ENABLED
  2873. };
  2874. static const SDLTest_TestCaseReference acosTestPrecision = {
  2875. (SDLTest_TestCaseFp)acos_precisionTest, "acos_precisionTest",
  2876. "Checks acos precision", TEST_ENABLED
  2877. };
  2878. /* SDL_asin test cases */
  2879. static const SDLTest_TestCaseReference asinTestLimit = {
  2880. (SDLTest_TestCaseFp)asin_limitCases, "asin_limitCases",
  2881. "Checks the edge of the domain (+/-1)", TEST_ENABLED
  2882. };
  2883. static const SDLTest_TestCaseReference asinTestOutOfDomain = {
  2884. (SDLTest_TestCaseFp)asin_outOfDomainCases, "asin_outOfDomainCases",
  2885. "Checks values outside the domain", TEST_ENABLED
  2886. };
  2887. static const SDLTest_TestCaseReference asinTestNan = {
  2888. (SDLTest_TestCaseFp)asin_nanCase, "asin_nanCase",
  2889. "Checks NAN", TEST_ENABLED
  2890. };
  2891. static const SDLTest_TestCaseReference asinTestPrecision = {
  2892. (SDLTest_TestCaseFp)asin_precisionTest, "asin_precisionTest",
  2893. "Checks asin precision", TEST_ENABLED
  2894. };
  2895. /* SDL_atan test cases */
  2896. static const SDLTest_TestCaseReference atanTestLimit = {
  2897. (SDLTest_TestCaseFp)atan_limitCases, "atan_limitCases",
  2898. "Checks the edge of the domain (+/-Infinity)", TEST_ENABLED
  2899. };
  2900. static const SDLTest_TestCaseReference atanTestZero = {
  2901. (SDLTest_TestCaseFp)atan_zeroCases, "atan_zeroCases",
  2902. "Checks for positive and negative zero", TEST_ENABLED
  2903. };
  2904. static const SDLTest_TestCaseReference atanTestNan = {
  2905. (SDLTest_TestCaseFp)atan_nanCase, "atan_nanCase",
  2906. "Checks NAN", TEST_ENABLED
  2907. };
  2908. static const SDLTest_TestCaseReference atanTestPrecision = {
  2909. (SDLTest_TestCaseFp)atan_precisionTest, "atan_precisionTest",
  2910. "Checks atan precision", TEST_ENABLED
  2911. };
  2912. /* SDL_atan2 test cases */
  2913. static const SDLTest_TestCaseReference atan2TestZero1 = {
  2914. (SDLTest_TestCaseFp)atan2_bothZeroCases, "atan2_bothZeroCases",
  2915. "Checks for both arguments being zero", TEST_ENABLED
  2916. };
  2917. static const SDLTest_TestCaseReference atan2TestZero2 = {
  2918. (SDLTest_TestCaseFp)atan2_yZeroCases, "atan2_yZeroCases",
  2919. "Checks for y=0", TEST_ENABLED
  2920. };
  2921. static const SDLTest_TestCaseReference atan2TestZero3 = {
  2922. (SDLTest_TestCaseFp)atan2_xZeroCases, "atan2_xZeroCases",
  2923. "Checks for x=0", TEST_ENABLED
  2924. };
  2925. static const SDLTest_TestCaseReference atan2TestInf1 = {
  2926. (SDLTest_TestCaseFp)atan2_bothInfCases, "atan2_bothInfCases",
  2927. "Checks for both arguments being infinity", TEST_ENABLED
  2928. };
  2929. static const SDLTest_TestCaseReference atan2TestInf2 = {
  2930. (SDLTest_TestCaseFp)atan2_yInfCases, "atan2_yInfCases",
  2931. "Checks for y=0", TEST_ENABLED
  2932. };
  2933. static const SDLTest_TestCaseReference atan2TestInf3 = {
  2934. (SDLTest_TestCaseFp)atan2_xInfCases, "atan2_xInfCases",
  2935. "Checks for x=0", TEST_ENABLED
  2936. };
  2937. static const SDLTest_TestCaseReference atan2TestNan = {
  2938. (SDLTest_TestCaseFp)atan2_nanCases, "atan2_nanCases",
  2939. "Checks NANs", TEST_ENABLED
  2940. };
  2941. static const SDLTest_TestCaseReference atan2TestQuadrantTopRight = {
  2942. (SDLTest_TestCaseFp)atan2_topRightQuadrantTest, "atan2_topRightQuadrantTest",
  2943. "Checks values in the top right quadrant", TEST_ENABLED
  2944. };
  2945. static const SDLTest_TestCaseReference atan2TestQuadrantTopLeft = {
  2946. (SDLTest_TestCaseFp)atan2_topLeftQuadrantTest, "atan2_topLeftQuadrantTest",
  2947. "Checks values in the top left quadrant", TEST_ENABLED
  2948. };
  2949. static const SDLTest_TestCaseReference atan2TestQuadrantBottomRight = {
  2950. (SDLTest_TestCaseFp)atan2_bottomRightQuadrantTest, "atan2_bottomRightQuadrantTest",
  2951. "Checks values in the bottom right quadrant", TEST_ENABLED
  2952. };
  2953. static const SDLTest_TestCaseReference atan2TestQuadrantBottomLeft = {
  2954. (SDLTest_TestCaseFp)atan2_bottomLeftQuadrantTest, "atan2_bottomLeftQuadrantTest",
  2955. "Checks values in the bottom left quadrant", TEST_ENABLED
  2956. };
  2957. static const SDLTest_TestCaseReference *mathTests[] = {
  2958. &floorTestInf, &floorTestZero, &floorTestNan,
  2959. &floorTestRound, &floorTestFraction, &floorTestRange,
  2960. &ceilTestInf, &ceilTestZero, &ceilTestNan,
  2961. &ceilTestRound, &ceilTestFraction, &ceilTestRange,
  2962. &truncTestInf, &truncTestZero, &truncTestNan,
  2963. &truncTestRound, &truncTestFraction, &truncTestRange,
  2964. &roundTestInf, &roundTestZero, &roundTestNan,
  2965. &roundTestRound, &roundTestFraction, &roundTestRange,
  2966. &fabsTestInf, &fabsTestZero, &fabsTestNan, &fabsTestRange,
  2967. &copysignTestInf, &copysignTestZero, &copysignTestNan, &copysignTestRange,
  2968. &fmodTestDivOfInf, &fmodTestDivByInf, &fmodTestDivOfZero, &fmodTestDivByZero,
  2969. &fmodTestNan, &fmodTestRegular, &fmodTestRange,
  2970. &expTestInf, &expTestZero, &expTestOverflow,
  2971. &expTestBase, &expTestRegular,
  2972. &logTestLimit, &logTestNan,
  2973. &logTestBase, &logTestRegular,
  2974. &log10TestLimit, &log10TestNan,
  2975. &log10TestBase, &log10TestRegular,
  2976. &modfTestBase,
  2977. &nextafterTestBase, &nextafterfTestBase,
  2978. &powTestExpInf1, &powTestExpInf2, &powTestExpInf3,
  2979. &powTestBaseInf1, &powTestBaseInf2,
  2980. &powTestNan1, &powTestNan2, &powTestNan3, &powTestNan4,
  2981. &powTestZero1, &powTestZero2, &powTestZero3, &powTestZero4,
  2982. &powTestRegular, &powTestPowOf2, &powTestRange,
  2983. &sqrtTestInf, &sqrtTestNan, &sqrtTestDomain,
  2984. &sqrtTestBase, &sqrtTestRegular,
  2985. &scalbnTestInf, &scalbnTestBaseZero, &scalbnTestExpZero,
  2986. &scalbnTestNan, &scalbnTestRegular,
  2987. &cosTestInf, &cosTestNan, &cosTestRegular,
  2988. &cosTestPrecision, &cosTestRange,
  2989. &sinTestInf, &sinTestNan, &sinTestRegular,
  2990. &sinTestPrecision, &sinTestRange,
  2991. &tanTestInf, &tanTestNan, &tanTestZero, &tanTestPrecision,
  2992. &acosTestLimit, &acosTestOutOfDomain, &acosTestNan, &acosTestPrecision,
  2993. &asinTestLimit, &asinTestOutOfDomain, &asinTestNan, &asinTestPrecision,
  2994. &atanTestLimit, &atanTestZero, &atanTestNan, &atanTestPrecision,
  2995. &atan2TestZero1, &atan2TestZero2, &atan2TestZero3,
  2996. &atan2TestInf1, &atan2TestInf2, &atan2TestInf3,
  2997. &atan2TestNan, &atan2TestQuadrantTopRight, &atan2TestQuadrantTopLeft,
  2998. &atan2TestQuadrantBottomRight, &atan2TestQuadrantBottomLeft,
  2999. NULL
  3000. };
  3001. SDLTest_TestSuiteReference mathTestSuite = {
  3002. "Math",
  3003. NULL,
  3004. mathTests,
  3005. NULL
  3006. };