ViewTests.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #include "../Tests.hpp"
  2. #include "core/math/View.hpp"
  3. using V3 = Core::Vector3;
  4. static void testFromAngles() {
  5. Core::View v;
  6. v.updateDirections(0.0f, 0.0f);
  7. CORE_TEST_VECTOR(V3(0.0f, 1.0f, 0.0f), v.getUp());
  8. CORE_TEST_VECTOR(V3(0.0f, -1.0f, 0.0f), v.getDown());
  9. CORE_TEST_VECTOR(V3(0.0f, 0.0f, -1.0f), v.getLeft());
  10. CORE_TEST_VECTOR(V3(0.0f, 0.0f, 1.0f), v.getRight());
  11. CORE_TEST_VECTOR(V3(1.0f, 0.0f, 0.0f), v.getFront());
  12. CORE_TEST_VECTOR(V3(-1.0f, 0.0f, 0.0f), v.getBack());
  13. }
  14. static void testFromQuaternion() {
  15. Core::View v;
  16. v.updateDirections(Core::Quaternion());
  17. CORE_TEST_VECTOR(V3(0.0f, 1.0f, 0.0f), v.getUp());
  18. CORE_TEST_VECTOR(V3(0.0f, -1.0f, 0.0f), v.getDown());
  19. CORE_TEST_VECTOR(V3(0.0f, 0.0f, -1.0f), v.getLeft());
  20. CORE_TEST_VECTOR(V3(0.0f, 0.0f, 1.0f), v.getRight());
  21. CORE_TEST_VECTOR(V3(1.0f, 0.0f, 0.0f), v.getFront());
  22. CORE_TEST_VECTOR(V3(-1.0f, 0.0f, 0.0f), v.getBack());
  23. }
  24. static void testUpdateMatrix() {
  25. Core::View v;
  26. CORE_TEST_STRING("[[0.00, 0.00, 0.00, 0.00], "
  27. "[0.00, 0.00, 0.00, 0.00], "
  28. "[0.00, 0.00, 0.00, 0.00], "
  29. "[0.00, 0.00, 0.00, 1.00]]",
  30. v.updateMatrix(Core::Vector3(1.0f, 2.0f, 3.0f)));
  31. }
  32. void Core::testView() {
  33. testFromAngles();
  34. testFromQuaternion();
  35. testUpdateMatrix();
  36. }