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.
 
 
 

61 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. #if !defined LOL_DEBUG
  20. LOLUNIT_TEST(FastMath)
  21. {
  22. double x, y;
  23. y = x = 1.0 + RandF(0.1f, 0.2f);
  24. y += 4503599627370496.0;
  25. /* The compiler should optimise this away */
  26. y -= 4503599627370496.0;
  27. LOLUNIT_ASSERT_EQUAL(x, y);
  28. }
  29. #endif
  30. LOLUNIT_TEST(FastMathOverride)
  31. {
  32. double x, y;
  33. y = x = 1.0 + RandF(0.1f, 0.2f);
  34. y += 4503599627370496.0;
  35. FP_USE(y);
  36. /* The compiler should not optimise this away */
  37. y -= 4503599627370496.0;
  38. LOLUNIT_ASSERT_EQUAL(1.0, y);
  39. }
  40. LOLUNIT_TEST(IsNaN)
  41. {
  42. union { float f; uint32_t x; } u;
  43. u.x = 0x7fc00000u;
  44. LOLUNIT_ASSERT(isnan(u.f));
  45. }
  46. };
  47. } /* namespace lol */