1 /*
2  * Copyright (C) 2013 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #define _GNU_SOURCE 1
18 #include <math.h>
19 
20 // This include (and the associated definition of __test_capture_signbit)
21 // must be placed before any files that include <cmath> (gtest.h in this case).
22 //
23 // <math.h> is required to define generic macros signbit, isfinite and
24 // several other such functions.
25 //
26 // <cmath> is required to undef declarations of these macros in the global
27 // namespace and make equivalent functions available in namespace std. Our
28 // stlport implementation does this only for signbit, isfinite, isinf and
29 // isnan.
30 //
31 // NOTE: We don't write our test using std::signbit because we want to be
32 // sure that we're testing the bionic version of signbit. The C++ libraries
33 // are free to reimplement signbit or delegate to compiler builtins if they
34 // please.
35 
36 namespace {
test_capture_signbit(const T in)37 template<typename T> inline int test_capture_signbit(const T in) {
38   return signbit(in);
39 }
test_capture_isfinite(const T in)40 template<typename T> inline int test_capture_isfinite(const T in) {
41   return isfinite(in);
42 }
test_capture_isnan(const T in)43 template<typename T> inline int test_capture_isnan(const T in) {
44   return isnan(in);
45 }
test_capture_isinf(const T in)46 template<typename T> inline int test_capture_isinf(const T in) {
47   return isinf(in);
48 }
49 }
50 
51 #if defined(__BIONIC_LP32_USE_LONG_DOUBLE)
52 #define MATH_TEST math_h_force_long_double
53 #else
54 #define MATH_TEST math_h
55 #endif
56 
57 #include "math_data_test.h"
58 
59 #include <gtest/gtest.h>
60 
61 #include <fenv.h>
62 #include <float.h>
63 #include <limits.h>
64 #include <stdint.h>
65 
66 #include <android-base/scopeguard.h>
67 
float_subnormal()68 static float float_subnormal() {
69   union {
70     float f;
71     uint32_t i;
72   } u;
73   u.i = 0x007fffff;
74   return u.f;
75 }
76 
double_subnormal()77 static double double_subnormal() {
78   union {
79     double d;
80     uint64_t i;
81   } u;
82   u.i = 0x000fffffffffffffLL;
83   return u.d;
84 }
85 
ldouble_subnormal()86 static long double ldouble_subnormal() {
87   union {
88     long double e;
89     unsigned char c[sizeof(long double)];
90   } u;
91 
92   // Subnormals must have a zero exponent and non zero significand.
93   // On all supported representation the 17 bit (counting from either sides)
94   // is part of the significand so it should be enough to set that.
95   // It also applies for the case sizeof(double) = sizeof(long double)
96   for (unsigned int i = 0; i < sizeof(long double); i++) {
97     u.c[i] = 0x00;
98   }
99   u.c[sizeof(long double) - 3] = 0x80;
100   u.c[2] = 0x80;
101 
102   return u.e;
103 }
104 
TEST(MATH_TEST,fpclassify)105 TEST(MATH_TEST, fpclassify) {
106   ASSERT_EQ(FP_INFINITE, fpclassify(INFINITY));
107   ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VALF));
108   ASSERT_EQ(FP_INFINITE, fpclassify(-HUGE_VALF));
109   ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VAL));
110   ASSERT_EQ(FP_INFINITE, fpclassify(-HUGE_VAL));
111   ASSERT_EQ(FP_INFINITE, fpclassify(HUGE_VALL));
112   ASSERT_EQ(FP_INFINITE, fpclassify(-HUGE_VALL));
113 
114   ASSERT_EQ(FP_NAN, fpclassify(nanf("")));
115   ASSERT_EQ(FP_NAN, fpclassify(nan("")));
116   ASSERT_EQ(FP_NAN, fpclassify(nanl("")));
117 
118   ASSERT_EQ(FP_NORMAL, fpclassify(1.0f));
119   ASSERT_EQ(FP_NORMAL, fpclassify(1.0));
120   ASSERT_EQ(FP_NORMAL, fpclassify(1.0L));
121 
122   ASSERT_EQ(FP_SUBNORMAL, fpclassify(float_subnormal()));
123   ASSERT_EQ(FP_SUBNORMAL, fpclassify(double_subnormal()));
124   ASSERT_EQ(FP_SUBNORMAL, fpclassify(ldouble_subnormal()));
125 
126   ASSERT_EQ(FP_ZERO, fpclassify(0.0f));
127   ASSERT_EQ(FP_ZERO, fpclassify(0.0));
128   ASSERT_EQ(FP_ZERO, fpclassify(0.0L));
129 }
130 
TEST(MATH_TEST,isfinite)131 TEST(MATH_TEST, isfinite) {
132   ASSERT_TRUE(test_capture_isfinite(123.0f));
133   ASSERT_TRUE(test_capture_isfinite(123.0));
134   ASSERT_TRUE(test_capture_isfinite(123.0L));
135   ASSERT_FALSE(test_capture_isfinite(HUGE_VALF));
136   ASSERT_FALSE(test_capture_isfinite(-HUGE_VALF));
137   ASSERT_FALSE(test_capture_isfinite(HUGE_VAL));
138   ASSERT_FALSE(test_capture_isfinite(-HUGE_VAL));
139   ASSERT_FALSE(test_capture_isfinite(HUGE_VALL));
140   ASSERT_FALSE(test_capture_isfinite(-HUGE_VALL));
141 }
142 
TEST(MATH_TEST,isinf)143 TEST(MATH_TEST, isinf) {
144   ASSERT_FALSE(test_capture_isinf(123.0f));
145   ASSERT_FALSE(test_capture_isinf(123.0));
146   ASSERT_FALSE(test_capture_isinf(123.0L));
147   ASSERT_TRUE(test_capture_isinf(HUGE_VALF));
148   ASSERT_TRUE(test_capture_isinf(-HUGE_VALF));
149   ASSERT_TRUE(test_capture_isinf(HUGE_VAL));
150   ASSERT_TRUE(test_capture_isinf(-HUGE_VAL));
151   ASSERT_TRUE(test_capture_isinf(HUGE_VALL));
152   ASSERT_TRUE(test_capture_isinf(-HUGE_VALL));
153 }
154 
TEST(MATH_TEST,isnan)155 TEST(MATH_TEST, isnan) {
156   ASSERT_FALSE(test_capture_isnan(123.0f));
157   ASSERT_FALSE(test_capture_isnan(123.0));
158   ASSERT_FALSE(test_capture_isnan(123.0L));
159   ASSERT_TRUE(test_capture_isnan(nanf("")));
160   ASSERT_TRUE(test_capture_isnan(nan("")));
161   ASSERT_TRUE(test_capture_isnan(nanl("")));
162 }
163 
TEST(MATH_TEST,isnormal)164 TEST(MATH_TEST, isnormal) {
165   ASSERT_TRUE(isnormal(123.0f));
166   ASSERT_TRUE(isnormal(123.0));
167   ASSERT_TRUE(isnormal(123.0L));
168   ASSERT_FALSE(isnormal(float_subnormal()));
169   ASSERT_FALSE(isnormal(double_subnormal()));
170   ASSERT_FALSE(isnormal(ldouble_subnormal()));
171 }
172 
173 // TODO: isgreater, isgreaterequals, isless, islessequal, islessgreater, isunordered
TEST(MATH_TEST,signbit)174 TEST(MATH_TEST, signbit) {
175   ASSERT_EQ(0, test_capture_signbit(0.0f));
176   ASSERT_EQ(0, test_capture_signbit(0.0));
177   ASSERT_EQ(0, test_capture_signbit(0.0L));
178 
179   ASSERT_EQ(0, test_capture_signbit(1.0f));
180   ASSERT_EQ(0, test_capture_signbit(1.0));
181   ASSERT_EQ(0, test_capture_signbit(1.0L));
182 
183   ASSERT_NE(0, test_capture_signbit(-1.0f));
184   ASSERT_NE(0, test_capture_signbit(-1.0));
185   ASSERT_NE(0, test_capture_signbit(-1.0L));
186 }
187 
188 // Historical BSD cruft that isn't exposed in <math.h> any more.
189 extern "C" int __fpclassify(double);
190 extern "C" int __fpclassifyd(double);
191 extern "C" int __fpclassifyf(float);
192 extern "C" int __fpclassifyl(long double);
193 
TEST(MATH_TEST,__fpclassify)194 TEST(MATH_TEST, __fpclassify) {
195   ASSERT_EQ(FP_INFINITE, __fpclassify(HUGE_VAL));
196   ASSERT_EQ(FP_INFINITE, __fpclassify(-HUGE_VAL));
197   ASSERT_EQ(FP_NAN, __fpclassify(nan("")));
198   ASSERT_EQ(FP_NORMAL, __fpclassify(1.0));
199   ASSERT_EQ(FP_SUBNORMAL, __fpclassify(double_subnormal()));
200   ASSERT_EQ(FP_ZERO, __fpclassify(0.0));
201 }
202 
TEST(MATH_TEST,__fpclassifyd)203 TEST(MATH_TEST, __fpclassifyd) {
204 #if defined(__GLIBC__)
205 #define __fpclassifyd __fpclassify
206 #endif
207   ASSERT_EQ(FP_INFINITE, __fpclassifyd(HUGE_VAL));
208   ASSERT_EQ(FP_INFINITE, __fpclassifyd(-HUGE_VAL));
209   ASSERT_EQ(FP_NAN, __fpclassifyd(nan("")));
210   ASSERT_EQ(FP_NORMAL, __fpclassifyd(1.0));
211   ASSERT_EQ(FP_SUBNORMAL, __fpclassifyd(double_subnormal()));
212   ASSERT_EQ(FP_ZERO, __fpclassifyd(0.0));
213 }
214 
TEST(MATH_TEST,__fpclassifyf)215 TEST(MATH_TEST, __fpclassifyf) {
216   ASSERT_EQ(FP_INFINITE, __fpclassifyf(HUGE_VALF));
217   ASSERT_EQ(FP_INFINITE, __fpclassifyf(-HUGE_VALF));
218   ASSERT_EQ(FP_NAN, __fpclassifyf(nanf("")));
219   ASSERT_EQ(FP_NORMAL, __fpclassifyf(1.0f));
220   ASSERT_EQ(FP_SUBNORMAL, __fpclassifyf(float_subnormal()));
221   ASSERT_EQ(FP_ZERO, __fpclassifyf(0.0f));
222 }
223 
TEST(MATH_TEST,__fpclassifyl)224 TEST(MATH_TEST, __fpclassifyl) {
225   EXPECT_EQ(FP_INFINITE, __fpclassifyl(HUGE_VALL));
226   EXPECT_EQ(FP_INFINITE, __fpclassifyl(-HUGE_VALL));
227   EXPECT_EQ(FP_NAN, __fpclassifyl(nanl("")));
228   EXPECT_EQ(FP_NORMAL, __fpclassifyl(1.0L));
229   EXPECT_EQ(FP_SUBNORMAL, __fpclassifyl(ldouble_subnormal()));
230   EXPECT_EQ(FP_ZERO, __fpclassifyl(0.0L));
231 }
232 
TEST(MATH_TEST,finitef)233 TEST(MATH_TEST, finitef) {
234   ASSERT_TRUE(finitef(123.0f));
235   ASSERT_FALSE(finitef(HUGE_VALF));
236   ASSERT_FALSE(finitef(-HUGE_VALF));
237 }
238 
239 // Historical BSD cruft that isn't exposed in <math.h> any more.
240 extern "C" int __isfinite(double);
241 extern "C" int __isfinitef(float);
242 extern "C" int isfinitef(float);
243 extern "C" int __isfinitel(long double);
244 extern "C" int isfinitel(long double);
245 
TEST(MATH_TEST,__isfinite)246 TEST(MATH_TEST, __isfinite) {
247 #if defined(__GLIBC__)
248 #define __isfinite __finite
249 #endif
250   ASSERT_TRUE(__isfinite(123.0));
251   ASSERT_FALSE(__isfinite(HUGE_VAL));
252   ASSERT_FALSE(__isfinite(-HUGE_VAL));
253 }
254 
TEST(MATH_TEST,__isfinitef)255 TEST(MATH_TEST, __isfinitef) {
256 #if defined(__GLIBC__)
257 #define __isfinitef __finitef
258 #endif
259   ASSERT_TRUE(__isfinitef(123.0f));
260   ASSERT_FALSE(__isfinitef(HUGE_VALF));
261   ASSERT_FALSE(__isfinitef(-HUGE_VALF));
262 }
263 
TEST(MATH_TEST,isfinitef)264 TEST(MATH_TEST, isfinitef) {
265 #if defined(__GLIBC__)
266 #define isfinitef __finitef
267 #endif
268   ASSERT_TRUE(isfinitef(123.0f));
269   ASSERT_FALSE(isfinitef(HUGE_VALF));
270   ASSERT_FALSE(isfinitef(-HUGE_VALF));
271 }
272 
TEST(MATH_TEST,__isfinitel)273 TEST(MATH_TEST, __isfinitel) {
274 #if defined(__GLIBC__)
275 #define __isfinitel __finitel
276 #endif
277   ASSERT_TRUE(__isfinitel(123.0L));
278   ASSERT_FALSE(__isfinitel(HUGE_VALL));
279   ASSERT_FALSE(__isfinitel(-HUGE_VALL));
280 }
281 
TEST(MATH_TEST,isfinitel)282 TEST(MATH_TEST, isfinitel) {
283 #if defined(__GLIBC__)
284 #define isfinitel __finitel
285 #endif
286   ASSERT_TRUE(isfinitel(123.0L));
287   ASSERT_FALSE(isfinitel(HUGE_VALL));
288   ASSERT_FALSE(isfinitel(-HUGE_VALL));
289 }
290 
TEST(MATH_TEST,finite)291 TEST(MATH_TEST, finite) {
292   ASSERT_TRUE(finite(123.0));
293   ASSERT_FALSE(finite(HUGE_VAL));
294   ASSERT_FALSE(finite(-HUGE_VAL));
295 }
296 
TEST(MATH_TEST,isinf_function)297 TEST(MATH_TEST, isinf_function) {
298   // The isinf macro deals with all three types; the isinf function is for doubles.
299   ASSERT_FALSE((isinf)(123.0));
300   ASSERT_TRUE((isinf)(HUGE_VAL));
301   ASSERT_TRUE((isinf)(-HUGE_VAL));
302 }
303 
304 // Historical BSD cruft that isn't exposed in <math.h> any more.
305 extern "C" int __isinf(double);
306 extern "C" int __isinff(float);
307 extern "C" int isinff(float);
308 extern "C" int __isinfl(long double);
309 extern "C" int isinfl(long double);
310 
TEST(MATH_TEST,__isinf)311 TEST(MATH_TEST, __isinf) {
312   ASSERT_FALSE(__isinf(123.0));
313   ASSERT_TRUE(__isinf(HUGE_VAL));
314   ASSERT_TRUE(__isinf(-HUGE_VAL));
315 }
316 
TEST(MATH_TEST,__isinff)317 TEST(MATH_TEST, __isinff) {
318   ASSERT_FALSE(__isinff(123.0f));
319   ASSERT_TRUE(__isinff(HUGE_VALF));
320   ASSERT_TRUE(__isinff(-HUGE_VALF));
321 }
322 
TEST(MATH_TEST,isinff)323 TEST(MATH_TEST, isinff) {
324   ASSERT_FALSE(isinff(123.0f));
325   ASSERT_TRUE(isinff(HUGE_VALF));
326   ASSERT_TRUE(isinff(-HUGE_VALF));
327 }
328 
TEST(MATH_TEST,__isinfl)329 TEST(MATH_TEST, __isinfl) {
330   ASSERT_FALSE(__isinfl(123.0L));
331   ASSERT_TRUE(__isinfl(HUGE_VALL));
332   ASSERT_TRUE(__isinfl(-HUGE_VALL));
333 }
334 
TEST(MATH_TEST,isinfl)335 TEST(MATH_TEST, isinfl) {
336   ASSERT_FALSE(isinfl(123.0L));
337   ASSERT_TRUE(isinfl(HUGE_VALL));
338   ASSERT_TRUE(isinfl(-HUGE_VALL));
339 }
340 
TEST(MATH_TEST,isnan_function)341 TEST(MATH_TEST, isnan_function) {
342   // The isnan macro deals with all three types; the isnan function is for doubles.
343   ASSERT_FALSE((isnan)(123.0));
344   ASSERT_TRUE((isnan)(nan("")));
345 }
346 
347 // Historical BSD cruft that isn't exposed in <math.h> any more.
348 extern "C" int __isnan(double);
349 extern "C" int __isnanf(float);
350 extern "C" int isnanf(float);
351 extern "C" int __isnanl(long double);
352 extern "C" int isnanl(long double);
353 
TEST(MATH_TEST,__isnan)354 TEST(MATH_TEST, __isnan) {
355   ASSERT_FALSE(__isnan(123.0));
356   ASSERT_TRUE(__isnan(nan("")));
357 }
358 
TEST(MATH_TEST,__isnanf)359 TEST(MATH_TEST, __isnanf) {
360   ASSERT_FALSE(__isnanf(123.0f));
361   ASSERT_TRUE(__isnanf(nanf("")));
362 }
363 
TEST(MATH_TEST,isnanf)364 TEST(MATH_TEST, isnanf) {
365   ASSERT_FALSE(isnanf(123.0f));
366   ASSERT_TRUE(isnanf(nanf("")));
367 }
368 
TEST(MATH_TEST,__isnanl)369 TEST(MATH_TEST, __isnanl) {
370   ASSERT_FALSE(__isnanl(123.0L));
371   ASSERT_TRUE(__isnanl(nanl("")));
372 }
373 
TEST(MATH_TEST,isnanl)374 TEST(MATH_TEST, isnanl) {
375   ASSERT_FALSE(isnanl(123.0L));
376   ASSERT_TRUE(isnanl(nanl("")));
377 }
378 
379 // Historical BSD cruft that isn't exposed in <math.h> any more.
380 extern "C" int __isnormal(double);
381 extern "C" int __isnormalf(float);
382 extern "C" int isnormalf(float);
383 extern "C" int __isnormall(long double);
384 extern "C" int isnormall(long double);
385 
TEST(MATH_TEST,__isnormal)386 TEST(MATH_TEST, __isnormal) {
387 #if defined(__BIONIC__)
388   ASSERT_TRUE(__isnormal(123.0));
389   ASSERT_FALSE(__isnormal(double_subnormal()));
390 #else // __BIONIC__
391   GTEST_SKIP() << "glibc doesn't have __isnormal";
392 #endif // __BIONIC__
393 }
394 
TEST(MATH_TEST,__isnormalf)395 TEST(MATH_TEST, __isnormalf) {
396 #if defined(__BIONIC__)
397   ASSERT_TRUE(__isnormalf(123.0f));
398   ASSERT_FALSE(__isnormalf(float_subnormal()));
399 #else // __BIONIC__
400   GTEST_SKIP() << "glibc doesn't have __isnormalf";
401 #endif // __BIONIC__
402 }
403 
TEST(MATH_TEST,isnormalf)404 TEST(MATH_TEST, isnormalf) {
405 #if defined(__BIONIC__)
406   ASSERT_TRUE(isnormalf(123.0f));
407   ASSERT_FALSE(isnormalf(float_subnormal()));
408 #else // __BIONIC__
409   GTEST_SKIP() << "glibc doesn't have isnormalf";
410 #endif // __BIONIC__
411 }
412 
TEST(MATH_TEST,__isnormall)413 TEST(MATH_TEST, __isnormall) {
414 #if defined(__BIONIC__)
415   ASSERT_TRUE(__isnormall(123.0L));
416   ASSERT_FALSE(__isnormall(ldouble_subnormal()));
417 #else // __BIONIC__
418   GTEST_SKIP() << "glibc doesn't have __isnormall";
419 #endif // __BIONIC__
420 }
421 
TEST(MATH_TEST,isnormall)422 TEST(MATH_TEST, isnormall) {
423 #if defined(__BIONIC__)
424   ASSERT_TRUE(isnormall(123.0L));
425   ASSERT_FALSE(isnormall(ldouble_subnormal()));
426 #else // __BIONIC__
427   GTEST_SKIP() << "glibc doesn't have isnormall";
428 #endif // __BIONIC__
429 }
430 
431 // Historical BSD cruft that isn't exposed in <math.h> any more.
432 extern "C" int __signbit(double);
433 extern "C" int __signbitf(float);
434 extern "C" int __signbitl(long double);
435 
TEST(MATH_TEST,__signbit)436 TEST(MATH_TEST, __signbit) {
437   ASSERT_EQ(0, __signbit(0.0));
438   ASSERT_EQ(0, __signbit(1.0));
439   ASSERT_NE(0, __signbit(-1.0));
440 }
441 
TEST(MATH_TEST,__signbitf)442 TEST(MATH_TEST, __signbitf) {
443   ASSERT_EQ(0, __signbitf(0.0f));
444   ASSERT_EQ(0, __signbitf(1.0f));
445   ASSERT_NE(0, __signbitf(-1.0f));
446 }
447 
TEST(MATH_TEST,__signbitl)448 TEST(MATH_TEST, __signbitl) {
449   ASSERT_EQ(0L, __signbitl(0.0L));
450   ASSERT_EQ(0L, __signbitl(1.0L));
451   ASSERT_NE(0L, __signbitl(-1.0L));
452 }
453 
TEST(MATH_TEST,acos)454 TEST(MATH_TEST, acos) {
455   ASSERT_DOUBLE_EQ(M_PI/2.0, acos(0.0));
456 }
457 
TEST(MATH_TEST,acosf)458 TEST(MATH_TEST, acosf) {
459   ASSERT_FLOAT_EQ(static_cast<float>(M_PI)/2.0f, acosf(0.0f));
460 }
461 
TEST(MATH_TEST,acosl)462 TEST(MATH_TEST, acosl) {
463   ASSERT_DOUBLE_EQ(M_PI/2.0L, acosl(0.0L));
464 }
465 
TEST(MATH_TEST,asin)466 TEST(MATH_TEST, asin) {
467   ASSERT_DOUBLE_EQ(0.0, asin(0.0));
468 }
469 
TEST(MATH_TEST,asinf)470 TEST(MATH_TEST, asinf) {
471   ASSERT_FLOAT_EQ(0.0f, asinf(0.0f));
472 }
473 
TEST(MATH_TEST,asinl)474 TEST(MATH_TEST, asinl) {
475   ASSERT_DOUBLE_EQ(0.0L, asinl(0.0L));
476 }
477 
TEST(MATH_TEST,atan)478 TEST(MATH_TEST, atan) {
479   ASSERT_DOUBLE_EQ(0.0, atan(0.0));
480 }
481 
TEST(MATH_TEST,atanf)482 TEST(MATH_TEST, atanf) {
483   ASSERT_FLOAT_EQ(0.0f, atanf(0.0f));
484 }
485 
TEST(MATH_TEST,atanl)486 TEST(MATH_TEST, atanl) {
487   ASSERT_DOUBLE_EQ(0.0L, atanl(0.0L));
488 }
489 
TEST(MATH_TEST,atan2)490 TEST(MATH_TEST, atan2) {
491   ASSERT_DOUBLE_EQ(0.0, atan2(0.0, 0.0));
492 }
493 
TEST(MATH_TEST,atan2f)494 TEST(MATH_TEST, atan2f) {
495   ASSERT_FLOAT_EQ(0.0f, atan2f(0.0f, 0.0f));
496 }
497 
TEST(MATH_TEST,atan2l)498 TEST(MATH_TEST, atan2l) {
499   ASSERT_DOUBLE_EQ(0.0L, atan2l(0.0L, 0.0L));
500 }
501 
TEST(MATH_TEST,cos)502 TEST(MATH_TEST, cos) {
503   ASSERT_DOUBLE_EQ(1.0, cos(0.0));
504 }
505 
TEST(MATH_TEST,cosf)506 TEST(MATH_TEST, cosf) {
507   ASSERT_FLOAT_EQ(1.0f, cosf(0.0f));
508 }
509 
TEST(MATH_TEST,cosl)510 TEST(MATH_TEST, cosl) {
511   ASSERT_DOUBLE_EQ(1.0L, cosl(0.0L));
512 }
513 
TEST(MATH_TEST,sin)514 TEST(MATH_TEST, sin) {
515   ASSERT_DOUBLE_EQ(0.0, sin(0.0));
516 }
517 
TEST(MATH_TEST,sinf)518 TEST(MATH_TEST, sinf) {
519   ASSERT_FLOAT_EQ(0.0f, sinf(0.0f));
520 }
521 
TEST(MATH_TEST,sinl)522 TEST(MATH_TEST, sinl) {
523   ASSERT_DOUBLE_EQ(0.0L, sinl(0.0L));
524 }
525 
TEST(MATH_TEST,sincos)526 TEST(MATH_TEST, sincos) {
527   double s, c;
528   sincos(0.0, &s, &c);
529   ASSERT_DOUBLE_EQ(0.0, s);
530   ASSERT_DOUBLE_EQ(1.0, c);
531 }
532 
TEST(MATH_TEST,sincosf)533 TEST(MATH_TEST, sincosf) {
534   float s, c;
535   sincosf(0.0f, &s, &c);
536   ASSERT_FLOAT_EQ(0.0f, s);
537   ASSERT_FLOAT_EQ(1.0f, c);
538 }
539 
TEST(MATH_TEST,sincosl)540 TEST(MATH_TEST, sincosl) {
541   long double s, c;
542   sincosl(0.0L, &s, &c);
543   ASSERT_DOUBLE_EQ(0.0L, s);
544   ASSERT_DOUBLE_EQ(1.0L, c);
545 }
546 
TEST(MATH_TEST,tan)547 TEST(MATH_TEST, tan) {
548   ASSERT_DOUBLE_EQ(0.0, tan(0.0));
549 }
550 
TEST(MATH_TEST,tanf)551 TEST(MATH_TEST, tanf) {
552   ASSERT_FLOAT_EQ(0.0f, tanf(0.0f));
553 }
554 
TEST(MATH_TEST,tanl)555 TEST(MATH_TEST, tanl) {
556   ASSERT_DOUBLE_EQ(0.0L, tanl(0.0L));
557 }
558 
TEST(MATH_TEST,acosh)559 TEST(MATH_TEST, acosh) {
560   ASSERT_DOUBLE_EQ(0.0, acosh(1.0));
561 }
562 
TEST(MATH_TEST,acoshf)563 TEST(MATH_TEST, acoshf) {
564   ASSERT_FLOAT_EQ(0.0f, acoshf(1.0f));
565 }
566 
TEST(MATH_TEST,acoshl)567 TEST(MATH_TEST, acoshl) {
568   ASSERT_DOUBLE_EQ(0.0L, acoshl(1.0L));
569 }
570 
TEST(MATH_TEST,asinh)571 TEST(MATH_TEST, asinh) {
572   ASSERT_DOUBLE_EQ(0.0, asinh(0.0));
573 }
574 
TEST(MATH_TEST,asinhf)575 TEST(MATH_TEST, asinhf) {
576   ASSERT_FLOAT_EQ(0.0f, asinhf(0.0f));
577 }
578 
TEST(MATH_TEST,asinhl)579 TEST(MATH_TEST, asinhl) {
580   ASSERT_DOUBLE_EQ(0.0L, asinhl(0.0L));
581 }
582 
TEST(MATH_TEST,atanh)583 TEST(MATH_TEST, atanh) {
584   ASSERT_DOUBLE_EQ(0.0, atanh(0.0));
585 }
586 
TEST(MATH_TEST,atanhf)587 TEST(MATH_TEST, atanhf) {
588   ASSERT_FLOAT_EQ(0.0f, atanhf(0.0f));
589 }
590 
TEST(MATH_TEST,atanhl)591 TEST(MATH_TEST, atanhl) {
592   ASSERT_DOUBLE_EQ(0.0L, atanhl(0.0L));
593 }
594 
TEST(MATH_TEST,cosh)595 TEST(MATH_TEST, cosh) {
596   ASSERT_DOUBLE_EQ(1.0, cosh(0.0));
597 }
598 
TEST(MATH_TEST,coshf)599 TEST(MATH_TEST, coshf) {
600   ASSERT_FLOAT_EQ(1.0f, coshf(0.0f));
601 }
602 
TEST(MATH_TEST,coshl)603 TEST(MATH_TEST, coshl) {
604   ASSERT_DOUBLE_EQ(1.0L, coshl(0.0L));
605 }
606 
TEST(MATH_TEST,sinh)607 TEST(MATH_TEST, sinh) {
608   ASSERT_DOUBLE_EQ(0.0, sinh(0.0));
609 }
610 
TEST(MATH_TEST,sinhf)611 TEST(MATH_TEST, sinhf) {
612   ASSERT_FLOAT_EQ(0.0f, sinhf(0.0f));
613 }
614 
TEST(MATH_TEST,sinhl)615 TEST(MATH_TEST, sinhl) {
616   ASSERT_DOUBLE_EQ(0.0L, sinhl(0.0L));
617 }
618 
TEST(MATH_TEST,tanh)619 TEST(MATH_TEST, tanh) {
620   ASSERT_DOUBLE_EQ(0.0, tanh(0.0));
621 }
622 
TEST(MATH_TEST,tanhf)623 TEST(MATH_TEST, tanhf) {
624   ASSERT_FLOAT_EQ(0.0f, tanhf(0.0f));
625 }
626 
TEST(MATH_TEST,tanhl)627 TEST(MATH_TEST, tanhl) {
628   ASSERT_DOUBLE_EQ(0.0L, tanhl(0.0L));
629 }
630 
TEST(MATH_TEST,log)631 TEST(MATH_TEST, log) {
632   ASSERT_DOUBLE_EQ(1.0, log(M_E));
633 }
634 
TEST(MATH_TEST,logf)635 TEST(MATH_TEST, logf) {
636   ASSERT_FLOAT_EQ(1.0f, logf(static_cast<float>(M_E)));
637 }
638 
TEST(MATH_TEST,logl)639 TEST(MATH_TEST, logl) {
640   ASSERT_DOUBLE_EQ(1.0L, logl(M_E));
641 }
642 
TEST(MATH_TEST,log2)643 TEST(MATH_TEST, log2) {
644   ASSERT_DOUBLE_EQ(12.0, log2(4096.0));
645 }
646 
TEST(MATH_TEST,log2f)647 TEST(MATH_TEST, log2f) {
648   ASSERT_FLOAT_EQ(12.0f, log2f(4096.0f));
649 }
650 
TEST(MATH_TEST,log2l)651 TEST(MATH_TEST, log2l) {
652   ASSERT_DOUBLE_EQ(12.0L, log2l(4096.0L));
653 }
654 
TEST(MATH_TEST,log10)655 TEST(MATH_TEST, log10) {
656   ASSERT_DOUBLE_EQ(3.0, log10(1000.0));
657 }
658 
TEST(MATH_TEST,log10f)659 TEST(MATH_TEST, log10f) {
660   ASSERT_FLOAT_EQ(3.0f, log10f(1000.0f));
661 }
662 
TEST(MATH_TEST,log10l)663 TEST(MATH_TEST, log10l) {
664   ASSERT_DOUBLE_EQ(3.0L, log10l(1000.0L));
665 }
666 
TEST(MATH_TEST,cbrt)667 TEST(MATH_TEST, cbrt) {
668   ASSERT_DOUBLE_EQ(3.0, cbrt(27.0));
669 }
670 
TEST(MATH_TEST,cbrtf)671 TEST(MATH_TEST, cbrtf) {
672   ASSERT_FLOAT_EQ(3.0f, cbrtf(27.0f));
673 }
674 
TEST(MATH_TEST,cbrtl)675 TEST(MATH_TEST, cbrtl) {
676   ASSERT_DOUBLE_EQ(3.0L, cbrtl(27.0L));
677 }
678 
TEST(MATH_TEST,sqrt)679 TEST(MATH_TEST, sqrt) {
680   ASSERT_DOUBLE_EQ(2.0, sqrt(4.0));
681 }
682 
TEST(MATH_TEST,sqrtf)683 TEST(MATH_TEST, sqrtf) {
684   ASSERT_FLOAT_EQ(2.0f, sqrtf(4.0f));
685 }
686 
TEST(MATH_TEST,sqrtl)687 TEST(MATH_TEST, sqrtl) {
688   ASSERT_DOUBLE_EQ(2.0L, sqrtl(4.0L));
689 }
690 
TEST(MATH_TEST,exp)691 TEST(MATH_TEST, exp) {
692   ASSERT_DOUBLE_EQ(1.0, exp(0.0));
693   ASSERT_DOUBLE_EQ(M_E, exp(1.0));
694 }
695 
TEST(MATH_TEST,expf)696 TEST(MATH_TEST, expf) {
697   ASSERT_FLOAT_EQ(1.0f, expf(0.0f));
698   ASSERT_FLOAT_EQ(static_cast<float>(M_E), expf(1.0f));
699 }
700 
TEST(MATH_TEST,expl)701 TEST(MATH_TEST, expl) {
702   ASSERT_DOUBLE_EQ(1.0L, expl(0.0L));
703   ASSERT_DOUBLE_EQ(M_E, expl(1.0L));
704 }
705 
TEST(MATH_TEST,exp2)706 TEST(MATH_TEST, exp2) {
707   ASSERT_DOUBLE_EQ(8.0, exp2(3.0));
708 }
709 
TEST(MATH_TEST,exp2f)710 TEST(MATH_TEST, exp2f) {
711   ASSERT_FLOAT_EQ(8.0f, exp2f(3.0f));
712 }
713 
TEST(MATH_TEST,exp2l)714 TEST(MATH_TEST, exp2l) {
715   ASSERT_DOUBLE_EQ(8.0L, exp2l(3.0L));
716 }
717 
TEST(MATH_TEST,expm1)718 TEST(MATH_TEST, expm1) {
719   ASSERT_DOUBLE_EQ(M_E - 1.0, expm1(1.0));
720 }
721 
TEST(MATH_TEST,expm1f)722 TEST(MATH_TEST, expm1f) {
723   ASSERT_FLOAT_EQ(static_cast<float>(M_E) - 1.0f, expm1f(1.0f));
724 }
725 
TEST(MATH_TEST,expm1l)726 TEST(MATH_TEST, expm1l) {
727   ASSERT_DOUBLE_EQ(M_E - 1.0L, expm1l(1.0L));
728 }
729 
TEST(MATH_TEST,pow)730 TEST(MATH_TEST, pow) {
731   ASSERT_TRUE(isnan(pow(nan(""), 3.0)));
732   ASSERT_DOUBLE_EQ(1.0, (pow(1.0, nan(""))));
733   ASSERT_TRUE(isnan(pow(2.0, nan(""))));
734   ASSERT_DOUBLE_EQ(8.0, pow(2.0, 3.0));
735 }
736 
TEST(MATH_TEST,powf)737 TEST(MATH_TEST, powf) {
738   ASSERT_TRUE(isnanf(powf(nanf(""), 3.0f)));
739   ASSERT_FLOAT_EQ(1.0f, (powf(1.0f, nanf(""))));
740   ASSERT_TRUE(isnanf(powf(2.0f, nanf(""))));
741   ASSERT_FLOAT_EQ(8.0f, powf(2.0f, 3.0f));
742 }
743 
TEST(MATH_TEST,powl)744 TEST(MATH_TEST, powl) {
745   ASSERT_TRUE(__isnanl(powl(nanl(""), 3.0L)));
746   ASSERT_DOUBLE_EQ(1.0L, (powl(1.0L, nanl(""))));
747   ASSERT_TRUE(__isnanl(powl(2.0L, nanl(""))));
748   ASSERT_DOUBLE_EQ(8.0L, powl(2.0L, 3.0L));
749 }
750 
TEST(MATH_TEST,ceil)751 TEST(MATH_TEST, ceil) {
752   ASSERT_DOUBLE_EQ(1.0, ceil(0.9));
753 }
754 
TEST(MATH_TEST,ceilf)755 TEST(MATH_TEST, ceilf) {
756   ASSERT_FLOAT_EQ(1.0f, ceilf(0.9f));
757 }
758 
TEST(MATH_TEST,ceill)759 TEST(MATH_TEST, ceill) {
760   ASSERT_DOUBLE_EQ(1.0L, ceill(0.9L));
761 }
762 
TEST(MATH_TEST,floor)763 TEST(MATH_TEST, floor) {
764   ASSERT_DOUBLE_EQ(1.0, floor(1.1));
765 }
766 
TEST(MATH_TEST,floorf)767 TEST(MATH_TEST, floorf) {
768   ASSERT_FLOAT_EQ(1.0f, floorf(1.1f));
769 }
770 
TEST(MATH_TEST,floorl)771 TEST(MATH_TEST, floorl) {
772   ASSERT_DOUBLE_EQ(1.0L, floorl(1.1L));
773 }
774 
TEST(MATH_TEST,fabs)775 TEST(MATH_TEST, fabs) {
776   ASSERT_DOUBLE_EQ(1.0, fabs(-1.0));
777 }
778 
TEST(MATH_TEST,fabsf)779 TEST(MATH_TEST, fabsf) {
780   ASSERT_FLOAT_EQ(1.0f, fabsf(-1.0f));
781 }
782 
TEST(MATH_TEST,fabsl)783 TEST(MATH_TEST, fabsl) {
784   ASSERT_DOUBLE_EQ(1.0L, fabsl(-1.0L));
785 }
786 
TEST(MATH_TEST,ldexp)787 TEST(MATH_TEST, ldexp) {
788   ASSERT_DOUBLE_EQ(16.0, ldexp(2.0, 3.0));
789 }
790 
TEST(MATH_TEST,ldexpf)791 TEST(MATH_TEST, ldexpf) {
792   ASSERT_FLOAT_EQ(16.0f, ldexpf(2.0f, 3.0f));
793 }
794 
TEST(MATH_TEST,ldexpl)795 TEST(MATH_TEST, ldexpl) {
796   ASSERT_DOUBLE_EQ(16.0L, ldexpl(2.0L, 3.0));
797 }
798 
TEST(MATH_TEST,fmod)799 TEST(MATH_TEST, fmod) {
800   ASSERT_DOUBLE_EQ(2.0, fmod(12.0, 10.0));
801 
802   // If x is an infinity, NaN is returned.
803   ASSERT_TRUE(isnan(fmod(HUGE_VAL, 10.0f)));
804   ASSERT_TRUE(isnan(fmod(-HUGE_VAL, 10.0f)));
805 
806   // If x or y is a NaN, NaN is returned.
807   ASSERT_TRUE(isnan(fmod(nan(""), 10.0)));
808   ASSERT_TRUE(isnan(fmod(12.0, nan(""))));
809 
810   // If y is 0, NaN is returned.
811   ASSERT_TRUE(isnan(fmod(3.0, 0.0)));
812 }
813 
TEST(MATH_TEST,fmodf)814 TEST(MATH_TEST, fmodf) {
815   ASSERT_FLOAT_EQ(2.0f, fmodf(12.0f, 10.0f));
816 
817   // If x is an infinity, NaN is returned.
818   ASSERT_TRUE(isnanf(fmodf(HUGE_VALF, 10.0f)));
819   ASSERT_TRUE(isnanf(fmodf(-HUGE_VALF, 10.0f)));
820 
821   // If x or y is a NaN, NaN is returned.
822   ASSERT_TRUE(isnanf(fmodf(nanf(""), 10.0f)));
823   ASSERT_TRUE(isnanf(fmodf(12.0f, nan(""))));
824 
825   // If y is 0, NaN is returned.
826   ASSERT_TRUE(isnanf(fmodf(3.0f, 0.0f)));
827 }
828 
TEST(MATH_TEST,fmodl)829 TEST(MATH_TEST, fmodl) {
830   ASSERT_DOUBLE_EQ(2.0L, fmodl(12.0L, 10.0L));
831 
832   // If x is an infinity, NaN is returned.
833   ASSERT_TRUE(isnanl(fmodl(HUGE_VALL, 10.0L)));
834   ASSERT_TRUE(isnanl(fmodl(-HUGE_VALL, 10.0L)));
835 
836   // If x or y is a NaN, NaN is returned.
837   ASSERT_TRUE(isnanl(fmodl(nanl(""), 10.0L)));
838   ASSERT_TRUE(isnanl(fmodl(12.0L, nanl(""))));
839 
840   // If y is 0, NaN is returned.
841   ASSERT_TRUE(isnanl(fmodl(3.0L, 0.0L)));
842 }
843 
TEST(MATH_TEST,remainder)844 TEST(MATH_TEST, remainder) {
845   ASSERT_DOUBLE_EQ(2.0, remainder(12.0, 10.0));
846 
847   // If x or y is a NaN, NaN is returned.
848   ASSERT_TRUE(isnan(remainder(nan(""), 10.0)));
849   ASSERT_TRUE(isnan(remainder(12.0, nan(""))));
850 
851   // If x is an infinity, NaN is returned.
852   ASSERT_TRUE(isnan(remainder(HUGE_VAL, 10.0)));
853   ASSERT_TRUE(isnan(remainder(-HUGE_VAL, 10.0)));
854 
855   // If y is 0, NaN is returned.
856   ASSERT_TRUE(isnan(remainder(12.0, 0.0)));
857 }
858 
TEST(MATH_TEST,remainderf)859 TEST(MATH_TEST, remainderf) {
860   ASSERT_FLOAT_EQ(2.0f, remainderf(12.0f, 10.0f));
861 
862   // If x or y is a NaN, NaN is returned.
863   ASSERT_TRUE(isnanf(remainderf(nanf(""), 10.0f)));
864   ASSERT_TRUE(isnanf(remainderf(12.0f, nanf(""))));
865 
866   // If x is an infinity, NaN is returned.
867   ASSERT_TRUE(isnanf(remainderf(HUGE_VALF, 10.0f)));
868   ASSERT_TRUE(isnanf(remainderf(-HUGE_VALF, 10.0f)));
869 
870   // If y is 0, NaN is returned.
871   ASSERT_TRUE(isnanf(remainderf(12.0f, 0.0f)));
872 }
873 
TEST(MATH_TEST,remainderl)874 TEST(MATH_TEST, remainderl) {
875   ASSERT_DOUBLE_EQ(2.0L, remainderl(12.0L, 10.0L));
876 
877   // If x or y is a NaN, NaN is returned.
878   ASSERT_TRUE(isnanl(remainderl(nanl(""), 10.0L)));
879   ASSERT_TRUE(isnanl(remainderl(12.0L, nanl(""))));
880 
881   // If x is an infinity, NaN is returned.
882   ASSERT_TRUE(isnanl(remainderl(HUGE_VALL, 10.0L)));
883   ASSERT_TRUE(isnanl(remainderl(-HUGE_VALL, 10.0L)));
884 
885   // If y is 0, NaN is returned.
886   ASSERT_TRUE(isnanl(remainderl(12.0L, 0.0L)));
887 }
888 
TEST(MATH_TEST,drem)889 TEST(MATH_TEST, drem) {
890   ASSERT_DOUBLE_EQ(2.0, drem(12.0, 10.0));
891 }
892 
TEST(MATH_TEST,dremf)893 TEST(MATH_TEST, dremf) {
894   ASSERT_FLOAT_EQ(2.0f, dremf(12.0f, 10.0f));
895 }
896 
TEST(MATH_TEST,fmax)897 TEST(MATH_TEST, fmax) {
898   ASSERT_DOUBLE_EQ(12.0, fmax(12.0, 10.0));
899   ASSERT_DOUBLE_EQ(12.0, fmax(12.0, nan("")));
900   ASSERT_DOUBLE_EQ(12.0, fmax(nan(""), 12.0));
901 }
902 
TEST(MATH_TEST,fmaxf)903 TEST(MATH_TEST, fmaxf) {
904   ASSERT_FLOAT_EQ(12.0f, fmaxf(12.0f, 10.0f));
905   ASSERT_FLOAT_EQ(12.0f, fmaxf(12.0f, nanf("")));
906   ASSERT_FLOAT_EQ(12.0f, fmaxf(nanf(""), 12.0f));
907 }
908 
TEST(MATH_TEST,fmaxl)909 TEST(MATH_TEST, fmaxl) {
910   ASSERT_DOUBLE_EQ(12.0L, fmaxl(12.0L, 10.0L));
911   ASSERT_DOUBLE_EQ(12.0L, fmaxl(12.0L, nanl("")));
912   ASSERT_DOUBLE_EQ(12.0L, fmaxl(nanl(""), 12.0L));
913 }
914 
TEST(MATH_TEST,fmin)915 TEST(MATH_TEST, fmin) {
916   ASSERT_DOUBLE_EQ(10.0, fmin(12.0, 10.0));
917   ASSERT_DOUBLE_EQ(12.0, fmin(12.0, nan("")));
918   ASSERT_DOUBLE_EQ(12.0, fmin(nan(""), 12.0));
919 }
920 
TEST(MATH_TEST,fminf)921 TEST(MATH_TEST, fminf) {
922   ASSERT_FLOAT_EQ(10.0f, fminf(12.0f, 10.0f));
923   ASSERT_FLOAT_EQ(12.0f, fminf(12.0f, nanf("")));
924   ASSERT_FLOAT_EQ(12.0f, fminf(nanf(""), 12.0f));
925 }
926 
TEST(MATH_TEST,fminl)927 TEST(MATH_TEST, fminl) {
928   ASSERT_DOUBLE_EQ(10.0L, fminl(12.0L, 10.0L));
929   ASSERT_DOUBLE_EQ(12.0L, fminl(12.0L, nanl("")));
930   ASSERT_DOUBLE_EQ(12.0L, fminl(nanl(""), 12.0L));
931 }
932 
TEST(MATH_TEST,fma)933 TEST(MATH_TEST, fma) {
934   ASSERT_DOUBLE_EQ(10.0, fma(2.0, 3.0, 4.0));
935 }
936 
TEST(MATH_TEST,fmaf)937 TEST(MATH_TEST, fmaf) {
938   ASSERT_FLOAT_EQ(10.0f, fmaf(2.0f, 3.0f, 4.0f));
939 }
940 
TEST(MATH_TEST,fmal)941 TEST(MATH_TEST, fmal) {
942   ASSERT_DOUBLE_EQ(10.0L, fmal(2.0L, 3.0L, 4.0L));
943 }
944 
TEST(MATH_TEST,hypot)945 TEST(MATH_TEST, hypot) {
946   ASSERT_DOUBLE_EQ(5.0, hypot(3.0, 4.0));
947 
948   // If x or y is an infinity, returns positive infinity.
949   ASSERT_EQ(HUGE_VAL, hypot(3.0, HUGE_VAL));
950   ASSERT_EQ(HUGE_VAL, hypot(3.0, -HUGE_VAL));
951   ASSERT_EQ(HUGE_VAL, hypot(HUGE_VAL, 4.0));
952   ASSERT_EQ(HUGE_VAL, hypot(-HUGE_VAL, 4.0));
953 
954   // If x or y is a NaN, returns NaN.
955   ASSERT_TRUE(isnan(hypot(3.0, nan(""))));
956   ASSERT_TRUE(isnan(hypot(nan(""), 4.0)));
957 }
958 
TEST(MATH_TEST,hypotf)959 TEST(MATH_TEST, hypotf) {
960   ASSERT_FLOAT_EQ(5.0f, hypotf(3.0f, 4.0f));
961 
962   // If x or y is an infinity, returns positive infinity.
963   ASSERT_EQ(HUGE_VALF, hypotf(3.0f, HUGE_VALF));
964   ASSERT_EQ(HUGE_VALF, hypotf(3.0f, -HUGE_VALF));
965   ASSERT_EQ(HUGE_VALF, hypotf(HUGE_VALF, 4.0f));
966   ASSERT_EQ(HUGE_VALF, hypotf(-HUGE_VALF, 4.0f));
967 
968   // If x or y is a NaN, returns NaN.
969   ASSERT_TRUE(isnanf(hypotf(3.0f, nanf(""))));
970   ASSERT_TRUE(isnanf(hypotf(nanf(""), 4.0f)));
971 }
972 
TEST(MATH_TEST,hypotl)973 TEST(MATH_TEST, hypotl) {
974   ASSERT_DOUBLE_EQ(5.0L, hypotl(3.0L, 4.0L));
975 
976   // If x or y is an infinity, returns positive infinity.
977   ASSERT_EQ(HUGE_VALL, hypotl(3.0L, HUGE_VALL));
978   ASSERT_EQ(HUGE_VALL, hypotl(3.0L, -HUGE_VALL));
979   ASSERT_EQ(HUGE_VALL, hypotl(HUGE_VALL, 4.0L));
980   ASSERT_EQ(HUGE_VALL, hypotl(-HUGE_VALL, 4.0L));
981 
982   // If x or y is a NaN, returns NaN.
983   ASSERT_TRUE(isnanl(hypotl(3.0L, nanl(""))));
984   ASSERT_TRUE(isnanl(hypotl(nanl(""), 4.0L)));
985 }
986 
TEST(MATH_TEST,erf)987 TEST(MATH_TEST, erf) {
988   ASSERT_DOUBLE_EQ(0.84270079294971489, erf(1.0));
989 }
990 
TEST(MATH_TEST,erff)991 TEST(MATH_TEST, erff) {
992   ASSERT_FLOAT_EQ(0.84270078f, erff(1.0f));
993 }
994 
TEST(MATH_TEST,erfl)995 TEST(MATH_TEST, erfl) {
996   ASSERT_DOUBLE_EQ(0.84270079294971489L, erfl(1.0L));
997 }
998 
TEST(MATH_TEST,erfc)999 TEST(MATH_TEST, erfc) {
1000   ASSERT_DOUBLE_EQ(0.15729920705028513, erfc(1.0));
1001 }
1002 
TEST(MATH_TEST,erfcf)1003 TEST(MATH_TEST, erfcf) {
1004   ASSERT_FLOAT_EQ(0.15729921f, erfcf(1.0f));
1005 }
1006 
TEST(MATH_TEST,erfcl)1007 TEST(MATH_TEST, erfcl) {
1008   ASSERT_DOUBLE_EQ(0.15729920705028513L, erfcl(1.0L));
1009 }
1010 
TEST(MATH_TEST,lrint)1011 TEST(MATH_TEST, lrint) {
1012   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1013 
1014   fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode.
1015   ASSERT_EQ(1235, lrint(1234.01));
1016   ASSERT_EQ(1235, lrintf(1234.01f));
1017   ASSERT_EQ(1235, lrintl(1234.01L));
1018   fesetround(FE_TOWARDZERO); // lrint/lrintf/lrintl obey the rounding mode.
1019   ASSERT_EQ(1234, lrint(1234.01));
1020   ASSERT_EQ(1234, lrintf(1234.01f));
1021   ASSERT_EQ(1234, lrintl(1234.01L));
1022 
1023   fesetround(FE_UPWARD); // llrint/llrintf/llrintl obey the rounding mode.
1024   ASSERT_EQ(1235L, llrint(1234.01));
1025   ASSERT_EQ(1235L, llrintf(1234.01f));
1026   ASSERT_EQ(1235L, llrintl(1234.01L));
1027   fesetround(FE_TOWARDZERO); // llrint/llrintf/llrintl obey the rounding mode.
1028   ASSERT_EQ(1234L, llrint(1234.01));
1029   ASSERT_EQ(1234L, llrintf(1234.01f));
1030   ASSERT_EQ(1234L, llrintl(1234.01L));
1031 }
1032 
TEST(MATH_TEST,rint)1033 TEST(MATH_TEST, rint) {
1034   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1035 
1036   fesetround(FE_UPWARD); // rint/rintf/rintl obey the rounding mode.
1037   feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
1038   ASSERT_EQ(1234.0, rint(1234.0));
1039   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
1040   ASSERT_EQ(1235.0, rint(1234.01));
1041   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
1042 
1043   feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
1044   ASSERT_EQ(1234.0f, rintf(1234.0f));
1045   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
1046   ASSERT_EQ(1235.0f, rintf(1234.01f));
1047   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
1048 
1049   feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
1050   ASSERT_EQ(1234.0, rintl(1234.0L));
1051   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
1052   ASSERT_EQ(1235.0, rintl(1234.01L));
1053   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
1054 
1055   fesetround(FE_TOWARDZERO); // rint/rintf obey the rounding mode.
1056   ASSERT_EQ(1234.0, rint(1234.01));
1057   ASSERT_EQ(1234.0f, rintf(1234.01f));
1058   ASSERT_EQ(1234.0, rintl(1234.01L));
1059 }
1060 
TEST(MATH_TEST,nearbyint)1061 TEST(MATH_TEST, nearbyint) {
1062   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1063   fesetround(FE_UPWARD); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
1064   feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
1065   ASSERT_EQ(1234.0, nearbyint(1234.0));
1066   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
1067   ASSERT_EQ(1235.0, nearbyint(1234.01));
1068   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
1069 
1070   feclearexcept(FE_ALL_EXCEPT);
1071   ASSERT_EQ(1234.0f, nearbyintf(1234.0f));
1072   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
1073   ASSERT_EQ(1235.0f, nearbyintf(1234.01f));
1074   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
1075 
1076   feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
1077   ASSERT_EQ(1234.0, nearbyintl(1234.0L));
1078   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
1079   ASSERT_EQ(1235.0, nearbyintl(1234.01L));
1080   ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
1081 
1082   fesetround(FE_TOWARDZERO); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
1083   ASSERT_EQ(1234.0, nearbyint(1234.01));
1084   ASSERT_EQ(1234.0f, nearbyintf(1234.01f));
1085   ASSERT_EQ(1234.0, nearbyintl(1234.01L));
1086 }
1087 
TEST(MATH_TEST,lround)1088 TEST(MATH_TEST, lround) {
1089   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1090   fesetround(FE_UPWARD); // lround ignores the rounding mode.
1091   ASSERT_EQ(1234, lround(1234.01));
1092   ASSERT_EQ(1234, lroundf(1234.01f));
1093   ASSERT_EQ(1234, lroundl(1234.01L));
1094 }
1095 
TEST(MATH_TEST,llround)1096 TEST(MATH_TEST, llround) {
1097   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1098   fesetround(FE_UPWARD); // llround ignores the rounding mode.
1099   ASSERT_EQ(1234L, llround(1234.01));
1100   ASSERT_EQ(1234L, llroundf(1234.01f));
1101   ASSERT_EQ(1234L, llroundl(1234.01L));
1102 }
1103 
TEST(MATH_TEST,ilogb)1104 TEST(MATH_TEST, ilogb) {
1105   ASSERT_EQ(FP_ILOGB0, ilogb(0.0));
1106   ASSERT_EQ(FP_ILOGBNAN, ilogb(nan("")));
1107   ASSERT_EQ(INT_MAX, ilogb(HUGE_VAL));
1108   ASSERT_EQ(INT_MAX, ilogb(-HUGE_VAL));
1109   ASSERT_EQ(0, ilogb(1.0));
1110   ASSERT_EQ(3, ilogb(10.0));
1111 }
1112 
TEST(MATH_TEST,ilogbf)1113 TEST(MATH_TEST, ilogbf) {
1114   ASSERT_EQ(FP_ILOGB0, ilogbf(0.0f));
1115   ASSERT_EQ(FP_ILOGBNAN, ilogbf(nanf("")));
1116   ASSERT_EQ(INT_MAX, ilogbf(HUGE_VALF));
1117   ASSERT_EQ(INT_MAX, ilogbf(-HUGE_VALF));
1118   ASSERT_EQ(0, ilogbf(1.0f));
1119   ASSERT_EQ(3, ilogbf(10.0f));
1120 }
1121 
TEST(MATH_TEST,ilogbl)1122 TEST(MATH_TEST, ilogbl) {
1123   ASSERT_EQ(FP_ILOGB0, ilogbl(0.0L));
1124   ASSERT_EQ(FP_ILOGBNAN, ilogbl(nanl("")));
1125   ASSERT_EQ(INT_MAX, ilogbl(HUGE_VALL));
1126   ASSERT_EQ(INT_MAX, ilogbl(-HUGE_VALL));
1127   ASSERT_EQ(0L, ilogbl(1.0L));
1128   ASSERT_EQ(3L, ilogbl(10.0L));
1129 }
1130 
TEST(MATH_TEST,logb)1131 TEST(MATH_TEST, logb) {
1132   ASSERT_EQ(-HUGE_VAL, logb(0.0));
1133   ASSERT_TRUE(isnan(logb(nan(""))));
1134   ASSERT_TRUE(isinf(logb(HUGE_VAL)));
1135   ASSERT_TRUE(isinf(logb(-HUGE_VAL)));
1136   ASSERT_EQ(0.0, logb(1.0));
1137   ASSERT_EQ(3.0, logb(10.0));
1138 }
1139 
TEST(MATH_TEST,logbf)1140 TEST(MATH_TEST, logbf) {
1141   ASSERT_EQ(-HUGE_VALF, logbf(0.0f));
1142   ASSERT_TRUE(isnanf(logbf(nanf(""))));
1143   ASSERT_TRUE(isinff(logbf(HUGE_VALF)));
1144   ASSERT_TRUE(isinff(logbf(-HUGE_VALF)));
1145   ASSERT_EQ(0.0f, logbf(1.0f));
1146   ASSERT_EQ(3.0f, logbf(10.0f));
1147 }
1148 
TEST(MATH_TEST,logbl)1149 TEST(MATH_TEST, logbl) {
1150   ASSERT_EQ(-HUGE_VAL, logbl(0.0L));
1151   ASSERT_TRUE(isnan(logbl(nanl(""))));
1152   ASSERT_TRUE(isinf(logbl(HUGE_VALL)));
1153   ASSERT_TRUE(isinf(logbl(-HUGE_VALL)));
1154   ASSERT_EQ(0.0L, logbl(1.0L));
1155   ASSERT_EQ(3.0L, logbl(10.0L));
1156 }
1157 
TEST(MATH_TEST,log1p)1158 TEST(MATH_TEST, log1p) {
1159   ASSERT_EQ(-HUGE_VAL, log1p(-1.0));
1160   ASSERT_TRUE(isnan(log1p(nan(""))));
1161   ASSERT_TRUE(isinf(log1p(HUGE_VAL)));
1162   ASSERT_TRUE(isnan(log1p(-HUGE_VAL)));
1163   ASSERT_DOUBLE_EQ(1.0, log1p(M_E - 1.0));
1164 }
1165 
TEST(MATH_TEST,log1pf)1166 TEST(MATH_TEST, log1pf) {
1167   ASSERT_EQ(-HUGE_VALF, log1pf(-1.0f));
1168   ASSERT_TRUE(isnanf(log1pf(nanf(""))));
1169   ASSERT_TRUE(isinff(log1pf(HUGE_VALF)));
1170   ASSERT_TRUE(isnanf(log1pf(-HUGE_VALF)));
1171   ASSERT_FLOAT_EQ(1.0f, log1pf(static_cast<float>(M_E) - 1.0f));
1172 }
1173 
TEST(MATH_TEST,log1pl)1174 TEST(MATH_TEST, log1pl) {
1175   ASSERT_EQ(-HUGE_VALL, log1pl(-1.0L));
1176   ASSERT_TRUE(isnanl(log1pl(nanl(""))));
1177   ASSERT_TRUE(isinfl(log1pl(HUGE_VALL)));
1178   ASSERT_TRUE(isnanl(log1pl(-HUGE_VALL)));
1179   ASSERT_DOUBLE_EQ(1.0L, log1pl(M_E - 1.0L));
1180 }
1181 
TEST(MATH_TEST,fdim)1182 TEST(MATH_TEST, fdim) {
1183   ASSERT_DOUBLE_EQ(0.0, fdim(1.0, 1.0));
1184   ASSERT_DOUBLE_EQ(1.0, fdim(2.0, 1.0));
1185   ASSERT_DOUBLE_EQ(0.0, fdim(1.0, 2.0));
1186 }
1187 
TEST(MATH_TEST,fdimf)1188 TEST(MATH_TEST, fdimf) {
1189   ASSERT_FLOAT_EQ(0.0f, fdimf(1.0f, 1.0f));
1190   ASSERT_FLOAT_EQ(1.0f, fdimf(2.0f, 1.0f));
1191   ASSERT_FLOAT_EQ(0.0f, fdimf(1.0f, 2.0f));
1192 }
1193 
TEST(MATH_TEST,fdiml)1194 TEST(MATH_TEST, fdiml) {
1195   ASSERT_DOUBLE_EQ(0.0L, fdiml(1.0L, 1.0L));
1196   ASSERT_DOUBLE_EQ(1.0L, fdiml(2.0L, 1.0L));
1197   ASSERT_DOUBLE_EQ(0.0L, fdiml(1.0L, 2.0L));
1198 }
1199 
TEST(MATH_TEST,round)1200 TEST(MATH_TEST, round) {
1201   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1202   fesetround(FE_TOWARDZERO); // round ignores the rounding mode and always rounds away from zero.
1203   ASSERT_DOUBLE_EQ(1.0, round(0.5));
1204   ASSERT_DOUBLE_EQ(-1.0, round(-0.5));
1205   ASSERT_DOUBLE_EQ(0.0, round(0.0));
1206   ASSERT_DOUBLE_EQ(-0.0, round(-0.0));
1207   ASSERT_TRUE(isnan(round(nan(""))));
1208   ASSERT_DOUBLE_EQ(HUGE_VAL, round(HUGE_VAL));
1209   ASSERT_DOUBLE_EQ(-HUGE_VAL, round(-HUGE_VAL));
1210 }
1211 
TEST(MATH_TEST,roundf)1212 TEST(MATH_TEST, roundf) {
1213   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1214   fesetround(FE_TOWARDZERO); // roundf ignores the rounding mode and always rounds away from zero.
1215   ASSERT_FLOAT_EQ(1.0f, roundf(0.5f));
1216   ASSERT_FLOAT_EQ(-1.0f, roundf(-0.5f));
1217   ASSERT_FLOAT_EQ(0.0f, roundf(0.0f));
1218   ASSERT_FLOAT_EQ(-0.0f, roundf(-0.0f));
1219   ASSERT_TRUE(isnanf(roundf(nanf(""))));
1220   ASSERT_FLOAT_EQ(HUGE_VALF, roundf(HUGE_VALF));
1221   ASSERT_FLOAT_EQ(-HUGE_VALF, roundf(-HUGE_VALF));
1222 }
1223 
TEST(MATH_TEST,roundl)1224 TEST(MATH_TEST, roundl) {
1225   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1226   fesetround(FE_TOWARDZERO); // roundl ignores the rounding mode and always rounds away from zero.
1227   ASSERT_DOUBLE_EQ(1.0L, roundl(0.5L));
1228   ASSERT_DOUBLE_EQ(-1.0L, roundl(-0.5L));
1229   ASSERT_DOUBLE_EQ(0.0L, roundl(0.0L));
1230   ASSERT_DOUBLE_EQ(-0.0L, roundl(-0.0L));
1231   ASSERT_TRUE(isnan(roundl(nanl(""))));
1232   ASSERT_DOUBLE_EQ(HUGE_VALL, roundl(HUGE_VALL));
1233   ASSERT_DOUBLE_EQ(-HUGE_VALL, roundl(-HUGE_VALL));
1234 }
1235 
TEST(MATH_TEST,trunc)1236 TEST(MATH_TEST, trunc) {
1237   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1238   fesetround(FE_UPWARD); // trunc ignores the rounding mode and always rounds toward zero.
1239   ASSERT_DOUBLE_EQ(1.0, trunc(1.5));
1240   ASSERT_DOUBLE_EQ(-1.0, trunc(-1.5));
1241   ASSERT_DOUBLE_EQ(0.0, trunc(0.0));
1242   ASSERT_DOUBLE_EQ(-0.0, trunc(-0.0));
1243   ASSERT_TRUE(isnan(trunc(nan(""))));
1244   ASSERT_DOUBLE_EQ(HUGE_VAL, trunc(HUGE_VAL));
1245   ASSERT_DOUBLE_EQ(-HUGE_VAL, trunc(-HUGE_VAL));
1246 }
1247 
TEST(MATH_TEST,truncf)1248 TEST(MATH_TEST, truncf) {
1249   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1250   fesetround(FE_UPWARD); // truncf ignores the rounding mode and always rounds toward zero.
1251   ASSERT_FLOAT_EQ(1.0f, truncf(1.5f));
1252   ASSERT_FLOAT_EQ(-1.0f, truncf(-1.5f));
1253   ASSERT_FLOAT_EQ(0.0f, truncf(0.0f));
1254   ASSERT_FLOAT_EQ(-0.0f, truncf(-0.0f));
1255   ASSERT_TRUE(isnan(truncf(nanf(""))));
1256   ASSERT_FLOAT_EQ(HUGE_VALF, truncf(HUGE_VALF));
1257   ASSERT_FLOAT_EQ(-HUGE_VALF, truncf(-HUGE_VALF));
1258 }
1259 
TEST(MATH_TEST,truncl)1260 TEST(MATH_TEST, truncl) {
1261   auto guard = android::base::make_scope_guard([]() { fesetenv(FE_DFL_ENV); });
1262   fesetround(FE_UPWARD); // truncl ignores the rounding mode and always rounds toward zero.
1263   ASSERT_DOUBLE_EQ(1.0L, truncl(1.5L));
1264   ASSERT_DOUBLE_EQ(-1.0L, truncl(-1.5L));
1265   ASSERT_DOUBLE_EQ(0.0L, truncl(0.0L));
1266   ASSERT_DOUBLE_EQ(-0.0L, truncl(-0.0L));
1267   ASSERT_TRUE(isnan(truncl(nan(""))));
1268   ASSERT_DOUBLE_EQ(HUGE_VALL, truncl(HUGE_VALL));
1269   ASSERT_DOUBLE_EQ(-HUGE_VALL, truncl(-HUGE_VALL));
1270 }
1271 
TEST(MATH_TEST,nextafter)1272 TEST(MATH_TEST, nextafter) {
1273   ASSERT_DOUBLE_EQ(0.0, nextafter(0.0, 0.0));
1274   ASSERT_DOUBLE_EQ(4.9406564584124654e-324, nextafter(0.0, 1.0));
1275   ASSERT_DOUBLE_EQ(-4.9406564584124654e-324, nextafter(0.0, -1.0));
1276 }
1277 
TEST(MATH_TEST,nextafterf)1278 TEST(MATH_TEST, nextafterf) {
1279   ASSERT_FLOAT_EQ(0.0f, nextafterf(0.0f, 0.0f));
1280   ASSERT_FLOAT_EQ(1.4012985e-45f, nextafterf(0.0f, 1.0f));
1281   ASSERT_FLOAT_EQ(-1.4012985e-45f, nextafterf(0.0f, -1.0f));
1282 }
1283 
TEST(MATH_TEST,nextafterl)1284 TEST(MATH_TEST, nextafterl) {
1285   ASSERT_DOUBLE_EQ(0.0L, nextafterl(0.0L, 0.0L));
1286   // Use a runtime value to accomodate the case when
1287   // sizeof(double) == sizeof(long double)
1288   long double smallest_positive = ldexpl(1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG);
1289   ASSERT_DOUBLE_EQ(smallest_positive, nextafterl(0.0L, 1.0L));
1290   ASSERT_DOUBLE_EQ(-smallest_positive, nextafterl(0.0L, -1.0L));
1291 }
1292 
TEST(MATH_TEST,nexttoward)1293 TEST(MATH_TEST, nexttoward) {
1294   ASSERT_DOUBLE_EQ(0.0, nexttoward(0.0, 0.0L));
1295   ASSERT_DOUBLE_EQ(4.9406564584124654e-324, nexttoward(0.0, 1.0L));
1296   ASSERT_DOUBLE_EQ(-4.9406564584124654e-324, nexttoward(0.0, -1.0L));
1297 }
1298 
TEST(MATH_TEST,nexttowardf)1299 TEST(MATH_TEST, nexttowardf) {
1300   ASSERT_FLOAT_EQ(0.0f, nexttowardf(0.0f, 0.0L));
1301   ASSERT_FLOAT_EQ(1.4012985e-45f, nexttowardf(0.0f, 1.0L));
1302   ASSERT_FLOAT_EQ(-1.4012985e-45f, nexttowardf(0.0f, -1.0L));
1303 }
1304 
TEST(MATH_TEST,nexttowardl)1305 TEST(MATH_TEST, nexttowardl) {
1306   ASSERT_DOUBLE_EQ(0.0L, nexttowardl(0.0L, 0.0L));
1307   // Use a runtime value to accomodate the case when
1308   // sizeof(double) == sizeof(long double)
1309   long double smallest_positive = ldexpl(1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG);
1310   ASSERT_DOUBLE_EQ(smallest_positive, nexttowardl(0.0L, 1.0L));
1311   ASSERT_DOUBLE_EQ(-smallest_positive, nexttowardl(0.0L, -1.0L));
1312 }
1313 
TEST(MATH_TEST,copysign)1314 TEST(MATH_TEST, copysign) {
1315   ASSERT_DOUBLE_EQ(0.0, copysign(0.0, 1.0));
1316   ASSERT_DOUBLE_EQ(-0.0, copysign(0.0, -1.0));
1317   ASSERT_DOUBLE_EQ(2.0, copysign(2.0, 1.0));
1318   ASSERT_DOUBLE_EQ(-2.0, copysign(2.0, -1.0));
1319 }
1320 
TEST(MATH_TEST,copysignf)1321 TEST(MATH_TEST, copysignf) {
1322   ASSERT_FLOAT_EQ(0.0f, copysignf(0.0f, 1.0f));
1323   ASSERT_FLOAT_EQ(-0.0f, copysignf(0.0f, -1.0f));
1324   ASSERT_FLOAT_EQ(2.0f, copysignf(2.0f, 1.0f));
1325   ASSERT_FLOAT_EQ(-2.0f, copysignf(2.0f, -1.0f));
1326 }
1327 
TEST(MATH_TEST,copysignl)1328 TEST(MATH_TEST, copysignl) {
1329   ASSERT_DOUBLE_EQ(0.0L, copysignl(0.0L, 1.0L));
1330   ASSERT_DOUBLE_EQ(-0.0L, copysignl(0.0L, -1.0L));
1331   ASSERT_DOUBLE_EQ(2.0L, copysignl(2.0L, 1.0L));
1332   ASSERT_DOUBLE_EQ(-2.0L, copysignl(2.0L, -1.0L));
1333 }
1334 
TEST(MATH_TEST,significand)1335 TEST(MATH_TEST, significand) {
1336   ASSERT_DOUBLE_EQ(0.0, significand(0.0));
1337   ASSERT_DOUBLE_EQ(1.2, significand(1.2));
1338   ASSERT_DOUBLE_EQ(1.53125, significand(12.25));
1339 }
1340 
TEST(MATH_TEST,significandf)1341 TEST(MATH_TEST, significandf) {
1342   ASSERT_FLOAT_EQ(0.0f, significandf(0.0f));
1343   ASSERT_FLOAT_EQ(1.2f, significandf(1.2f));
1344   ASSERT_FLOAT_EQ(1.53125f, significandf(12.25f));
1345 }
1346 
TEST(MATH_TEST,significandl)1347 TEST(MATH_TEST, significandl) {
1348   ASSERT_DOUBLE_EQ(0.0L, significandl(0.0L));
1349   ASSERT_DOUBLE_EQ(1.2L, significandl(1.2L));
1350   ASSERT_DOUBLE_EQ(1.53125L, significandl(12.25L));
1351 }
1352 
TEST(MATH_TEST,scalb)1353 TEST(MATH_TEST, scalb) {
1354   ASSERT_DOUBLE_EQ(12.0, scalb(3.0, 2.0));
1355 }
1356 
TEST(MATH_TEST,scalbf)1357 TEST(MATH_TEST, scalbf) {
1358   ASSERT_FLOAT_EQ(12.0f, scalbf(3.0f, 2.0f));
1359 }
1360 
TEST(MATH_TEST,scalbln)1361 TEST(MATH_TEST, scalbln) {
1362   ASSERT_DOUBLE_EQ(12.0, scalbln(3.0, 2L));
1363 }
1364 
TEST(MATH_TEST,scalblnf)1365 TEST(MATH_TEST, scalblnf) {
1366   ASSERT_FLOAT_EQ(12.0f, scalblnf(3.0f, 2L));
1367 }
1368 
TEST(MATH_TEST,scalblnl)1369 TEST(MATH_TEST, scalblnl) {
1370   ASSERT_DOUBLE_EQ(12.0L, scalblnl(3.0L, 2L));
1371 }
1372 
TEST(MATH_TEST,scalbn)1373 TEST(MATH_TEST, scalbn) {
1374   ASSERT_DOUBLE_EQ(12.0, scalbn(3.0, 2));
1375 }
1376 
TEST(MATH_TEST,scalbnf)1377 TEST(MATH_TEST, scalbnf) {
1378   ASSERT_FLOAT_EQ(12.0f, scalbnf(3.0f, 2));
1379 }
1380 
TEST(MATH_TEST,scalbnl)1381 TEST(MATH_TEST, scalbnl) {
1382   ASSERT_DOUBLE_EQ(12.0L, scalbnl(3.0L, 2));
1383 }
1384 
TEST(MATH_TEST,gamma)1385 TEST(MATH_TEST, gamma) {
1386   ASSERT_DOUBLE_EQ(log(24.0), gamma(5.0));
1387 }
1388 
TEST(MATH_TEST,gammaf)1389 TEST(MATH_TEST, gammaf) {
1390   ASSERT_FLOAT_EQ(logf(24.0f), gammaf(5.0f));
1391 }
1392 
TEST(MATH_TEST,gamma_r)1393 TEST(MATH_TEST, gamma_r) {
1394 #if defined(__BIONIC__)
1395   int sign;
1396   ASSERT_DOUBLE_EQ(log(24.0), gamma_r(5.0, &sign));
1397   ASSERT_EQ(1, sign);
1398 #else // __BIONIC__
1399   GTEST_SKIP() << "glibc doesn't have gamma_r";
1400 #endif // __BIONIC__
1401 }
1402 
TEST(MATH_TEST,gammaf_r)1403 TEST(MATH_TEST, gammaf_r) {
1404 #if defined(__BIONIC__)
1405   int sign;
1406   ASSERT_FLOAT_EQ(logf(24.0f), gammaf_r(5.0f, &sign));
1407   ASSERT_EQ(1, sign);
1408 #else // __BIONIC__
1409   GTEST_SKIP() << "glibc doesn't have gammaf_r";
1410 #endif // __BIONIC__
1411 }
1412 
TEST(MATH_TEST,lgamma)1413 TEST(MATH_TEST, lgamma) {
1414   ASSERT_DOUBLE_EQ(log(24.0), lgamma(5.0));
1415 }
1416 
TEST(MATH_TEST,lgammaf)1417 TEST(MATH_TEST, lgammaf) {
1418   ASSERT_FLOAT_EQ(logf(24.0f), lgammaf(5.0f));
1419 }
1420 
TEST(MATH_TEST,lgammal)1421 TEST(MATH_TEST, lgammal) {
1422   ASSERT_DOUBLE_EQ(logl(24.0L), lgammal(5.0L));
1423 }
1424 
TEST(MATH_TEST,lgamma_r)1425 TEST(MATH_TEST, lgamma_r) {
1426   int sign;
1427   ASSERT_DOUBLE_EQ(log(24.0), lgamma_r(5.0, &sign));
1428   ASSERT_EQ(1, sign);
1429 }
1430 
TEST(MATH_TEST,lgamma_r_17471883)1431 TEST(MATH_TEST, lgamma_r_17471883) {
1432   int sign;
1433 
1434   sign = 0;
1435   ASSERT_DOUBLE_EQ(HUGE_VAL, lgamma_r(0.0, &sign));
1436   ASSERT_EQ(1, sign);
1437   sign = 0;
1438   ASSERT_DOUBLE_EQ(HUGE_VAL, lgamma_r(-0.0, &sign));
1439   ASSERT_EQ(-1, sign);
1440 }
1441 
TEST(MATH_TEST,lgammaf_r)1442 TEST(MATH_TEST, lgammaf_r) {
1443   int sign;
1444   ASSERT_FLOAT_EQ(logf(24.0f), lgammaf_r(5.0f, &sign));
1445   ASSERT_EQ(1, sign);
1446 }
1447 
TEST(MATH_TEST,lgammaf_r_17471883)1448 TEST(MATH_TEST, lgammaf_r_17471883) {
1449   int sign;
1450 
1451   sign = 0;
1452   ASSERT_FLOAT_EQ(HUGE_VALF, lgammaf_r(0.0f, &sign));
1453   ASSERT_EQ(1, sign);
1454   sign = 0;
1455   ASSERT_FLOAT_EQ(HUGE_VALF, lgammaf_r(-0.0f, &sign));
1456   ASSERT_EQ(-1, sign);
1457 }
1458 
TEST(MATH_TEST,lgammal_r)1459 TEST(MATH_TEST, lgammal_r) {
1460   int sign;
1461   ASSERT_DOUBLE_EQ(log(24.0L), lgamma_r(5.0L, &sign));
1462   ASSERT_EQ(1, sign);
1463 }
1464 
TEST(MATH_TEST,lgammal_r_17471883)1465 TEST(MATH_TEST, lgammal_r_17471883) {
1466   int sign;
1467 
1468   sign = 0;
1469   ASSERT_DOUBLE_EQ(HUGE_VAL, lgammal_r(0.0L, &sign));
1470   ASSERT_EQ(1, sign);
1471   sign = 0;
1472   ASSERT_DOUBLE_EQ(HUGE_VAL, lgammal_r(-0.0L, &sign));
1473   ASSERT_EQ(-1, sign);
1474 }
1475 
TEST(MATH_TEST,tgamma_NaN)1476 TEST(MATH_TEST, tgamma_NaN) {
1477   ASSERT_TRUE(isnan(tgamma(nan(""))));
1478   ASSERT_TRUE(isnanf(tgammaf(nanf(""))));
1479   ASSERT_TRUE(isnanl(tgammal(nanl(""))));
1480 }
1481 
TEST(MATH_TEST,tgamma_inf)1482 TEST(MATH_TEST, tgamma_inf) {
1483   ASSERT_TRUE(isinf(tgamma(HUGE_VAL)));
1484   ASSERT_TRUE(isinff(tgammaf(HUGE_VALF)));
1485   ASSERT_TRUE(isinfl(tgammal(HUGE_VALL)));
1486 }
1487 
TEST(MATH_TEST,tgamma_negative)1488 TEST(MATH_TEST, tgamma_negative) {
1489   ASSERT_TRUE(isnan(tgamma(-1.0)));
1490   ASSERT_TRUE(isnanf(tgammaf(-1.0f)));
1491   ASSERT_TRUE(isnanl(tgammal(-1.0L)));
1492 }
1493 
TEST(MATH_TEST,tgamma)1494 TEST(MATH_TEST, tgamma) {
1495   ASSERT_DOUBLE_EQ(24.0, tgamma(5.0));
1496   ASSERT_DOUBLE_EQ(120.0, tgamma(6.0));
1497   ASSERT_TRUE(isinf(tgamma(172.0)));
1498 }
1499 
TEST(MATH_TEST,tgammaf)1500 TEST(MATH_TEST, tgammaf) {
1501   ASSERT_FLOAT_EQ(24.0f, tgammaf(5.0f));
1502   ASSERT_FLOAT_EQ(120.0f, tgammaf(6.0f));
1503   ASSERT_TRUE(isinff(tgammaf(172.0f)));
1504 }
1505 
TEST(MATH_TEST,tgammal)1506 TEST(MATH_TEST, tgammal) {
1507   ASSERT_DOUBLE_EQ(24.0L, tgammal(5.0L));
1508   ASSERT_DOUBLE_EQ(120.0L, tgammal(6.0L));
1509   ASSERT_TRUE(isinf(tgammal(172.0L)));
1510 }
1511 
TEST(MATH_TEST,j0)1512 TEST(MATH_TEST, j0) {
1513   ASSERT_DOUBLE_EQ(1.0, j0(0.0));
1514   ASSERT_DOUBLE_EQ(0.76519768655796661, j0(1.0));
1515 }
1516 
TEST(MATH_TEST,j0f)1517 TEST(MATH_TEST, j0f) {
1518   ASSERT_FLOAT_EQ(1.0f, j0f(0.0f));
1519   ASSERT_FLOAT_EQ(0.76519769f, j0f(1.0f));
1520 }
1521 
TEST(MATH_TEST,j1)1522 TEST(MATH_TEST, j1) {
1523   ASSERT_DOUBLE_EQ(0.0, j1(0.0));
1524   ASSERT_DOUBLE_EQ(0.44005058574493355, j1(1.0));
1525 }
1526 
TEST(MATH_TEST,j1f)1527 TEST(MATH_TEST, j1f) {
1528   ASSERT_FLOAT_EQ(0.0f, j1f(0.0f));
1529   ASSERT_FLOAT_EQ(0.44005057f, j1f(1.0f));
1530 }
1531 
TEST(MATH_TEST,jn)1532 TEST(MATH_TEST, jn) {
1533   ASSERT_DOUBLE_EQ(0.0, jn(4, 0.0));
1534   ASSERT_DOUBLE_EQ(0.0024766389641099553, jn(4, 1.0));
1535 }
1536 
TEST(MATH_TEST,jnf)1537 TEST(MATH_TEST, jnf) {
1538   ASSERT_FLOAT_EQ(0.0f, jnf(4, 0.0f));
1539   ASSERT_FLOAT_EQ(0.0024766389f, jnf(4, 1.0f));
1540 }
1541 
TEST(MATH_TEST,y0)1542 TEST(MATH_TEST, y0) {
1543   ASSERT_DOUBLE_EQ(-HUGE_VAL, y0(0.0));
1544   ASSERT_DOUBLE_EQ(0.08825696421567697, y0(1.0));
1545 }
1546 
TEST(MATH_TEST,y0f)1547 TEST(MATH_TEST, y0f) {
1548   ASSERT_FLOAT_EQ(-HUGE_VALF, y0f(0.0f));
1549   ASSERT_FLOAT_EQ(0.088256963f, y0f(1.0f));
1550 }
1551 
TEST(MATH_TEST,y1)1552 TEST(MATH_TEST, y1) {
1553   ASSERT_DOUBLE_EQ(-HUGE_VAL, y1(0.0));
1554   ASSERT_DOUBLE_EQ(-0.78121282130028868, y1(1.0));
1555 }
1556 
TEST(MATH_TEST,y1f)1557 TEST(MATH_TEST, y1f) {
1558   ASSERT_FLOAT_EQ(-HUGE_VALF, y1f(0.0f));
1559   ASSERT_FLOAT_EQ(-0.78121281f, y1f(1.0f));
1560 }
1561 
TEST(MATH_TEST,yn)1562 TEST(MATH_TEST, yn) {
1563   ASSERT_DOUBLE_EQ(-HUGE_VAL, yn(4, 0.0));
1564   ASSERT_DOUBLE_EQ(-33.278423028972114, yn(4, 1.0));
1565 }
1566 
TEST(MATH_TEST,ynf)1567 TEST(MATH_TEST, ynf) {
1568   ASSERT_FLOAT_EQ(-HUGE_VALF, ynf(4, 0.0f));
1569   ASSERT_FLOAT_EQ(-33.278423f, ynf(4, 1.0f));
1570 }
1571 
TEST(MATH_TEST,frexp)1572 TEST(MATH_TEST, frexp) {
1573   int exp;
1574   double dr = frexp(1024.0, &exp);
1575   ASSERT_DOUBLE_EQ(1024.0, scalbn(dr, exp));
1576 }
1577 
TEST(MATH_TEST,frexpf)1578 TEST(MATH_TEST, frexpf) {
1579   int exp;
1580   float fr = frexpf(1024.0f, &exp);
1581   ASSERT_FLOAT_EQ(1024.0f, scalbnf(fr, exp));
1582 }
1583 
TEST(MATH_TEST,frexpl)1584 TEST(MATH_TEST, frexpl) {
1585   int exp;
1586   long double ldr = frexpl(1024.0L, &exp);
1587   ASSERT_DOUBLE_EQ(1024.0L, scalbnl(ldr, exp));
1588 }
1589 
TEST(MATH_TEST,modf)1590 TEST(MATH_TEST, modf) {
1591   double di;
1592   double df = modf(123.75, &di);
1593   ASSERT_DOUBLE_EQ(123.0, di);
1594   ASSERT_DOUBLE_EQ(0.75, df);
1595 }
1596 
TEST(MATH_TEST,modff)1597 TEST(MATH_TEST, modff) {
1598   float fi;
1599   float ff = modff(123.75f, &fi);
1600   ASSERT_FLOAT_EQ(123.0f, fi);
1601   ASSERT_FLOAT_EQ(0.75f, ff);
1602 }
1603 
TEST(MATH_TEST,modfl)1604 TEST(MATH_TEST, modfl) {
1605   long double ldi;
1606   long double ldf = modfl(123.75L, &ldi);
1607   ASSERT_DOUBLE_EQ(123.0L, ldi);
1608   ASSERT_DOUBLE_EQ(0.75L, ldf);
1609 }
1610 
TEST(MATH_TEST,remquo)1611 TEST(MATH_TEST, remquo) {
1612   int q;
1613   double d = remquo(13.0, 4.0, &q);
1614   ASSERT_EQ(3, q);
1615   ASSERT_DOUBLE_EQ(1.0, d);
1616 
1617   // If x or y is a NaN, NaN is returned.
1618   ASSERT_TRUE(isnan(remquo(nan(""), 10.0, &q)));
1619   ASSERT_TRUE(isnan(remquo(12.0, nan(""), &q)));
1620 
1621   // If x is an infinity, NaN is returned.
1622   ASSERT_TRUE(isnan(remquo(HUGE_VAL, 10.0, &q)));
1623   ASSERT_TRUE(isnan(remquo(-HUGE_VAL, 10.0, &q)));
1624 
1625   // If y is 0, NaN is returned.
1626   ASSERT_TRUE(isnan(remquo(12.0, 0.0, &q)));
1627 }
1628 
TEST(MATH_TEST,remquof)1629 TEST(MATH_TEST, remquof) {
1630   int q;
1631   float f = remquof(13.0f, 4.0f, &q);
1632   ASSERT_EQ(3, q);
1633   ASSERT_FLOAT_EQ(1.0, f);
1634 
1635   // If x or y is a NaN, NaN is returned.
1636   ASSERT_TRUE(isnanf(remquof(nanf(""), 10.0f, &q)));
1637   ASSERT_TRUE(isnanf(remquof(12.0f, nanf(""), &q)));
1638 
1639   // If x is an infinity, NaN is returned.
1640   ASSERT_TRUE(isnanf(remquof(HUGE_VALF, 10.0f, &q)));
1641   ASSERT_TRUE(isnanf(remquof(-HUGE_VALF, 10.0f, &q)));
1642 
1643   // If y is 0, NaN is returned.
1644   ASSERT_TRUE(isnanf(remquof(12.0f, 0.0f, &q)));
1645 }
1646 
TEST(MATH_TEST,remquol)1647 TEST(MATH_TEST, remquol) {
1648   int q;
1649   long double ld = remquol(13.0L, 4.0L, &q);
1650   ASSERT_DOUBLE_EQ(3L, q);
1651   ASSERT_DOUBLE_EQ(1.0L, ld);
1652 
1653   // If x or y is a NaN, NaN is returned.
1654   ASSERT_TRUE(isnanl(remquol(nanl(""), 10.0L, &q)));
1655   ASSERT_TRUE(isnanl(remquol(12.0L, nanl(""), &q)));
1656 
1657   // If x is an infinity, NaN is returned.
1658   ASSERT_TRUE(isnanl(remquol(HUGE_VALL, 10.0L, &q)));
1659   ASSERT_TRUE(isnanl(remquol(-HUGE_VALL, 10.0L, &q)));
1660 
1661   // If y is 0, NaN is returned.
1662   ASSERT_TRUE(isnanl(remquol(12.0L, 0.0L, &q)));
1663 }
1664 
1665 // https://code.google.com/p/android/issues/detail?id=6697
TEST(MATH_TEST,frexpf_public_bug_6697)1666 TEST(MATH_TEST, frexpf_public_bug_6697) {
1667   int exp;
1668   float fr = frexpf(14.1f, &exp);
1669   ASSERT_FLOAT_EQ(14.1f, scalbnf(fr, exp));
1670 }
1671 
TEST(MATH_TEST,exp2_STRICT_ALIGN_OpenBSD_bug)1672 TEST(MATH_TEST, exp2_STRICT_ALIGN_OpenBSD_bug) {
1673   // OpenBSD/x86's libm had a bug here, but it was already fixed in FreeBSD:
1674   // http://svnweb.FreeBSD.org/base/head/lib/msun/src/math_private.h?revision=240827&view=markup
1675   ASSERT_DOUBLE_EQ(5.0, exp2(log2(5)));
1676   ASSERT_FLOAT_EQ(5.0f, exp2f(log2f(5)));
1677   ASSERT_DOUBLE_EQ(5.0L, exp2l(log2l(5)));
1678 }
1679 
TEST(MATH_TEST,nextafterl_OpenBSD_bug)1680 TEST(MATH_TEST, nextafterl_OpenBSD_bug) {
1681   // OpenBSD/x86's libm had a bug here.
1682   ASSERT_TRUE(nextafter(1.0, 0.0) - 1.0 < 0.0);
1683   ASSERT_TRUE(nextafterf(1.0f, 0.0f) - 1.0f < 0.0f);
1684   ASSERT_TRUE(nextafterl(1.0L, 0.0L) - 1.0L < 0.0L);
1685 }
1686 
1687 #include "math_data/acos_intel_data.h"
TEST(MATH_TEST,acos_intel)1688 TEST(MATH_TEST, acos_intel) {
1689   DoMathDataTest<1>(g_acos_intel_data, acos);
1690 }
1691 
1692 #include "math_data/acosf_intel_data.h"
TEST(MATH_TEST,acosf_intel)1693 TEST(MATH_TEST, acosf_intel) {
1694   DoMathDataTest<1>(g_acosf_intel_data, acosf);
1695 }
1696 
1697 #include "math_data/acosh_intel_data.h"
TEST(MATH_TEST,acosh_intel)1698 TEST(MATH_TEST, acosh_intel) {
1699   DoMathDataTest<2>(g_acosh_intel_data, acosh);
1700 }
1701 
1702 #include "math_data/acoshf_intel_data.h"
TEST(MATH_TEST,acoshf_intel)1703 TEST(MATH_TEST, acoshf_intel) {
1704   DoMathDataTest<2>(g_acoshf_intel_data, acoshf);
1705 }
1706 
1707 #include "math_data/asin_intel_data.h"
TEST(MATH_TEST,asin_intel)1708 TEST(MATH_TEST, asin_intel) {
1709   DoMathDataTest<1>(g_asin_intel_data, asin);
1710 }
1711 
1712 #include "math_data/asinf_intel_data.h"
TEST(MATH_TEST,asinf_intel)1713 TEST(MATH_TEST, asinf_intel) {
1714   DoMathDataTest<1>(g_asinf_intel_data, asinf);
1715 }
1716 
1717 #include "math_data/asinh_intel_data.h"
TEST(MATH_TEST,asinh_intel)1718 TEST(MATH_TEST, asinh_intel) {
1719   DoMathDataTest<2>(g_asinh_intel_data, asinh);
1720 }
1721 
1722 #include "math_data/asinhf_intel_data.h"
TEST(MATH_TEST,asinhf_intel)1723 TEST(MATH_TEST, asinhf_intel) {
1724   DoMathDataTest<2>(g_asinhf_intel_data, asinhf);
1725 }
1726 
1727 #include "math_data/atan2_intel_data.h"
TEST(MATH_TEST,atan2_intel)1728 TEST(MATH_TEST, atan2_intel) {
1729   DoMathDataTest<2>(g_atan2_intel_data, atan2);
1730 }
1731 
1732 #include "math_data/atan2f_intel_data.h"
TEST(MATH_TEST,atan2f_intel)1733 TEST(MATH_TEST, atan2f_intel) {
1734   DoMathDataTest<2>(g_atan2f_intel_data, atan2f);
1735 }
1736 
1737 #include "math_data/atan_intel_data.h"
TEST(MATH_TEST,atan_intel)1738 TEST(MATH_TEST, atan_intel) {
1739   DoMathDataTest<1>(g_atan_intel_data, atan);
1740 }
1741 
1742 #include "math_data/atanf_intel_data.h"
TEST(MATH_TEST,atanf_intel)1743 TEST(MATH_TEST, atanf_intel) {
1744   DoMathDataTest<1>(g_atanf_intel_data, atanf);
1745 }
1746 
1747 #include "math_data/atanh_intel_data.h"
TEST(MATH_TEST,atanh_intel)1748 TEST(MATH_TEST, atanh_intel) {
1749   DoMathDataTest<2>(g_atanh_intel_data, atanh);
1750 }
1751 
1752 #include "math_data/atanhf_intel_data.h"
TEST(MATH_TEST,atanhf_intel)1753 TEST(MATH_TEST, atanhf_intel) {
1754   DoMathDataTest<2>(g_atanhf_intel_data, atanhf);
1755 }
1756 
1757 #include "math_data/cbrt_intel_data.h"
TEST(MATH_TEST,cbrt_intel)1758 TEST(MATH_TEST, cbrt_intel) {
1759   DoMathDataTest<1>(g_cbrt_intel_data, cbrt);
1760 }
1761 
1762 #include "math_data/cbrtf_intel_data.h"
TEST(MATH_TEST,cbrtf_intel)1763 TEST(MATH_TEST, cbrtf_intel) {
1764   DoMathDataTest<1>(g_cbrtf_intel_data, cbrtf);
1765 }
1766 
1767 #include "math_data/ceil_intel_data.h"
TEST(MATH_TEST,ceil_intel)1768 TEST(MATH_TEST, ceil_intel) {
1769   DoMathDataTest<1>(g_ceil_intel_data, ceil);
1770 }
1771 
1772 #include "math_data/ceilf_intel_data.h"
TEST(MATH_TEST,ceilf_intel)1773 TEST(MATH_TEST, ceilf_intel) {
1774   DoMathDataTest<1>(g_ceilf_intel_data, ceilf);
1775 }
1776 
1777 #include "math_data/copysign_intel_data.h"
TEST(MATH_TEST,copysign_intel)1778 TEST(MATH_TEST, copysign_intel) {
1779   DoMathDataTest<1>(g_copysign_intel_data, copysign);
1780 }
1781 
1782 #include "math_data/copysignf_intel_data.h"
TEST(MATH_TEST,copysignf_intel)1783 TEST(MATH_TEST, copysignf_intel) {
1784   DoMathDataTest<1>(g_copysignf_intel_data, copysignf);
1785 }
1786 
1787 #include "math_data/cos_intel_data.h"
TEST(MATH_TEST,cos_intel)1788 TEST(MATH_TEST, cos_intel) {
1789   DoMathDataTest<1>(g_cos_intel_data, cos);
1790 }
1791 
1792 #include "math_data/cosf_intel_data.h"
TEST(MATH_TEST,cosf_intel)1793 TEST(MATH_TEST, cosf_intel) {
1794   DoMathDataTest<1>(g_cosf_intel_data, cosf);
1795 }
1796 
1797 #include "math_data/cosh_intel_data.h"
TEST(MATH_TEST,cosh_intel)1798 TEST(MATH_TEST, cosh_intel) {
1799   DoMathDataTest<2>(g_cosh_intel_data, cosh);
1800 }
1801 
1802 #include "math_data/coshf_intel_data.h"
TEST(MATH_TEST,coshf_intel)1803 TEST(MATH_TEST, coshf_intel) {
1804   DoMathDataTest<2>(g_coshf_intel_data, coshf);
1805 }
1806 
1807 #include "math_data/exp_intel_data.h"
TEST(MATH_TEST,exp_intel)1808 TEST(MATH_TEST, exp_intel) {
1809   DoMathDataTest<1>(g_exp_intel_data, exp);
1810 }
1811 
1812 #include "math_data/expf_intel_data.h"
TEST(MATH_TEST,expf_intel)1813 TEST(MATH_TEST, expf_intel) {
1814   DoMathDataTest<1>(g_expf_intel_data, expf);
1815 }
1816 
1817 #include "math_data/exp2_intel_data.h"
TEST(MATH_TEST,exp2_intel)1818 TEST(MATH_TEST, exp2_intel) {
1819   DoMathDataTest<1>(g_exp2_intel_data, exp2);
1820 }
1821 
1822 #include "math_data/exp2f_intel_data.h"
TEST(MATH_TEST,exp2f_intel)1823 TEST(MATH_TEST, exp2f_intel) {
1824   DoMathDataTest<1>(g_exp2f_intel_data, exp2f);
1825 }
1826 
1827 #include "math_data/expm1_intel_data.h"
TEST(MATH_TEST,expm1_intel)1828 TEST(MATH_TEST, expm1_intel) {
1829   DoMathDataTest<1>(g_expm1_intel_data, expm1);
1830 }
1831 
1832 #include "math_data/expm1f_intel_data.h"
TEST(MATH_TEST,expm1f_intel)1833 TEST(MATH_TEST, expm1f_intel) {
1834   DoMathDataTest<1>(g_expm1f_intel_data, expm1f);
1835 }
1836 
1837 #include "math_data/fabs_intel_data.h"
TEST(MATH_TEST,fabs_intel)1838 TEST(MATH_TEST, fabs_intel) {
1839   DoMathDataTest<1>(g_fabs_intel_data, fabs);
1840 }
1841 
1842 #include "math_data/fabsf_intel_data.h"
TEST(MATH_TEST,fabsf_intel)1843 TEST(MATH_TEST, fabsf_intel) {
1844   DoMathDataTest<1>(g_fabsf_intel_data, fabsf);
1845 }
1846 
1847 #include "math_data/fdim_intel_data.h"
TEST(MATH_TEST,fdim_intel)1848 TEST(MATH_TEST, fdim_intel) {
1849   DoMathDataTest<1>(g_fdim_intel_data, fdim);
1850 }
1851 
1852 #include "math_data/fdimf_intel_data.h"
TEST(MATH_TEST,fdimf_intel)1853 TEST(MATH_TEST, fdimf_intel) {
1854   DoMathDataTest<1>(g_fdimf_intel_data, fdimf);
1855 }
1856 
1857 #include "math_data/floor_intel_data.h"
TEST(MATH_TEST,floor_intel)1858 TEST(MATH_TEST, floor_intel) {
1859   DoMathDataTest<1>(g_floor_intel_data, floor);
1860 }
1861 
1862 #include "math_data/floorf_intel_data.h"
TEST(MATH_TEST,floorf_intel)1863 TEST(MATH_TEST, floorf_intel) {
1864   DoMathDataTest<1>(g_floorf_intel_data, floorf);
1865 }
1866 
1867 #include "math_data/fma_intel_data.h"
TEST(MATH_TEST,fma_intel)1868 TEST(MATH_TEST, fma_intel) {
1869   DoMathDataTest<1>(g_fma_intel_data, fma);
1870 }
1871 
1872 #include "math_data/fmaf_intel_data.h"
TEST(MATH_TEST,fmaf_intel)1873 TEST(MATH_TEST, fmaf_intel) {
1874   DoMathDataTest<1>(g_fmaf_intel_data, fmaf);
1875 }
1876 
1877 #include "math_data/fmax_intel_data.h"
TEST(MATH_TEST,fmax_intel)1878 TEST(MATH_TEST, fmax_intel) {
1879   DoMathDataTest<1>(g_fmax_intel_data, fmax);
1880 }
1881 
1882 #include "math_data/fmaxf_intel_data.h"
TEST(MATH_TEST,fmaxf_intel)1883 TEST(MATH_TEST, fmaxf_intel) {
1884   DoMathDataTest<1>(g_fmaxf_intel_data, fmaxf);
1885 }
1886 
1887 #include "math_data/fmin_intel_data.h"
TEST(MATH_TEST,fmin_intel)1888 TEST(MATH_TEST, fmin_intel) {
1889   DoMathDataTest<1>(g_fmin_intel_data, fmin);
1890 }
1891 
1892 #include "math_data/fminf_intel_data.h"
TEST(MATH_TEST,fminf_intel)1893 TEST(MATH_TEST, fminf_intel) {
1894   DoMathDataTest<1>(g_fminf_intel_data, fminf);
1895 }
1896 
1897 #include "math_data/fmod_intel_data.h"
TEST(MATH_TEST,fmod_intel)1898 TEST(MATH_TEST, fmod_intel) {
1899   DoMathDataTest<1>(g_fmod_intel_data, fmod);
1900 }
1901 
1902 #include "math_data/fmodf_intel_data.h"
TEST(MATH_TEST,fmodf_intel)1903 TEST(MATH_TEST, fmodf_intel) {
1904   DoMathDataTest<1>(g_fmodf_intel_data, fmodf);
1905 }
1906 
1907 #include "math_data/frexp_intel_data.h"
TEST(MATH_TEST,frexp_intel)1908 TEST(MATH_TEST, frexp_intel) {
1909   DoMathDataTest<1>(g_frexp_intel_data, frexp);
1910 }
1911 
1912 #include "math_data/frexpf_intel_data.h"
TEST(MATH_TEST,frexpf_intel)1913 TEST(MATH_TEST, frexpf_intel) {
1914   DoMathDataTest<1>(g_frexpf_intel_data, frexpf);
1915 }
1916 
1917 #include "math_data/hypot_intel_data.h"
TEST(MATH_TEST,hypot_intel)1918 TEST(MATH_TEST, hypot_intel) {
1919   DoMathDataTest<1>(g_hypot_intel_data, hypot);
1920 }
1921 
1922 #include "math_data/hypotf_intel_data.h"
TEST(MATH_TEST,hypotf_intel)1923 TEST(MATH_TEST, hypotf_intel) {
1924   DoMathDataTest<1>(g_hypotf_intel_data, hypotf);
1925 }
1926 
1927 #include "math_data/ilogb_intel_data.h"
TEST(MATH_TEST,ilogb_intel)1928 TEST(MATH_TEST, ilogb_intel) {
1929   DoMathDataTest<1>(g_ilogb_intel_data, ilogb);
1930 }
1931 
1932 #include "math_data/ilogbf_intel_data.h"
TEST(MATH_TEST,ilogbf_intel)1933 TEST(MATH_TEST, ilogbf_intel) {
1934   DoMathDataTest<1>(g_ilogbf_intel_data, ilogbf);
1935 }
1936 
1937 #include "math_data/ldexp_intel_data.h"
TEST(MATH_TEST,ldexp_intel)1938 TEST(MATH_TEST, ldexp_intel) {
1939   DoMathDataTest<1>(g_ldexp_intel_data, ldexp);
1940 }
1941 
1942 #include "math_data/ldexpf_intel_data.h"
TEST(MATH_TEST,ldexpf_intel)1943 TEST(MATH_TEST, ldexpf_intel) {
1944   DoMathDataTest<1>(g_ldexpf_intel_data, ldexpf);
1945 }
1946 
1947 #include "math_data/llrint_intel_data.h"
TEST(MATH_TEST,llrint_intel)1948 TEST(MATH_TEST, llrint_intel) {
1949   DoMathDataTest<1>(g_llrint_intel_data, llrint);
1950 }
1951 
1952 #include "math_data/llrintf_intel_data.h"
TEST(MATH_TEST,llrintf_intel)1953 TEST(MATH_TEST, llrintf_intel) {
1954   DoMathDataTest<1>(g_llrintf_intel_data, llrintf);
1955 }
1956 
1957 #include "math_data/log_intel_data.h"
TEST(MATH_TEST,log_intel)1958 TEST(MATH_TEST, log_intel) {
1959   DoMathDataTest<1>(g_log_intel_data, log);
1960 }
1961 
1962 #include "math_data/logf_intel_data.h"
TEST(MATH_TEST,logf_intel)1963 TEST(MATH_TEST, logf_intel) {
1964   DoMathDataTest<1>(g_logf_intel_data, logf);
1965 }
1966 
1967 #include "math_data/log10_intel_data.h"
TEST(MATH_TEST,log10_intel)1968 TEST(MATH_TEST, log10_intel) {
1969   DoMathDataTest<1>(g_log10_intel_data, log10);
1970 }
1971 
1972 #include "math_data/log10f_intel_data.h"
TEST(MATH_TEST,log10f_intel)1973 TEST(MATH_TEST, log10f_intel) {
1974   DoMathDataTest<1>(g_log10f_intel_data, log10f);
1975 }
1976 
1977 #include "math_data/log1p_intel_data.h"
TEST(MATH_TEST,log1p_intel)1978 TEST(MATH_TEST, log1p_intel) {
1979   DoMathDataTest<1>(g_log1p_intel_data, log1p);
1980 }
1981 
1982 #include "math_data/log1pf_intel_data.h"
TEST(MATH_TEST,log1pf_intel)1983 TEST(MATH_TEST, log1pf_intel) {
1984   DoMathDataTest<1>(g_log1pf_intel_data, log1pf);
1985 }
1986 
1987 #include "math_data/log2_intel_data.h"
TEST(MATH_TEST,log2_intel)1988 TEST(MATH_TEST, log2_intel) {
1989   DoMathDataTest<1>(g_log2_intel_data, log2);
1990 }
1991 
1992 #include "math_data/log2f_intel_data.h"
TEST(MATH_TEST,log2f_intel)1993 TEST(MATH_TEST, log2f_intel) {
1994   DoMathDataTest<1>(g_log2f_intel_data, log2f);
1995 }
1996 
1997 #include "math_data/logb_intel_data.h"
TEST(MATH_TEST,logb_intel)1998 TEST(MATH_TEST, logb_intel) {
1999   DoMathDataTest<1>(g_logb_intel_data, logb);
2000 }
2001 
2002 #include "math_data/logbf_intel_data.h"
TEST(MATH_TEST,logbf_intel)2003 TEST(MATH_TEST, logbf_intel) {
2004   DoMathDataTest<1>(g_logbf_intel_data, logbf);
2005 }
2006 
2007 #include "math_data/lrint_intel_data.h"
TEST(MATH_TEST,lrint_intel)2008 TEST(MATH_TEST, lrint_intel) {
2009   DoMathDataTest<1>(g_lrint_intel_data, lrint);
2010 }
2011 
2012 #include "math_data/lrintf_intel_data.h"
TEST(MATH_TEST,lrintf_intel)2013 TEST(MATH_TEST, lrintf_intel) {
2014   DoMathDataTest<1>(g_lrintf_intel_data, lrintf);
2015 }
2016 
2017 #include "math_data/modf_intel_data.h"
TEST(MATH_TEST,modf_intel)2018 TEST(MATH_TEST, modf_intel) {
2019   DoMathDataTest<1>(g_modf_intel_data, modf);
2020 }
2021 
2022 #include "math_data/modff_intel_data.h"
TEST(MATH_TEST,modff_intel)2023 TEST(MATH_TEST, modff_intel) {
2024   DoMathDataTest<1>(g_modff_intel_data, modff);
2025 }
2026 
2027 #include "math_data/nearbyint_intel_data.h"
TEST(MATH_TEST,nearbyint_intel)2028 TEST(MATH_TEST, nearbyint_intel) {
2029   DoMathDataTest<1>(g_nearbyint_intel_data, nearbyint);
2030 }
2031 
2032 #include "math_data/nearbyintf_intel_data.h"
TEST(MATH_TEST,nearbyintf_intel)2033 TEST(MATH_TEST, nearbyintf_intel) {
2034   DoMathDataTest<1>(g_nearbyintf_intel_data, nearbyintf);
2035 }
2036 
2037 #include "math_data/nextafter_intel_data.h"
TEST(MATH_TEST,nextafter_intel)2038 TEST(MATH_TEST, nextafter_intel) {
2039   DoMathDataTest<1>(g_nextafter_intel_data, nextafter);
2040 }
2041 
2042 #include "math_data/nextafterf_intel_data.h"
TEST(MATH_TEST,nextafterf_intel)2043 TEST(MATH_TEST, nextafterf_intel) {
2044   DoMathDataTest<1>(g_nextafterf_intel_data, nextafterf);
2045 }
2046 
2047 #include "math_data/pow_intel_data.h"
TEST(MATH_TEST,pow_intel)2048 TEST(MATH_TEST, pow_intel) {
2049   DoMathDataTest<1>(g_pow_intel_data, pow);
2050 }
2051 
2052 #include "math_data/powf_intel_data.h"
TEST(MATH_TEST,powf_intel)2053 TEST(MATH_TEST, powf_intel) {
2054   DoMathDataTest<1>(g_powf_intel_data, powf);
2055 }
2056 
2057 #include "math_data/remainder_intel_data.h"
TEST(MATH_TEST,remainder_intel)2058 TEST(MATH_TEST, remainder_intel) {
2059   DoMathDataTest<1>(g_remainder_intel_data, remainder);
2060 }
2061 
2062 #include "math_data/remainderf_intel_data.h"
TEST(MATH_TEST,remainderf_intel)2063 TEST(MATH_TEST, remainderf_intel) {
2064   DoMathDataTest<1>(g_remainderf_intel_data, remainderf);
2065 }
2066 
2067 #include "math_data/remquo_intel_data.h"
TEST(MATH_TEST,remquo_intel)2068 TEST(MATH_TEST, remquo_intel) {
2069   DoMathDataTest<1>(g_remquo_intel_data, remquo);
2070 }
2071 
2072 #include "math_data/remquof_intel_data.h"
TEST(MATH_TEST,remquof_intel)2073 TEST(MATH_TEST, remquof_intel) {
2074   DoMathDataTest<1>(g_remquof_intel_data, remquof);
2075 }
2076 
2077 #include "math_data/rint_intel_data.h"
TEST(MATH_TEST,rint_intel)2078 TEST(MATH_TEST, rint_intel) {
2079   DoMathDataTest<1>(g_rint_intel_data, rint);
2080 }
2081 
2082 #include "math_data/rintf_intel_data.h"
TEST(MATH_TEST,rintf_intel)2083 TEST(MATH_TEST, rintf_intel) {
2084   DoMathDataTest<1>(g_rintf_intel_data, rintf);
2085 }
2086 
2087 #include "math_data/round_intel_data.h"
TEST(MATH_TEST,round_intel)2088 TEST(MATH_TEST, round_intel) {
2089   DoMathDataTest<1>(g_round_intel_data, round);
2090 }
2091 
2092 #include "math_data/roundf_intel_data.h"
TEST(MATH_TEST,roundf_intel)2093 TEST(MATH_TEST, roundf_intel) {
2094   DoMathDataTest<1>(g_roundf_intel_data, roundf);
2095 }
2096 
2097 #include "math_data/scalb_intel_data.h"
TEST(MATH_TEST,scalb_intel)2098 TEST(MATH_TEST, scalb_intel) {
2099   DoMathDataTest<1>(g_scalb_intel_data, scalb);
2100 }
2101 
2102 #include "math_data/scalbf_intel_data.h"
TEST(MATH_TEST,scalbf_intel)2103 TEST(MATH_TEST, scalbf_intel) {
2104   DoMathDataTest<1>(g_scalbf_intel_data, scalbf);
2105 }
2106 
2107 #include "math_data/scalbn_intel_data.h"
TEST(MATH_TEST,scalbn_intel)2108 TEST(MATH_TEST, scalbn_intel) {
2109   DoMathDataTest<1>(g_scalbn_intel_data, scalbn);
2110 }
2111 
2112 #include "math_data/scalbnf_intel_data.h"
TEST(MATH_TEST,scalbnf_intel)2113 TEST(MATH_TEST, scalbnf_intel) {
2114   DoMathDataTest<1>(g_scalbnf_intel_data, scalbnf);
2115 }
2116 
2117 #include "math_data/significand_intel_data.h"
TEST(MATH_TEST,significand_intel)2118 TEST(MATH_TEST, significand_intel) {
2119   DoMathDataTest<1>(g_significand_intel_data, significand);
2120 }
2121 
2122 #include "math_data/significandf_intel_data.h"
TEST(MATH_TEST,significandf_intel)2123 TEST(MATH_TEST, significandf_intel) {
2124   DoMathDataTest<1>(g_significandf_intel_data, significandf);
2125 }
2126 
2127 #include "math_data/sin_intel_data.h"
TEST(MATH_TEST,sin_intel)2128 TEST(MATH_TEST, sin_intel) {
2129   DoMathDataTest<1>(g_sin_intel_data, sin);
2130 }
2131 
2132 #include "math_data/sinf_intel_data.h"
TEST(MATH_TEST,sinf_intel)2133 TEST(MATH_TEST, sinf_intel) {
2134   DoMathDataTest<1>(g_sinf_intel_data, sinf);
2135 }
2136 
2137 #include "math_data/sinh_intel_data.h"
TEST(MATH_TEST,sinh_intel)2138 TEST(MATH_TEST, sinh_intel) {
2139   DoMathDataTest<2>(g_sinh_intel_data, sinh);
2140 }
2141 
2142 #include "math_data/sinhf_intel_data.h"
TEST(MATH_TEST,sinhf_intel)2143 TEST(MATH_TEST, sinhf_intel) {
2144   DoMathDataTest<2>(g_sinhf_intel_data, sinhf);
2145 }
2146 
2147 #include "math_data/sincos_intel_data.h"
TEST(MATH_TEST,sincos_intel)2148 TEST(MATH_TEST, sincos_intel) {
2149   DoMathDataTest<1>(g_sincos_intel_data, sincos);
2150 }
2151 
2152 #include "math_data/sincosf_intel_data.h"
TEST(MATH_TEST,sincosf_intel)2153 TEST(MATH_TEST, sincosf_intel) {
2154   DoMathDataTest<1>(g_sincosf_intel_data, sincosf);
2155 }
2156 
2157 #include "math_data/sqrt_intel_data.h"
TEST(MATH_TEST,sqrt_intel)2158 TEST(MATH_TEST, sqrt_intel) {
2159   DoMathDataTest<1>(g_sqrt_intel_data, sqrt);
2160 }
2161 
2162 #include "math_data/sqrtf_intel_data.h"
TEST(MATH_TEST,sqrtf_intel)2163 TEST(MATH_TEST, sqrtf_intel) {
2164   DoMathDataTest<1>(g_sqrtf_intel_data, sqrtf);
2165 }
2166 
2167 #include "math_data/tan_intel_data.h"
TEST(MATH_TEST,tan_intel)2168 TEST(MATH_TEST, tan_intel) {
2169   DoMathDataTest<1>(g_tan_intel_data, tan);
2170 }
2171 
2172 #include "math_data/tanf_intel_data.h"
TEST(MATH_TEST,tanf_intel)2173 TEST(MATH_TEST, tanf_intel) {
2174   DoMathDataTest<1>(g_tanf_intel_data, tanf);
2175 }
2176 
2177 #include "math_data/tanh_intel_data.h"
TEST(MATH_TEST,tanh_intel)2178 TEST(MATH_TEST, tanh_intel) {
2179   DoMathDataTest<2>(g_tanh_intel_data, tanh);
2180 }
2181 
2182 #include "math_data/tanhf_intel_data.h"
TEST(MATH_TEST,tanhf_intel)2183 TEST(MATH_TEST, tanhf_intel) {
2184   DoMathDataTest<2>(g_tanhf_intel_data, tanhf);
2185 }
2186 
2187 #include "math_data/trunc_intel_data.h"
TEST(MATH_TEST,trunc_intel)2188 TEST(MATH_TEST, trunc_intel) {
2189   DoMathDataTest<1>(g_trunc_intel_data, trunc);
2190 }
2191 
2192 #include "math_data/truncf_intel_data.h"
TEST(MATH_TEST,truncf_intel)2193 TEST(MATH_TEST, truncf_intel) {
2194   DoMathDataTest<1>(g_truncf_intel_data, truncf);
2195 }
2196