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.
 
 
 

59 lines
1.2 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 "core.h"
  14. #include "lol/unit.h"
  15. namespace lol
  16. {
  17. LOLUNIT_FIXTURE(BuildTest)
  18. {
  19. LOLUNIT_TEST(FastMath)
  20. {
  21. double x, y;
  22. y = x = 1.0 + RandF(0.1f, 0.2f);
  23. y += 4503599627370496.0;
  24. /* The compiler should optimise this away */
  25. y -= 4503599627370496.0;
  26. LOLUNIT_ASSERT_EQUAL(x, y);
  27. }
  28. LOLUNIT_TEST(FastMathOverride)
  29. {
  30. double x, y;
  31. y = x = 1.0 + RandF(0.1f, 0.2f);
  32. y += 4503599627370496.0;
  33. FP_USE(y);
  34. /* The compiler should not optimise this away */
  35. y -= 4503599627370496.0;
  36. LOLUNIT_ASSERT_EQUAL(1.0, y);
  37. }
  38. LOLUNIT_TEST(IsNaN)
  39. {
  40. union { float f; uint32_t x; } u;
  41. u.x = 0x7fc00000u;
  42. LOLUNIT_ASSERT(isnan(u.f));
  43. }
  44. };
  45. } /* namespace lol */