Open Source Tomb Raider Engine
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.

12345678910111213141516171819202122232425262728293031323334
  1. /*!
  2. * \file test/math.cpp
  3. * \brief Math Unit Test
  4. *
  5. * \author xythobuz
  6. */
  7. #include <iostream>
  8. #include "global.h"
  9. #include "math/math.h"
  10. #include "math/Vec3.h"
  11. #define check(x) if (!(x)) { \
  12. std::cout << "Test failed: " << #x << std::endl; \
  13. return -1; \
  14. }
  15. int main() {
  16. // math.h
  17. check(equalEpsilon(42.23f, 42.23f));
  18. check(!equalEpsilon(42.23f, 23.42f));
  19. // Vec3.h
  20. Vec3 a(42.0f, 23.0f, 66.0f);
  21. Vec3 b(23.0f, 66.0f, 42.0f);
  22. Vec3 result(-3390.0f, -246.0f, 2243.0f);
  23. check(Vec3::cross(a, b) == result);
  24. check(equalEpsilon(a * b, 5256.0f));
  25. return 0;
  26. }