math.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <math.h>
  2. #include "_math.h"
  3. #include "test.h"
  4. void test_math_h(void)
  5. {
  6. int iexp = 1;
  7. double iptr = 0;
  8. testing_header("math.h");
  9. test_double(acos(1), 0);
  10. test_double(asin(1), 0);
  11. test_double(atan(1), 0);
  12. test_double(atan2(1, 1), 0);
  13. test_double(cos(1), 0);
  14. test_double(sin(1), 0);
  15. test_double(tan(1), 0);
  16. test_double(cosh(1), 0);
  17. test_double(sinh(1), 0);
  18. test_double(tanh(1), 0);
  19. test_double(exp(1), 0);
  20. test_double(frexp(1, &iexp), 0);
  21. test_double(ldexp(1, iexp), 0);
  22. test_double(log(2.4), 1);
  23. test_double(log10(10), 1);
  24. test_double(log10(100), 2);
  25. test_double(modf(1, &iptr), 0);
  26. test_double(pow(2, 2), 4);
  27. test_double(sqrt(100), 10);
  28. test_double(ceil(0.1), 1);
  29. test_double(fabs(-1.0), 1.0);
  30. test_double(floor(0.9), 0);
  31. test_double(fmod(1, 1), 0);
  32. #if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
  33. long double ldm1 = -1.0;
  34. double dm1 = -1.0;
  35. float fm1 = -1.0;
  36. long double ld1 = 1.0;
  37. double d1 = 1.0;
  38. float f1 = 1.0;
  39. test_int_equals(signbit(ldm1), 1);
  40. test_int_equals(signbit(dm1), 1);
  41. test_int_equals(signbit(fm1), 1);
  42. test_int_equals(signbit(ld1), 0);
  43. test_int_equals(signbit(d1), 0);
  44. test_int_equals(signbit(f1), 0);
  45. #endif
  46. testing_end();
  47. }