Platformer in OpenGL
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

154 lines
4.0 KiB

5 years ago
  1. #define GLM_ENABLE_EXPERIMENTAL
  2. #include <glm/glm.hpp>
  3. #include <glm/gtx/string_cast.hpp>
  4. #include <limits>
  5. int test_string_cast_vector()
  6. {
  7. int Error = 0;
  8. {
  9. glm::vec2 A1(1, 2);
  10. std::string A2 = glm::to_string(A1);
  11. Error += A2 != std::string("vec2(1.000000, 2.000000)") ? 1 : 0;
  12. glm::vec3 B1(1, 2, 3);
  13. std::string B2 = glm::to_string(B1);
  14. Error += B2 != std::string("vec3(1.000000, 2.000000, 3.000000)") ? 1 : 0;
  15. glm::vec4 C1(1, 2, 3, 4);
  16. std::string C2 = glm::to_string(C1);
  17. Error += C2 != std::string("vec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0;
  18. glm::dvec2 J1(1, 2);
  19. std::string J2 = glm::to_string(J1);
  20. Error += J2 != std::string("dvec2(1.000000, 2.000000)") ? 1 : 0;
  21. glm::dvec3 K1(1, 2, 3);
  22. std::string K2 = glm::to_string(K1);
  23. Error += K2 != std::string("dvec3(1.000000, 2.000000, 3.000000)") ? 1 : 0;
  24. glm::dvec4 L1(1, 2, 3, 4);
  25. std::string L2 = glm::to_string(L1);
  26. Error += L2 != std::string("dvec4(1.000000, 2.000000, 3.000000, 4.000000)") ? 1 : 0;
  27. }
  28. {
  29. glm::bvec2 M1(false, true);
  30. std::string M2 = glm::to_string(M1);
  31. Error += M2 != std::string("bvec2(false, true)") ? 1 : 0;
  32. glm::bvec3 O1(false, true, false);
  33. std::string O2 = glm::to_string(O1);
  34. Error += O2 != std::string("bvec3(false, true, false)") ? 1 : 0;
  35. glm::bvec4 P1(false, true, false, true);
  36. std::string P2 = glm::to_string(P1);
  37. Error += P2 != std::string("bvec4(false, true, false, true)") ? 1 : 0;
  38. }
  39. {
  40. glm::ivec2 D1(1, 2);
  41. std::string D2 = glm::to_string(D1);
  42. Error += D2 != std::string("ivec2(1, 2)") ? 1 : 0;
  43. glm::ivec3 E1(1, 2, 3);
  44. std::string E2 = glm::to_string(E1);
  45. Error += E2 != std::string("ivec3(1, 2, 3)") ? 1 : 0;
  46. glm::ivec4 F1(1, 2, 3, 4);
  47. std::string F2 = glm::to_string(F1);
  48. Error += F2 != std::string("ivec4(1, 2, 3, 4)") ? 1 : 0;
  49. }
  50. {
  51. glm::i8vec2 D1(1, 2);
  52. std::string D2 = glm::to_string(D1);
  53. Error += D2 != std::string("i8vec2(1, 2)") ? 1 : 0;
  54. glm::i8vec3 E1(1, 2, 3);
  55. std::string E2 = glm::to_string(E1);
  56. Error += E2 != std::string("i8vec3(1, 2, 3)") ? 1 : 0;
  57. glm::i8vec4 F1(1, 2, 3, 4);
  58. std::string F2 = glm::to_string(F1);
  59. Error += F2 != std::string("i8vec4(1, 2, 3, 4)") ? 1 : 0;
  60. }
  61. {
  62. glm::i16vec2 D1(1, 2);
  63. std::string D2 = glm::to_string(D1);
  64. Error += D2 != std::string("i16vec2(1, 2)") ? 1 : 0;
  65. glm::i16vec3 E1(1, 2, 3);
  66. std::string E2 = glm::to_string(E1);
  67. Error += E2 != std::string("i16vec3(1, 2, 3)") ? 1 : 0;
  68. glm::i16vec4 F1(1, 2, 3, 4);
  69. std::string F2 = glm::to_string(F1);
  70. Error += F2 != std::string("i16vec4(1, 2, 3, 4)") ? 1 : 0;
  71. }
  72. {
  73. glm::i64vec2 D1(1, 2);
  74. std::string D2 = glm::to_string(D1);
  75. Error += D2 != std::string("i64vec2(1, 2)") ? 1 : 0;
  76. glm::i64vec3 E1(1, 2, 3);
  77. std::string E2 = glm::to_string(E1);
  78. Error += E2 != std::string("i64vec3(1, 2, 3)") ? 1 : 0;
  79. glm::i64vec4 F1(1, 2, 3, 4);
  80. std::string F2 = glm::to_string(F1);
  81. Error += F2 != std::string("i64vec4(1, 2, 3, 4)") ? 1 : 0;
  82. }
  83. return Error;
  84. }
  85. int test_string_cast_matrix()
  86. {
  87. int Error = 0;
  88. glm::mat2x2 A1(1.000000, 2.000000, 3.000000, 4.000000);
  89. std::string A2 = glm::to_string(A1);
  90. Error += A2 != std::string("mat2x2((1.000000, 2.000000), (3.000000, 4.000000))") ? 1 : 0;
  91. return Error;
  92. }
  93. int test_string_cast_quaternion()
  94. {
  95. int Error = 0;
  96. glm::quat Q0 = glm::quat(1.0f, 2.0f, 3.0f, 4.0f);
  97. std::string S0 = glm::to_string(Q0);
  98. Error += S0 != std::string("quat(1.000000, {2.000000, 3.000000, 4.000000})") ? 1 : 0;
  99. return Error;
  100. }
  101. int test_string_cast_dual_quaternion()
  102. {
  103. int Error = 0;
  104. glm::dualquat Q0 = glm::dualquat(glm::quat(1.0f, 2.0f, 3.0f, 4.0f), glm::quat(5.0f, 6.0f, 7.0f, 8.0f));
  105. std::string S0 = glm::to_string(Q0);
  106. Error += S0 != std::string("dualquat((1.000000, {2.000000, 3.000000, 4.000000}), (5.000000, {6.000000, 7.000000, 8.000000}))") ? 1 : 0;
  107. return Error;
  108. }
  109. int main()
  110. {
  111. int Error = 0;
  112. Error += test_string_cast_vector();
  113. Error += test_string_cast_matrix();
  114. Error += test_string_cast_quaternion();
  115. Error += test_string_cast_dual_quaternion();
  116. return Error;
  117. }