2
0

ext_vector_float1.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #include <glm/gtc/constants.hpp>
  2. #include <glm/ext/vector_relational.hpp>
  3. #include <glm/ext/vector_float1.hpp>
  4. #include <glm/ext/vector_float1_precision.hpp>
  5. #include <glm/ext/vector_float2.hpp>
  6. #include <glm/ext/vector_float3.hpp>
  7. #include <glm/ext/vector_float4.hpp>
  8. template <typename genType>
  9. static int test_operators()
  10. {
  11. int Error = 0;
  12. {
  13. genType const A(1);
  14. genType const B(1);
  15. genType const C = A + B;
  16. Error += glm::all(glm::equal(C, genType(2), glm::epsilon<float>())) ? 0 : 1;
  17. genType const D = A - B;
  18. Error += glm::all(glm::equal(D, genType(0), glm::epsilon<float>())) ? 0 : 1;
  19. genType const E = A * B;
  20. Error += glm::all(glm::equal(E, genType(1), glm::epsilon<float>())) ? 0 : 1;
  21. genType const F = A / B;
  22. Error += glm::all(glm::equal(F, genType(1), glm::epsilon<float>())) ? 0 : 1;
  23. }
  24. return Error;
  25. }
  26. template <typename genType>
  27. static int test_ctor()
  28. {
  29. int Error = 0;
  30. glm::vec1 const A = genType(1);
  31. glm::vec1 const E(genType(1));
  32. Error += glm::all(glm::equal(A, E, glm::epsilon<float>())) ? 0 : 1;
  33. glm::vec1 const F(E);
  34. Error += glm::all(glm::equal(A, F, glm::epsilon<float>())) ? 0 : 1;
  35. genType const B = genType(1);
  36. genType const G(glm::vec2(1));
  37. Error += glm::all(glm::equal(B, G, glm::epsilon<float>())) ? 0 : 1;
  38. genType const H(glm::vec3(1));
  39. Error += glm::all(glm::equal(B, H, glm::epsilon<float>())) ? 0 : 1;
  40. genType const I(glm::vec4(1));
  41. Error += glm::all(glm::equal(B, I, glm::epsilon<float>())) ? 0 : 1;
  42. return Error;
  43. }
  44. template <typename genType>
  45. static int test_size()
  46. {
  47. int Error = 0;
  48. Error += sizeof(glm::vec1) == sizeof(genType) ? 0 : 1;
  49. Error += genType().length() == 1 ? 0 : 1;
  50. Error += genType::length() == 1 ? 0 : 1;
  51. return Error;
  52. }
  53. template <typename genType>
  54. static int test_relational()
  55. {
  56. int Error = 0;
  57. genType const A(1);
  58. genType const B(1);
  59. genType const C(0);
  60. Error += all(equal(A, B, glm::epsilon<float>())) ? 0 : 1;
  61. Error += any(notEqual(A, C, glm::epsilon<float>())) ? 0 : 1;
  62. return Error;
  63. }
  64. template <typename genType>
  65. static int test_constexpr()
  66. {
  67. # if GLM_CONFIG_CONSTEXP == GLM_ENABLE
  68. static_assert(genType::length() == 1, "GLM: Failed constexpr");
  69. # endif
  70. return 0;
  71. }
  72. int main()
  73. {
  74. int Error = 0;
  75. Error += test_operators<glm::vec1>();
  76. Error += test_operators<glm::lowp_vec1>();
  77. Error += test_operators<glm::mediump_vec1>();
  78. Error += test_operators<glm::highp_vec1>();
  79. Error += test_ctor<glm::vec1>();
  80. Error += test_ctor<glm::lowp_vec1>();
  81. Error += test_ctor<glm::mediump_vec1>();
  82. Error += test_ctor<glm::highp_vec1>();
  83. Error += test_size<glm::vec1>();
  84. Error += test_size<glm::lowp_vec1>();
  85. Error += test_size<glm::mediump_vec1>();
  86. Error += test_size<glm::highp_vec1>();
  87. Error += test_relational<glm::vec1>();
  88. Error += test_relational<glm::lowp_vec1>();
  89. Error += test_relational<glm::mediump_vec1>();
  90. Error += test_relational<glm::highp_vec1>();
  91. Error += test_constexpr<glm::vec1>();
  92. Error += test_constexpr<glm::lowp_vec1>();
  93. Error += test_constexpr<glm::mediump_vec1>();
  94. Error += test_constexpr<glm::highp_vec1>();
  95. return Error;
  96. }