您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 

64 行
1.4 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 <cppunit/extensions/HelperMacros.h>
  14. #include <cppunit/TestCaller.h>
  15. #include <cppunit/TestCase.h>
  16. #include <cppunit/TestSuite.h>
  17. #include <cmath>
  18. #include "core.h"
  19. namespace lol
  20. {
  21. class TrigTest : public CppUnit::TestCase
  22. {
  23. CPPUNIT_TEST_SUITE(TrigTest);
  24. CPPUNIT_TEST(test_sin);
  25. CPPUNIT_TEST_SUITE_END();
  26. public:
  27. TrigTest() : CppUnit::TestCase("Trigonometry Test") {}
  28. void setUp() {}
  29. void tearDown() {}
  30. void test_sin()
  31. {
  32. for (int i = -10000; i < 10000; i++)
  33. {
  34. double f = (double)i * (1.0 / 1000.0);
  35. double a = __builtin_sin(f);
  36. double b = lol_sin(f);
  37. CPPUNIT_ASSERT(fabs(a - b) <= fabs(f) * 1e-11);
  38. }
  39. for (int i = -10000; i < 10000; i++)
  40. {
  41. double f = (double)i * (1.0 / 100000.0);
  42. double a = __builtin_sin(f);
  43. double b = lol_sin(f);
  44. CPPUNIT_ASSERT(fabs(a - b) <= fabs(f) * 1e-11);
  45. }
  46. }
  47. };
  48. CPPUNIT_TEST_SUITE_REGISTRATION(TrigTest);
  49. } /* namespace lol */