ViewTests.cpp 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. module Tests;
  2. import Core.Test;
  3. import Core.View;
  4. import Core.Quaternion;
  5. import Core.Matrix;
  6. import Core.Vector;
  7. using V3 = Core::Vector3;
  8. using Core::View;
  9. static void testFromAngles() {
  10. View v;
  11. v.updateDirections(0.0f, 0.0f);
  12. Core::test(V3(0.0f, 1.0f, 0.0f), v.getUp());
  13. Core::test(V3(0.0f, -1.0f, 0.0f), v.getDown());
  14. Core::test(V3(0.0f, 0.0f, -1.0f), v.getLeft());
  15. Core::test(V3(0.0f, 0.0f, 1.0f), v.getRight());
  16. Core::test(V3(1.0f, 0.0f, 0.0f), v.getFront());
  17. Core::test(V3(-1.0f, 0.0f, 0.0f), v.getBack());
  18. }
  19. static void testFromQuaternion() {
  20. View v;
  21. v.updateDirections(Core::Quaternion());
  22. Core::test(V3(0.0f, 1.0f, 0.0f), v.getUp());
  23. Core::test(V3(0.0f, -1.0f, 0.0f), v.getDown());
  24. Core::test(V3(0.0f, 0.0f, -1.0f), v.getLeft());
  25. Core::test(V3(0.0f, 0.0f, 1.0f), v.getRight());
  26. Core::test(V3(1.0f, 0.0f, 0.0f), v.getFront());
  27. Core::test(V3(-1.0f, 0.0f, 0.0f), v.getBack());
  28. }
  29. static void testUpdateMatrix() {
  30. View v;
  31. const Core::Matrix& m = v.updateMatrix(V3(1.0f, 2.0f, 3.0f));
  32. Core::testString(
  33. "[[0.00, 0.00, 0.00, -0.00], "
  34. "[0.00, 0.00, 0.00, -0.00], "
  35. "[0.00, 0.00, 0.00, -0.00], "
  36. "[0.00, 0.00, 0.00, 1.00]]",
  37. m);
  38. }
  39. void testView() {
  40. testFromAngles();
  41. testFromQuaternion();
  42. testUpdateMatrix();
  43. }