63 строки
1.3 KiB

  1. //
  2. // Lol Engine
  3. //
  4. // Copyright: (c) 2010-2011 Sam Hocevar <sam@hocevar.net>
  5. // This program is free software; you can redistribute it and/or
  6. // modify it under the terms of the Do What The Fuck You Want To
  7. // Public License, Version 2, as published by Sam Hocevar. See
  8. // http://sam.zoy.org/projects/COPYING.WTFPL for more details.
  9. //
  10. #if defined HAVE_CONFIG_H
  11. # include "config.h"
  12. #endif
  13. #include <cmath>
  14. #include "core.h"
  15. #include "lol/unit.h"
  16. namespace lol
  17. {
  18. LOLUNIT_FIXTURE(RealTest)
  19. {
  20. public:
  21. LOLUNIT_TEST(test_real_from_float)
  22. {
  23. float x = real(0.0f);
  24. float y = real(1.0f);
  25. float z = real(1.5f);
  26. LOLUNIT_ASSERT_EQUAL(x, 0.0f);
  27. LOLUNIT_ASSERT_EQUAL(y, 1.0f);
  28. LOLUNIT_ASSERT_EQUAL(z, 1.5f);
  29. }
  30. LOLUNIT_TEST(test_real_add)
  31. {
  32. LOLUNIT_ASSERT(true);
  33. }
  34. LOLUNIT_TEST(test_real_mul)
  35. {
  36. real x(1.25f);
  37. real y(1.5f);
  38. real z(1.99999f);
  39. real w(-1.5f);
  40. float m1 = x * x;
  41. float m2 = y * y;
  42. float m3 = z * z;
  43. float m4 = w * w;
  44. LOLUNIT_ASSERT_EQUAL(m1, 1.25f * 1.25f);
  45. LOLUNIT_ASSERT_EQUAL(m2, 1.5f * 1.5f);
  46. LOLUNIT_ASSERT_EQUAL(m3, 1.99999f * 1.99999f);
  47. LOLUNIT_ASSERT_EQUAL(m4, -1.5f * -1.5f);
  48. }
  49. };
  50. } /* namespace lol */