core_func_common.cpp 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572
  1. ///////////////////////////////////////////////////////////////////////////////////////////////////
  2. // OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
  3. ///////////////////////////////////////////////////////////////////////////////////////////////////
  4. // Created : 2011-01-15
  5. // Updated : 2011-09-13
  6. // Licence : This source is under MIT licence
  7. // File : test/core/func_common.cpp
  8. ///////////////////////////////////////////////////////////////////////////////////////////////////
  9. //#include <boost/array.hpp>
  10. //#include <boost/date_time/posix_time/posix_time.hpp>
  11. //#include <boost/thread/thread.hpp>
  12. #include <glm/glm.hpp>
  13. #include <glm/gtc/constants.hpp>
  14. #include <glm/gtc/epsilon.hpp>
  15. #include <cstdio>
  16. int test_modf()
  17. {
  18. int Error(0);
  19. {
  20. float X(1.5f);
  21. float I(0.0f);
  22. float A = glm::modf(X, I);
  23. Error += I == 1.0f ? 0 : 1;
  24. Error += A == 0.5f ? 0 : 1;
  25. }
  26. {
  27. glm::vec4 X(1.1f, 1.2f, 1.5f, 1.7f);
  28. glm::vec4 I(0.0f);
  29. glm::vec4 A = glm::modf(X, I);
  30. Error += I == glm::vec4(1.0f) ? 0 : 1;
  31. Error += glm::all(glm::epsilonEqual(A, glm::vec4(0.1f, 0.2f, 0.5f, 0.7f), 0.00001f)) ? 0 : 1;
  32. }
  33. {
  34. glm::dvec4 X(1.1, 1.2, 1.5, 1.7);
  35. glm::dvec4 I(0.0);
  36. glm::dvec4 A = glm::modf(X, I);
  37. Error += I == glm::dvec4(1.0) ? 0 : 1;
  38. Error += glm::all(glm::epsilonEqual(A, glm::dvec4(0.1, 0.2, 0.5, 0.7), 0.000000001)) ? 0 : 1;
  39. }
  40. {
  41. double X(1.5);
  42. double I(0.0);
  43. double A = glm::modf(X, I);
  44. Error += I == 1.0 ? 0 : 1;
  45. Error += A == 0.5 ? 0 : 1;
  46. }
  47. return Error;
  48. }
  49. int test_floatBitsToInt()
  50. {
  51. int Error = 0;
  52. {
  53. float A = 1.0f;
  54. int B = glm::floatBitsToInt(A);
  55. float C = glm::intBitsToFloat(B);
  56. int D = *(int*)&A;
  57. Error += B == D ? 0 : 1;
  58. Error += A == C ? 0 : 1;
  59. }
  60. {
  61. glm::vec2 A(1.0f, 2.0f);
  62. glm::ivec2 B = glm::floatBitsToInt(A);
  63. glm::vec2 C = glm::intBitsToFloat(B);
  64. Error += B.x == *(int*)&(A.x) ? 0 : 1;
  65. Error += B.y == *(int*)&(A.y) ? 0 : 1;
  66. Error += A == C? 0 : 1;
  67. }
  68. {
  69. glm::vec3 A(1.0f, 2.0f, 3.0f);
  70. glm::ivec3 B = glm::floatBitsToInt(A);
  71. glm::vec3 C = glm::intBitsToFloat(B);
  72. Error += B.x == *(int*)&(A.x) ? 0 : 1;
  73. Error += B.y == *(int*)&(A.y) ? 0 : 1;
  74. Error += B.z == *(int*)&(A.z) ? 0 : 1;
  75. Error += A == C? 0 : 1;
  76. }
  77. {
  78. glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
  79. glm::ivec4 B = glm::floatBitsToInt(A);
  80. glm::vec4 C = glm::intBitsToFloat(B);
  81. Error += B.x == *(int*)&(A.x) ? 0 : 1;
  82. Error += B.y == *(int*)&(A.y) ? 0 : 1;
  83. Error += B.z == *(int*)&(A.z) ? 0 : 1;
  84. Error += B.w == *(int*)&(A.w) ? 0 : 1;
  85. Error += A == C? 0 : 1;
  86. }
  87. return Error;
  88. }
  89. int test_floatBitsToUint()
  90. {
  91. int Error = 0;
  92. {
  93. float A = 1.0f;
  94. glm::uint B = glm::floatBitsToUint(A);
  95. float C = glm::intBitsToFloat(B);
  96. Error += B == *(glm::uint*)&A ? 0 : 1;
  97. Error += A == C? 0 : 1;
  98. }
  99. {
  100. glm::vec2 A(1.0f, 2.0f);
  101. glm::uvec2 B = glm::floatBitsToUint(A);
  102. glm::vec2 C = glm::uintBitsToFloat(B);
  103. Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
  104. Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
  105. Error += A == C ? 0 : 1;
  106. }
  107. {
  108. glm::vec3 A(1.0f, 2.0f, 3.0f);
  109. glm::uvec3 B = glm::floatBitsToUint(A);
  110. glm::vec3 C = glm::uintBitsToFloat(B);
  111. Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
  112. Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
  113. Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
  114. Error += A == C? 0 : 1;
  115. }
  116. {
  117. glm::vec4 A(1.0f, 2.0f, 3.0f, 4.0f);
  118. glm::uvec4 B = glm::floatBitsToUint(A);
  119. glm::vec4 C = glm::uintBitsToFloat(B);
  120. Error += B.x == *(glm::uint*)&(A.x) ? 0 : 1;
  121. Error += B.y == *(glm::uint*)&(A.y) ? 0 : 1;
  122. Error += B.z == *(glm::uint*)&(A.z) ? 0 : 1;
  123. Error += B.w == *(glm::uint*)&(A.w) ? 0 : 1;
  124. Error += A == C? 0 : 1;
  125. }
  126. return Error;
  127. }
  128. namespace test_mix
  129. {
  130. template <typename T, typename B>
  131. struct test
  132. {
  133. T x;
  134. T y;
  135. B a;
  136. T Result;
  137. };
  138. test<float, bool> TestBool[] =
  139. {
  140. {0.0f, 1.0f, false, 0.0f},
  141. {0.0f, 1.0f, true, 1.0f},
  142. {-1.0f, 1.0f, false, -1.0f},
  143. {-1.0f, 1.0f, true, 1.0f}
  144. };
  145. test<float, float> TestFloat[] =
  146. {
  147. {0.0f, 1.0f, 0.0f, 0.0f},
  148. {0.0f, 1.0f, 1.0f, 1.0f},
  149. {-1.0f, 1.0f, 0.0f, -1.0f},
  150. {-1.0f, 1.0f, 1.0f, 1.0f}
  151. };
  152. test<glm::vec2, bool> TestVec2Bool[] =
  153. {
  154. {glm::vec2(0.0f), glm::vec2(1.0f), false, glm::vec2(0.0f)},
  155. {glm::vec2(0.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)},
  156. {glm::vec2(-1.0f), glm::vec2(1.0f), false, glm::vec2(-1.0f)},
  157. {glm::vec2(-1.0f), glm::vec2(1.0f), true, glm::vec2(1.0f)}
  158. };
  159. test<glm::vec2, glm::bvec2> TestBVec2[] =
  160. {
  161. {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(0.0f)},
  162. {glm::vec2(0.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)},
  163. {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(false), glm::vec2(-1.0f)},
  164. {glm::vec2(-1.0f), glm::vec2(1.0f), glm::bvec2(true), glm::vec2(1.0f)}
  165. };
  166. test<glm::vec3, bool> TestVec3Bool[] =
  167. {
  168. {glm::vec3(0.0f), glm::vec3(1.0f), false, glm::vec3(0.0f)},
  169. {glm::vec3(0.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)},
  170. {glm::vec3(-1.0f), glm::vec3(1.0f), false, glm::vec3(-1.0f)},
  171. {glm::vec3(-1.0f), glm::vec3(1.0f), true, glm::vec3(1.0f)}
  172. };
  173. test<glm::vec3, glm::bvec3> TestBVec3[] =
  174. {
  175. {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(0.0f)},
  176. {glm::vec3(0.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)},
  177. {glm::vec3(-1.0f), glm::vec3(1.0f), glm::bvec3(false), glm::vec3(-1.0f)},
  178. {glm::vec3(-1.0f), glm::vec3(1.0f), glm::bvec3(true), glm::vec3(1.0f)}
  179. };
  180. test<glm::vec4, bool> TestVec4Bool[] =
  181. {
  182. {glm::vec4(0.0f), glm::vec4(1.0f), false, glm::vec4(0.0f)},
  183. {glm::vec4(0.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)},
  184. {glm::vec4(-1.0f), glm::vec4(1.0f), false, glm::vec4(-1.0f)},
  185. {glm::vec4(-1.0f), glm::vec4(1.0f), true, glm::vec4(1.0f)}
  186. };
  187. test<glm::vec4, glm::bvec4> TestBVec4[] =
  188. {
  189. {glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(false), glm::vec4(0.0f)},
  190. {glm::vec4(0.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)},
  191. {glm::vec4(-1.0f), glm::vec4(1.0f), glm::bvec4(false), glm::vec4(-1.0f)},
  192. {glm::vec4(-1.0f), glm::vec4(1.0f), glm::bvec4(true), glm::vec4(1.0f)}
  193. };
  194. int run()
  195. {
  196. int Error = 0;
  197. // Float with bool
  198. {
  199. for(std::size_t i = 0; i < sizeof(TestBool) / sizeof(test<float, bool>); ++i)
  200. {
  201. float Result = glm::mix(TestBool[i].x, TestBool[i].y, TestBool[i].a);
  202. Error += glm::epsilonEqual(Result, TestBool[i].Result, glm::epsilon<float>()) ? 0 : 1;
  203. }
  204. }
  205. // Float with float
  206. {
  207. for(std::size_t i = 0; i < sizeof(TestFloat) / sizeof(test<float, float>); ++i)
  208. {
  209. float Result = glm::mix(TestFloat[i].x, TestFloat[i].y, TestFloat[i].a);
  210. Error += glm::epsilonEqual(Result, TestFloat[i].Result, glm::epsilon<float>()) ? 0 : 1;
  211. }
  212. }
  213. // vec2 with bool
  214. {
  215. for(std::size_t i = 0; i < sizeof(TestVec2Bool) / sizeof(test<glm::vec2, bool>); ++i)
  216. {
  217. glm::vec2 Result = glm::mix(TestVec2Bool[i].x, TestVec2Bool[i].y, TestVec2Bool[i].a);
  218. Error += glm::epsilonEqual(Result.x, TestVec2Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  219. Error += glm::epsilonEqual(Result.y, TestVec2Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  220. }
  221. }
  222. // vec2 with bvec2
  223. {
  224. for(std::size_t i = 0; i < sizeof(TestBVec2) / sizeof(test<glm::vec2, glm::bvec2>); ++i)
  225. {
  226. glm::vec2 Result = glm::mix(TestBVec2[i].x, TestBVec2[i].y, TestBVec2[i].a);
  227. Error += glm::epsilonEqual(Result.x, TestBVec2[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  228. Error += glm::epsilonEqual(Result.y, TestBVec2[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  229. }
  230. }
  231. // vec3 with bool
  232. {
  233. for(std::size_t i = 0; i < sizeof(TestVec3Bool) / sizeof(test<glm::vec3, bool>); ++i)
  234. {
  235. glm::vec3 Result = glm::mix(TestVec3Bool[i].x, TestVec3Bool[i].y, TestVec3Bool[i].a);
  236. Error += glm::epsilonEqual(Result.x, TestVec3Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  237. Error += glm::epsilonEqual(Result.y, TestVec3Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  238. Error += glm::epsilonEqual(Result.z, TestVec3Bool[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
  239. }
  240. }
  241. // vec3 with bvec3
  242. {
  243. for(std::size_t i = 0; i < sizeof(TestBVec3) / sizeof(test<glm::vec3, glm::bvec3>); ++i)
  244. {
  245. glm::vec3 Result = glm::mix(TestBVec3[i].x, TestBVec3[i].y, TestBVec3[i].a);
  246. Error += glm::epsilonEqual(Result.x, TestBVec3[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  247. Error += glm::epsilonEqual(Result.y, TestBVec3[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  248. Error += glm::epsilonEqual(Result.z, TestBVec3[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
  249. }
  250. }
  251. // vec4 with bool
  252. {
  253. for(std::size_t i = 0; i < sizeof(TestVec4Bool) / sizeof(test<glm::vec4, bool>); ++i)
  254. {
  255. glm::vec3 Result = glm::mix(TestVec4Bool[i].x, TestVec4Bool[i].y, TestVec4Bool[i].a);
  256. Error += glm::epsilonEqual(Result.x, TestVec4Bool[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  257. Error += glm::epsilonEqual(Result.y, TestVec4Bool[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  258. Error += glm::epsilonEqual(Result.z, TestVec4Bool[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
  259. Error += glm::epsilonEqual(Result.w, TestVec4Bool[i].Result.w, glm::epsilon<float>()) ? 0 : 1;
  260. }
  261. }
  262. // vec4 with bvec4
  263. {
  264. for(std::size_t i = 0; i < sizeof(TestBVec4) / sizeof(test<glm::vec4, glm::bvec4>); ++i)
  265. {
  266. glm::vec4 Result = glm::mix(TestBVec4[i].x, TestBVec4[i].y, TestBVec4[i].a);
  267. Error += glm::epsilonEqual(Result.x, TestBVec3[i].Result.x, glm::epsilon<float>()) ? 0 : 1;
  268. Error += glm::epsilonEqual(Result.y, TestBVec3[i].Result.y, glm::epsilon<float>()) ? 0 : 1;
  269. Error += glm::epsilonEqual(Result.z, TestBVec3[i].Result.z, glm::epsilon<float>()) ? 0 : 1;
  270. Error += glm::epsilonEqual(Result.w, TestBVec3[i].Result.w, glm::epsilon<float>()) ? 0 : 1;
  271. }
  272. }
  273. return Error;
  274. }
  275. }//namespace test_mix
  276. int test_round()
  277. {
  278. int Error = 0;
  279. {
  280. float A = glm::round(0.0f);
  281. Error += A == 0.0f ? 0 : 1;
  282. float B = glm::round(0.5f);
  283. Error += B == 1.0f ? 0 : 1;
  284. float C = glm::round(1.0f);
  285. Error += C == 1.0f ? 0 : 1;
  286. float D = glm::round(0.1f);
  287. Error += D == 0.0f ? 0 : 1;
  288. float E = glm::round(0.9f);
  289. Error += E == 1.0f ? 0 : 1;
  290. float F = glm::round(1.5f);
  291. Error += F == 2.0f ? 0 : 1;
  292. float G = glm::round(1.9f);
  293. Error += G == 2.0f ? 0 : 1;
  294. }
  295. {
  296. float A = glm::round(-0.0f);
  297. Error += A == 0.0f ? 0 : 1;
  298. float B = glm::round(-0.5f);
  299. Error += B == -1.0f ? 0 : 1;
  300. float C = glm::round(-1.0f);
  301. Error += C == -1.0f ? 0 : 1;
  302. float D = glm::round(-0.1f);
  303. Error += D == 0.0f ? 0 : 1;
  304. float E = glm::round(-0.9f);
  305. Error += E == -1.0f ? 0 : 1;
  306. float F = glm::round(-1.5f);
  307. Error += F == -2.0f ? 0 : 1;
  308. float G = glm::round(-1.9f);
  309. Error += G == -2.0f ? 0 : 1;
  310. }
  311. return Error;
  312. }
  313. int test_roundEven()
  314. {
  315. int Error = 0;
  316. {
  317. float A = glm::roundEven(-1.5f);
  318. Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
  319. Error += 0;
  320. }
  321. {
  322. float A = glm::roundEven(1.5f);
  323. Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
  324. Error += 0;
  325. }
  326. {
  327. float A = glm::roundEven(-3.5f);
  328. Error += glm::epsilonEqual(A, -4.0f, 0.0001f) ? 0 : 1;
  329. Error += 0;
  330. }
  331. {
  332. float A = glm::roundEven(3.5f);
  333. Error += glm::epsilonEqual(A, 4.0f, 0.0001f) ? 0 : 1;
  334. Error += 0;
  335. }
  336. {
  337. float A = glm::roundEven(-2.5f);
  338. Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
  339. Error += 0;
  340. }
  341. {
  342. float A = glm::roundEven(2.5f);
  343. Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
  344. Error += 0;
  345. }
  346. {
  347. float A = glm::roundEven(-2.4f);
  348. Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
  349. Error += 0;
  350. }
  351. {
  352. float A = glm::roundEven(2.4f);
  353. Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
  354. Error += 0;
  355. }
  356. {
  357. float A = glm::roundEven(-2.6f);
  358. Error += glm::epsilonEqual(A, -3.0f, 0.0001f) ? 0 : 1;
  359. Error += 0;
  360. }
  361. {
  362. float A = glm::roundEven(2.6f);
  363. Error += glm::epsilonEqual(A, 3.0f, 0.0001f) ? 0 : 1;
  364. Error += 0;
  365. }
  366. {
  367. float A = glm::roundEven(-2.0f);
  368. Error += glm::epsilonEqual(A, -2.0f, 0.0001f) ? 0 : 1;
  369. Error += 0;
  370. }
  371. {
  372. float A = glm::roundEven(2.0f);
  373. Error += glm::epsilonEqual(A, 2.0f, 0.0001f) ? 0 : 1;
  374. Error += 0;
  375. }
  376. {
  377. float A = glm::roundEven(0.0f);
  378. Error += A == 0.0f ? 0 : 1;
  379. float B = glm::roundEven(0.5f);
  380. Error += B == 0.0f ? 0 : 1;
  381. float C = glm::roundEven(1.0f);
  382. Error += C == 1.0f ? 0 : 1;
  383. float D = glm::roundEven(0.1f);
  384. Error += D == 0.0f ? 0 : 1;
  385. float E = glm::roundEven(0.9f);
  386. Error += E == 1.0f ? 0 : 1;
  387. float F = glm::roundEven(1.5f);
  388. Error += F == 2.0f ? 0 : 1;
  389. float G = glm::roundEven(1.9f);
  390. Error += G == 2.0f ? 0 : 1;
  391. }
  392. {
  393. float A = glm::roundEven(-0.0f);
  394. Error += A == 0.0f ? 0 : 1;
  395. float B = glm::roundEven(-0.5f);
  396. Error += B == -0.0f ? 0 : 1;
  397. float C = glm::roundEven(-1.0f);
  398. Error += C == -1.0f ? 0 : 1;
  399. float D = glm::roundEven(-0.1f);
  400. Error += D == 0.0f ? 0 : 1;
  401. float E = glm::roundEven(-0.9f);
  402. Error += E == -1.0f ? 0 : 1;
  403. float F = glm::roundEven(-1.5f);
  404. Error += F == -2.0f ? 0 : 1;
  405. float G = glm::roundEven(-1.9f);
  406. Error += G == -2.0f ? 0 : 1;
  407. }
  408. {
  409. float A = glm::roundEven(1.5f);
  410. Error += A == 2.0f ? 0 : 1;
  411. float B = glm::roundEven(2.5f);
  412. Error += B == 2.0f ? 0 : 1;
  413. float C = glm::roundEven(3.5f);
  414. Error += C == 4.0f ? 0 : 1;
  415. float D = glm::roundEven(4.5f);
  416. Error += D == 4.0f ? 0 : 1;
  417. float E = glm::roundEven(5.5f);
  418. Error += E == 6.0f ? 0 : 1;
  419. float F = glm::roundEven(6.5f);
  420. Error += F == 6.0f ? 0 : 1;
  421. float G = glm::roundEven(7.5f);
  422. Error += G == 8.0f ? 0 : 1;
  423. }
  424. {
  425. float A = glm::roundEven(-1.5f);
  426. Error += A == -2.0f ? 0 : 1;
  427. float B = glm::roundEven(-2.5f);
  428. Error += B == -2.0f ? 0 : 1;
  429. float C = glm::roundEven(-3.5f);
  430. Error += C == -4.0f ? 0 : 1;
  431. float D = glm::roundEven(-4.5f);
  432. Error += D == -4.0f ? 0 : 1;
  433. float E = glm::roundEven(-5.5f);
  434. Error += E == -6.0f ? 0 : 1;
  435. float F = glm::roundEven(-6.5f);
  436. Error += F == -6.0f ? 0 : 1;
  437. float G = glm::roundEven(-7.5f);
  438. Error += G == -8.0f ? 0 : 1;
  439. }
  440. return Error;
  441. }
  442. int test_isnan()
  443. {
  444. int Error = 0;
  445. float Zero_f = 0.0;
  446. double Zero_d = 0.0;
  447. {
  448. Error += true == glm::isnan(0.0/Zero_d) ? 0 : 1;
  449. Error += true == glm::any(glm::isnan(glm::dvec2(0.0 / Zero_d))) ? 0 : 1;
  450. Error += true == glm::any(glm::isnan(glm::dvec3(0.0 / Zero_d))) ? 0 : 1;
  451. Error += true == glm::any(glm::isnan(glm::dvec4(0.0 / Zero_d))) ? 0 : 1;
  452. }
  453. {
  454. Error += true == glm::isnan(0.0f/Zero_f) ? 0 : 1;
  455. Error += true == glm::any(glm::isnan(glm::vec2(0.0f/Zero_f))) ? 0 : 1;
  456. Error += true == glm::any(glm::isnan(glm::vec3(0.0f/Zero_f))) ? 0 : 1;
  457. Error += true == glm::any(glm::isnan(glm::vec4(0.0f/Zero_f))) ? 0 : 1;
  458. }
  459. return Error;
  460. }
  461. int test_isinf()
  462. {
  463. int Error = 0;
  464. float Zero_f = 0.0;
  465. double Zero_d = 0.0;
  466. {
  467. Error += true == glm::isinf( 1.0/Zero_d) ? 0 : 1;
  468. Error += true == glm::isinf(-1.0/Zero_d) ? 0 : 1;
  469. Error += true == glm::any(glm::isinf(glm::dvec2( 1.0/Zero_d))) ? 0 : 1;
  470. Error += true == glm::any(glm::isinf(glm::dvec2(-1.0/Zero_d))) ? 0 : 1;
  471. Error += true == glm::any(glm::isinf(glm::dvec3( 1.0/Zero_d))) ? 0 : 1;
  472. Error += true == glm::any(glm::isinf(glm::dvec3(-1.0/Zero_d))) ? 0 : 1;
  473. Error += true == glm::any(glm::isinf(glm::dvec4( 1.0/Zero_d))) ? 0 : 1;
  474. Error += true == glm::any(glm::isinf(glm::dvec4(-1.0/Zero_d))) ? 0 : 1;
  475. }
  476. {
  477. Error += true == glm::isinf( 1.0f/Zero_f) ? 0 : 1;
  478. Error += true == glm::isinf(-1.0f/Zero_f) ? 0 : 1;
  479. Error += true == glm::any(glm::isinf(glm::vec2( 1.0f/Zero_f))) ? 0 : 1;
  480. Error += true == glm::any(glm::isinf(glm::vec2(-1.0f/Zero_f))) ? 0 : 1;
  481. Error += true == glm::any(glm::isinf(glm::vec3( 1.0f/Zero_f))) ? 0 : 1;
  482. Error += true == glm::any(glm::isinf(glm::vec3(-1.0f/Zero_f))) ? 0 : 1;
  483. Error += true == glm::any(glm::isinf(glm::vec4( 1.0f/Zero_f))) ? 0 : 1;
  484. Error += true == glm::any(glm::isinf(glm::vec4(-1.0f/Zero_f))) ? 0 : 1;
  485. }
  486. return Error;
  487. }
  488. int main()
  489. {
  490. int Error(0);
  491. Error += test_modf();
  492. Error += test_floatBitsToInt();
  493. Error += test_floatBitsToUint();
  494. Error += test_mix::run();
  495. Error += test_round();
  496. Error += test_roundEven();
  497. Error += test_isnan();
  498. //Error += test_isinf();
  499. return Error;
  500. }