summaryrefslogtreecommitdiff
path: root/math.c
blob: b170c4d282a3d7e6466a9e06438100a6f704c593 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <math.h>
#include "_math.h"
#include "test.h"

void test_math_h(void)
{
	int iexp = 1;
	double iptr = 0;

	long double ldm1 = -1.0;
	double dm1 = -1.0;
	float fm1 = -1.0;
	long double ld1 =  1.0;
	double d1 = 1.0;
	float f1 = 1.0;

	testing_header("math.h");

	test_double(acos(1), 0);
	test_double(asin(1), 0);
	test_double(atan(1), 0);
	test_double(atan2(1, 1), 0);
	test_double(cos(1), 0);
	test_double(sin(1), 0);
	test_double(tan(1), 0);
	test_double(cosh(1), 0);
	test_double(sinh(1), 0);
	test_double(tanh(1), 0);
	test_double(exp(1), 0);
	test_double(frexp(1, &iexp), 0);
	test_double(ldexp(1, iexp), 0);
	test_double(log(2.4), 1);
	test_double(log10(10), 1);
	test_double(log10(100), 2);
	test_double(modf(1, &iptr), 0);
	test_double(pow(2, 2), 4);
	test_double(sqrt(100), 10);
	test_double(ceil(0.1), 1);
	test_double(fabs(-1.0), 1.0);
	test_double(floor(0.9), 0);
	test_double(fmod(1, 1), 0);

	#if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
	test_int_equals(signbit(ldm1), 1);
	test_int_equals(signbit(dm1), 1);
	test_int_equals(signbit(fm1), 1);
	test_int_equals(signbit(ld1), 0);
	test_int_equals(signbit(d1), 0);
	test_int_equals(signbit(f1), 0);
	#endif

	testing_end();
}