ext_vector_integer_sized.cpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #include <glm/ext/vector_integer.hpp>
  2. #include <glm/ext/vector_int1.hpp>
  3. #include <glm/ext/vector_int1_sized.hpp>
  4. #include <glm/ext/vector_uint1.hpp>
  5. #include <glm/ext/vector_uint1_sized.hpp>
  6. template <typename genType>
  7. static int test_operators()
  8. {
  9. int Error = 0;
  10. {
  11. genType const A(1);
  12. genType const B(1);
  13. bool const R = A != B;
  14. bool const S = A == B;
  15. Error += (S && !R) ? 0 : 1;
  16. }
  17. {
  18. genType const A(1);
  19. genType const B(1);
  20. genType const C = A + B;
  21. Error += C == genType(2) ? 0 : 1;
  22. genType const D = A - B;
  23. Error += D == genType(0) ? 0 : 1;
  24. genType const E = A * B;
  25. Error += E == genType(1) ? 0 : 1;
  26. genType const F = A / B;
  27. Error += F == genType(1) ? 0 : 1;
  28. }
  29. {
  30. genType const A(3);
  31. genType const B(2);
  32. genType const C = A % B;
  33. Error += C == genType(1) ? 0 : 1;
  34. }
  35. {
  36. genType const A(1);
  37. genType const B(1);
  38. genType const C(0);
  39. genType const I = A & B;
  40. Error += I == genType(1) ? 0 : 1;
  41. genType const D = A & C;
  42. Error += D == genType(0) ? 0 : 1;
  43. genType const E = A | B;
  44. Error += E == genType(1) ? 0 : 1;
  45. genType const F = A | C;
  46. Error += F == genType(1) ? 0 : 1;
  47. genType const G = A ^ B;
  48. Error += G == genType(0) ? 0 : 1;
  49. genType const H = A ^ C;
  50. Error += H == genType(1) ? 0 : 1;
  51. }
  52. {
  53. genType B(1);
  54. genType C(2);
  55. genType D = B << B;
  56. Error += D == genType(2) ? 0 : 1;
  57. genType E = C >> B;
  58. Error += E == genType(1) ? 0 : 1;
  59. }
  60. return Error;
  61. }
  62. template <typename genType>
  63. static int test_ctor()
  64. {
  65. typedef typename genType::value_type T;
  66. int Error = 0;
  67. genType const A = genType(1);
  68. genType const E(genType(1));
  69. Error += A == E ? 0 : 1;
  70. genType const F(E);
  71. Error += A == F ? 0 : 1;
  72. genType const B = genType(1);
  73. genType const G(glm::vec<2, T>(1));
  74. Error += B == G ? 0 : 1;
  75. genType const H(glm::vec<3, T>(1));
  76. Error += B == H ? 0 : 1;
  77. genType const I(glm::vec<4, T>(1));
  78. Error += B == I ? 0 : 1;
  79. return Error;
  80. }
  81. template <typename genType>
  82. static int test_size()
  83. {
  84. int Error = 0;
  85. Error += sizeof(typename genType::value_type) == sizeof(genType) ? 0 : 1;
  86. Error += genType().length() == 1 ? 0 : 1;
  87. Error += genType::length() == 1 ? 0 : 1;
  88. return Error;
  89. }
  90. template <typename genType>
  91. static int test_relational()
  92. {
  93. int Error = 0;
  94. genType const A(1);
  95. genType const B(1);
  96. genType const C(0);
  97. Error += A == B ? 0 : 1;
  98. Error += A != C ? 0 : 1;
  99. Error += all(equal(A, B)) ? 0 : 1;
  100. Error += any(notEqual(A, C)) ? 0 : 1;
  101. return Error;
  102. }
  103. int main()
  104. {
  105. int Error = 0;
  106. Error += test_operators<glm::ivec1>();
  107. Error += test_operators<glm::i8vec1>();
  108. Error += test_operators<glm::i16vec1>();
  109. Error += test_operators<glm::i32vec1>();
  110. Error += test_operators<glm::i64vec1>();
  111. Error += test_ctor<glm::ivec1>();
  112. Error += test_ctor<glm::i8vec1>();
  113. Error += test_ctor<glm::i16vec1>();
  114. Error += test_ctor<glm::i32vec1>();
  115. Error += test_ctor<glm::i64vec1>();
  116. Error += test_size<glm::ivec1>();
  117. Error += test_size<glm::i8vec1>();
  118. Error += test_size<glm::i16vec1>();
  119. Error += test_size<glm::i32vec1>();
  120. Error += test_size<glm::i64vec1>();
  121. Error += test_relational<glm::ivec1>();
  122. Error += test_relational<glm::i8vec1>();
  123. Error += test_relational<glm::i16vec1>();
  124. Error += test_relational<glm::i32vec1>();
  125. Error += test_relational<glm::i64vec1>();
  126. Error += test_operators<glm::uvec1>();
  127. Error += test_operators<glm::u8vec1>();
  128. Error += test_operators<glm::u16vec1>();
  129. Error += test_operators<glm::u32vec1>();
  130. Error += test_operators<glm::u64vec1>();
  131. Error += test_ctor<glm::uvec1>();
  132. Error += test_ctor<glm::u8vec1>();
  133. Error += test_ctor<glm::u16vec1>();
  134. Error += test_ctor<glm::u32vec1>();
  135. Error += test_ctor<glm::u64vec1>();
  136. Error += test_size<glm::uvec1>();
  137. Error += test_size<glm::u8vec1>();
  138. Error += test_size<glm::u16vec1>();
  139. Error += test_size<glm::u32vec1>();
  140. Error += test_size<glm::u64vec1>();
  141. Error += test_relational<glm::uvec1>();
  142. Error += test_relational<glm::u8vec1>();
  143. Error += test_relational<glm::u16vec1>();
  144. Error += test_relational<glm::u32vec1>();
  145. Error += test_relational<glm::u64vec1>();
  146. return Error;
  147. }