ext_vector_bool1.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #include <glm/ext/vector_bool1.hpp>
  2. #include <glm/ext/vector_bool1_precision.hpp>
  3. template <typename genType>
  4. static int test_operators()
  5. {
  6. int Error = 0;
  7. genType const A(true);
  8. genType const B(true);
  9. {
  10. bool const R = A != B;
  11. bool const S = A == B;
  12. Error += (S && !R) ? 0 : 1;
  13. }
  14. return Error;
  15. }
  16. template <typename genType>
  17. static int test_ctor()
  18. {
  19. int Error = 0;
  20. glm::bvec1 const A = genType(true);
  21. glm::bvec1 const E(genType(true));
  22. Error += A == E ? 0 : 1;
  23. glm::bvec1 const F(E);
  24. Error += A == F ? 0 : 1;
  25. return Error;
  26. }
  27. template <typename genType>
  28. static int test_size()
  29. {
  30. int Error = 0;
  31. Error += sizeof(glm::bvec1) == sizeof(genType) ? 0 : 1;
  32. Error += genType().length() == 1 ? 0 : 1;
  33. Error += genType::length() == 1 ? 0 : 1;
  34. return Error;
  35. }
  36. template <typename genType>
  37. static int test_relational()
  38. {
  39. int Error = 0;
  40. genType const A(true);
  41. genType const B(true);
  42. genType const C(false);
  43. Error += A == B ? 0 : 1;
  44. Error += (A && B) == A ? 0 : 1;
  45. Error += (A || C) == A ? 0 : 1;
  46. return Error;
  47. }
  48. template <typename genType>
  49. static int test_constexpr()
  50. {
  51. static_assert(genType::length() == 1, "GLM: Failed constexpr");
  52. return 0;
  53. }
  54. int main()
  55. {
  56. int Error = 0;
  57. Error += test_operators<glm::bvec1>();
  58. Error += test_operators<glm::lowp_bvec1>();
  59. Error += test_operators<glm::mediump_bvec1>();
  60. Error += test_operators<glm::highp_bvec1>();
  61. Error += test_ctor<glm::bvec1>();
  62. Error += test_ctor<glm::lowp_bvec1>();
  63. Error += test_ctor<glm::mediump_bvec1>();
  64. Error += test_ctor<glm::highp_bvec1>();
  65. Error += test_size<glm::bvec1>();
  66. Error += test_size<glm::lowp_bvec1>();
  67. Error += test_size<glm::mediump_bvec1>();
  68. Error += test_size<glm::highp_bvec1>();
  69. Error += test_relational<glm::bvec1>();
  70. Error += test_relational<glm::lowp_bvec1>();
  71. Error += test_relational<glm::mediump_bvec1>();
  72. Error += test_relational<glm::highp_bvec1>();
  73. Error += test_constexpr<glm::bvec1>();
  74. Error += test_constexpr<glm::lowp_bvec1>();
  75. Error += test_constexpr<glm::mediump_bvec1>();
  76. Error += test_constexpr<glm::highp_bvec1>();
  77. return Error;
  78. }