• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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)1476 TEST(MATH_TEST, tgamma) {
1477   ASSERT_DOUBLE_EQ(24.0, tgamma(5.0));
1478 }
1479 
TEST(MATH_TEST,tgammaf)1480 TEST(MATH_TEST, tgammaf) {
1481   ASSERT_FLOAT_EQ(24.0f, tgammaf(5.0f));
1482 }
1483 
TEST(MATH_TEST,tgammal)1484 TEST(MATH_TEST, tgammal) {
1485   ASSERT_DOUBLE_EQ(24.0L, tgammal(5.0L));
1486 }
1487 
TEST(MATH_TEST,j0)1488 TEST(MATH_TEST, j0) {
1489   ASSERT_DOUBLE_EQ(1.0, j0(0.0));
1490   ASSERT_DOUBLE_EQ(0.76519768655796661, j0(1.0));
1491 }
1492 
TEST(MATH_TEST,j0f)1493 TEST(MATH_TEST, j0f) {
1494   ASSERT_FLOAT_EQ(1.0f, j0f(0.0f));
1495   ASSERT_FLOAT_EQ(0.76519769f, j0f(1.0f));
1496 }
1497 
TEST(MATH_TEST,j1)1498 TEST(MATH_TEST, j1) {
1499   ASSERT_DOUBLE_EQ(0.0, j1(0.0));
1500   ASSERT_DOUBLE_EQ(0.44005058574493355, j1(1.0));
1501 }
1502 
TEST(MATH_TEST,j1f)1503 TEST(MATH_TEST, j1f) {
1504   ASSERT_FLOAT_EQ(0.0f, j1f(0.0f));
1505   ASSERT_FLOAT_EQ(0.44005057f, j1f(1.0f));
1506 }
1507 
TEST(MATH_TEST,jn)1508 TEST(MATH_TEST, jn) {
1509   ASSERT_DOUBLE_EQ(0.0, jn(4, 0.0));
1510   ASSERT_DOUBLE_EQ(0.0024766389641099553, jn(4, 1.0));
1511 }
1512 
TEST(MATH_TEST,jnf)1513 TEST(MATH_TEST, jnf) {
1514   ASSERT_FLOAT_EQ(0.0f, jnf(4, 0.0f));
1515   ASSERT_FLOAT_EQ(0.0024766389f, jnf(4, 1.0f));
1516 }
1517 
TEST(MATH_TEST,y0)1518 TEST(MATH_TEST, y0) {
1519   ASSERT_DOUBLE_EQ(-HUGE_VAL, y0(0.0));
1520   ASSERT_DOUBLE_EQ(0.08825696421567697, y0(1.0));
1521 }
1522 
TEST(MATH_TEST,y0f)1523 TEST(MATH_TEST, y0f) {
1524   ASSERT_FLOAT_EQ(-HUGE_VALF, y0f(0.0f));
1525   ASSERT_FLOAT_EQ(0.088256963f, y0f(1.0f));
1526 }
1527 
TEST(MATH_TEST,y1)1528 TEST(MATH_TEST, y1) {
1529   ASSERT_DOUBLE_EQ(-HUGE_VAL, y1(0.0));
1530   ASSERT_DOUBLE_EQ(-0.78121282130028868, y1(1.0));
1531 }
1532 
TEST(MATH_TEST,y1f)1533 TEST(MATH_TEST, y1f) {
1534   ASSERT_FLOAT_EQ(-HUGE_VALF, y1f(0.0f));
1535   ASSERT_FLOAT_EQ(-0.78121281f, y1f(1.0f));
1536 }
1537 
TEST(MATH_TEST,yn)1538 TEST(MATH_TEST, yn) {
1539   ASSERT_DOUBLE_EQ(-HUGE_VAL, yn(4, 0.0));
1540   ASSERT_DOUBLE_EQ(-33.278423028972114, yn(4, 1.0));
1541 }
1542 
TEST(MATH_TEST,ynf)1543 TEST(MATH_TEST, ynf) {
1544   ASSERT_FLOAT_EQ(-HUGE_VALF, ynf(4, 0.0f));
1545   ASSERT_FLOAT_EQ(-33.278423f, ynf(4, 1.0f));
1546 }
1547 
TEST(MATH_TEST,frexp)1548 TEST(MATH_TEST, frexp) {
1549   int exp;
1550   double dr = frexp(1024.0, &exp);
1551   ASSERT_DOUBLE_EQ(1024.0, scalbn(dr, exp));
1552 }
1553 
TEST(MATH_TEST,frexpf)1554 TEST(MATH_TEST, frexpf) {
1555   int exp;
1556   float fr = frexpf(1024.0f, &exp);
1557   ASSERT_FLOAT_EQ(1024.0f, scalbnf(fr, exp));
1558 }
1559 
TEST(MATH_TEST,frexpl)1560 TEST(MATH_TEST, frexpl) {
1561   int exp;
1562   long double ldr = frexpl(1024.0L, &exp);
1563   ASSERT_DOUBLE_EQ(1024.0L, scalbnl(ldr, exp));
1564 }
1565 
TEST(MATH_TEST,modf)1566 TEST(MATH_TEST, modf) {
1567   double di;
1568   double df = modf(123.75, &di);
1569   ASSERT_DOUBLE_EQ(123.0, di);
1570   ASSERT_DOUBLE_EQ(0.75, df);
1571 }
1572 
TEST(MATH_TEST,modff)1573 TEST(MATH_TEST, modff) {
1574   float fi;
1575   float ff = modff(123.75f, &fi);
1576   ASSERT_FLOAT_EQ(123.0f, fi);
1577   ASSERT_FLOAT_EQ(0.75f, ff);
1578 }
1579 
TEST(MATH_TEST,modfl)1580 TEST(MATH_TEST, modfl) {
1581   long double ldi;
1582   long double ldf = modfl(123.75L, &ldi);
1583   ASSERT_DOUBLE_EQ(123.0L, ldi);
1584   ASSERT_DOUBLE_EQ(0.75L, ldf);
1585 }
1586 
TEST(MATH_TEST,remquo)1587 TEST(MATH_TEST, remquo) {
1588   int q;
1589   double d = remquo(13.0, 4.0, &q);
1590   ASSERT_EQ(3, q);
1591   ASSERT_DOUBLE_EQ(1.0, d);
1592 
1593   // If x or y is a NaN, NaN is returned.
1594   ASSERT_TRUE(isnan(remquo(nan(""), 10.0, &q)));
1595   ASSERT_TRUE(isnan(remquo(12.0, nan(""), &q)));
1596 
1597   // If x is an infinity, NaN is returned.
1598   ASSERT_TRUE(isnan(remquo(HUGE_VAL, 10.0, &q)));
1599   ASSERT_TRUE(isnan(remquo(-HUGE_VAL, 10.0, &q)));
1600 
1601   // If y is 0, NaN is returned.
1602   ASSERT_TRUE(isnan(remquo(12.0, 0.0, &q)));
1603 }
1604 
TEST(MATH_TEST,remquof)1605 TEST(MATH_TEST, remquof) {
1606   int q;
1607   float f = remquof(13.0f, 4.0f, &q);
1608   ASSERT_EQ(3, q);
1609   ASSERT_FLOAT_EQ(1.0, f);
1610 
1611   // If x or y is a NaN, NaN is returned.
1612   ASSERT_TRUE(isnanf(remquof(nanf(""), 10.0f, &q)));
1613   ASSERT_TRUE(isnanf(remquof(12.0f, nanf(""), &q)));
1614 
1615   // If x is an infinity, NaN is returned.
1616   ASSERT_TRUE(isnanf(remquof(HUGE_VALF, 10.0f, &q)));
1617   ASSERT_TRUE(isnanf(remquof(-HUGE_VALF, 10.0f, &q)));
1618 
1619   // If y is 0, NaN is returned.
1620   ASSERT_TRUE(isnanf(remquof(12.0f, 0.0f, &q)));
1621 }
1622 
TEST(MATH_TEST,remquol)1623 TEST(MATH_TEST, remquol) {
1624   int q;
1625   long double ld = remquol(13.0L, 4.0L, &q);
1626   ASSERT_DOUBLE_EQ(3L, q);
1627   ASSERT_DOUBLE_EQ(1.0L, ld);
1628 
1629   // If x or y is a NaN, NaN is returned.
1630   ASSERT_TRUE(isnanl(remquol(nanl(""), 10.0L, &q)));
1631   ASSERT_TRUE(isnanl(remquol(12.0L, nanl(""), &q)));
1632 
1633   // If x is an infinity, NaN is returned.
1634   ASSERT_TRUE(isnanl(remquol(HUGE_VALL, 10.0L, &q)));
1635   ASSERT_TRUE(isnanl(remquol(-HUGE_VALL, 10.0L, &q)));
1636 
1637   // If y is 0, NaN is returned.
1638   ASSERT_TRUE(isnanl(remquol(12.0L, 0.0L, &q)));
1639 }
1640 
1641 // https://code.google.com/p/android/issues/detail?id=6697
TEST(MATH_TEST,frexpf_public_bug_6697)1642 TEST(MATH_TEST, frexpf_public_bug_6697) {
1643   int exp;
1644   float fr = frexpf(14.1f, &exp);
1645   ASSERT_FLOAT_EQ(14.1f, scalbnf(fr, exp));
1646 }
1647 
TEST(MATH_TEST,exp2_STRICT_ALIGN_OpenBSD_bug)1648 TEST(MATH_TEST, exp2_STRICT_ALIGN_OpenBSD_bug) {
1649   // OpenBSD/x86's libm had a bug here, but it was already fixed in FreeBSD:
1650   // http://svnweb.FreeBSD.org/base/head/lib/msun/src/math_private.h?revision=240827&view=markup
1651   ASSERT_DOUBLE_EQ(5.0, exp2(log2(5)));
1652   ASSERT_FLOAT_EQ(5.0f, exp2f(log2f(5)));
1653   ASSERT_DOUBLE_EQ(5.0L, exp2l(log2l(5)));
1654 }
1655 
TEST(MATH_TEST,nextafterl_OpenBSD_bug)1656 TEST(MATH_TEST, nextafterl_OpenBSD_bug) {
1657   // OpenBSD/x86's libm had a bug here.
1658   ASSERT_TRUE(nextafter(1.0, 0.0) - 1.0 < 0.0);
1659   ASSERT_TRUE(nextafterf(1.0f, 0.0f) - 1.0f < 0.0f);
1660   ASSERT_TRUE(nextafterl(1.0L, 0.0L) - 1.0L < 0.0L);
1661 }
1662 
1663 #include "math_data/acos_intel_data.h"
TEST(MATH_TEST,acos_intel)1664 TEST(MATH_TEST, acos_intel) {
1665   DoMathDataTest<1>(g_acos_intel_data, acos);
1666 }
1667 
1668 #include "math_data/acosf_intel_data.h"
TEST(MATH_TEST,acosf_intel)1669 TEST(MATH_TEST, acosf_intel) {
1670   DoMathDataTest<1>(g_acosf_intel_data, acosf);
1671 }
1672 
1673 #include "math_data/acosh_intel_data.h"
TEST(MATH_TEST,acosh_intel)1674 TEST(MATH_TEST, acosh_intel) {
1675   DoMathDataTest<2>(g_acosh_intel_data, acosh);
1676 }
1677 
1678 #include "math_data/acoshf_intel_data.h"
TEST(MATH_TEST,acoshf_intel)1679 TEST(MATH_TEST, acoshf_intel) {
1680   DoMathDataTest<2>(g_acoshf_intel_data, acoshf);
1681 }
1682 
1683 #include "math_data/asin_intel_data.h"
TEST(MATH_TEST,asin_intel)1684 TEST(MATH_TEST, asin_intel) {
1685   DoMathDataTest<1>(g_asin_intel_data, asin);
1686 }
1687 
1688 #include "math_data/asinf_intel_data.h"
TEST(MATH_TEST,asinf_intel)1689 TEST(MATH_TEST, asinf_intel) {
1690   DoMathDataTest<1>(g_asinf_intel_data, asinf);
1691 }
1692 
1693 #include "math_data/asinh_intel_data.h"
TEST(MATH_TEST,asinh_intel)1694 TEST(MATH_TEST, asinh_intel) {
1695   DoMathDataTest<2>(g_asinh_intel_data, asinh);
1696 }
1697 
1698 #include "math_data/asinhf_intel_data.h"
TEST(MATH_TEST,asinhf_intel)1699 TEST(MATH_TEST, asinhf_intel) {
1700   DoMathDataTest<2>(g_asinhf_intel_data, asinhf);
1701 }
1702 
1703 #include "math_data/atan2_intel_data.h"
TEST(MATH_TEST,atan2_intel)1704 TEST(MATH_TEST, atan2_intel) {
1705   DoMathDataTest<2>(g_atan2_intel_data, atan2);
1706 }
1707 
1708 #include "math_data/atan2f_intel_data.h"
TEST(MATH_TEST,atan2f_intel)1709 TEST(MATH_TEST, atan2f_intel) {
1710   DoMathDataTest<2>(g_atan2f_intel_data, atan2f);
1711 }
1712 
1713 #include "math_data/atan_intel_data.h"
TEST(MATH_TEST,atan_intel)1714 TEST(MATH_TEST, atan_intel) {
1715   DoMathDataTest<1>(g_atan_intel_data, atan);
1716 }
1717 
1718 #include "math_data/atanf_intel_data.h"
TEST(MATH_TEST,atanf_intel)1719 TEST(MATH_TEST, atanf_intel) {
1720   DoMathDataTest<1>(g_atanf_intel_data, atanf);
1721 }
1722 
1723 #include "math_data/atanh_intel_data.h"
TEST(MATH_TEST,atanh_intel)1724 TEST(MATH_TEST, atanh_intel) {
1725   DoMathDataTest<2>(g_atanh_intel_data, atanh);
1726 }
1727 
1728 #include "math_data/atanhf_intel_data.h"
TEST(MATH_TEST,atanhf_intel)1729 TEST(MATH_TEST, atanhf_intel) {
1730   DoMathDataTest<2>(g_atanhf_intel_data, atanhf);
1731 }
1732 
1733 #include "math_data/cbrt_intel_data.h"
TEST(MATH_TEST,cbrt_intel)1734 TEST(MATH_TEST, cbrt_intel) {
1735   DoMathDataTest<1>(g_cbrt_intel_data, cbrt);
1736 }
1737 
1738 #include "math_data/cbrtf_intel_data.h"
TEST(MATH_TEST,cbrtf_intel)1739 TEST(MATH_TEST, cbrtf_intel) {
1740   DoMathDataTest<1>(g_cbrtf_intel_data, cbrtf);
1741 }
1742 
1743 #include "math_data/ceil_intel_data.h"
TEST(MATH_TEST,ceil_intel)1744 TEST(MATH_TEST, ceil_intel) {
1745   DoMathDataTest<1>(g_ceil_intel_data, ceil);
1746 }
1747 
1748 #include "math_data/ceilf_intel_data.h"
TEST(MATH_TEST,ceilf_intel)1749 TEST(MATH_TEST, ceilf_intel) {
1750   DoMathDataTest<1>(g_ceilf_intel_data, ceilf);
1751 }
1752 
1753 #include "math_data/copysign_intel_data.h"
TEST(MATH_TEST,copysign_intel)1754 TEST(MATH_TEST, copysign_intel) {
1755   DoMathDataTest<1>(g_copysign_intel_data, copysign);
1756 }
1757 
1758 #include "math_data/copysignf_intel_data.h"
TEST(MATH_TEST,copysignf_intel)1759 TEST(MATH_TEST, copysignf_intel) {
1760   DoMathDataTest<1>(g_copysignf_intel_data, copysignf);
1761 }
1762 
1763 #include "math_data/cos_intel_data.h"
TEST(MATH_TEST,cos_intel)1764 TEST(MATH_TEST, cos_intel) {
1765   DoMathDataTest<1>(g_cos_intel_data, cos);
1766 }
1767 
1768 #include "math_data/cosf_intel_data.h"
TEST(MATH_TEST,cosf_intel)1769 TEST(MATH_TEST, cosf_intel) {
1770   DoMathDataTest<1>(g_cosf_intel_data, cosf);
1771 }
1772 
1773 #include "math_data/cosh_intel_data.h"
TEST(MATH_TEST,cosh_intel)1774 TEST(MATH_TEST, cosh_intel) {
1775   DoMathDataTest<2>(g_cosh_intel_data, cosh);
1776 }
1777 
1778 #include "math_data/coshf_intel_data.h"
TEST(MATH_TEST,coshf_intel)1779 TEST(MATH_TEST, coshf_intel) {
1780   DoMathDataTest<2>(g_coshf_intel_data, coshf);
1781 }
1782 
1783 #include "math_data/exp_intel_data.h"
TEST(MATH_TEST,exp_intel)1784 TEST(MATH_TEST, exp_intel) {
1785   DoMathDataTest<1>(g_exp_intel_data, exp);
1786 }
1787 
1788 #include "math_data/expf_intel_data.h"
TEST(MATH_TEST,expf_intel)1789 TEST(MATH_TEST, expf_intel) {
1790   DoMathDataTest<1>(g_expf_intel_data, expf);
1791 }
1792 
1793 #include "math_data/exp2_intel_data.h"
TEST(MATH_TEST,exp2_intel)1794 TEST(MATH_TEST, exp2_intel) {
1795   DoMathDataTest<1>(g_exp2_intel_data, exp2);
1796 }
1797 
1798 #include "math_data/exp2f_intel_data.h"
TEST(MATH_TEST,exp2f_intel)1799 TEST(MATH_TEST, exp2f_intel) {
1800   DoMathDataTest<1>(g_exp2f_intel_data, exp2f);
1801 }
1802 
1803 #include "math_data/expm1_intel_data.h"
TEST(MATH_TEST,expm1_intel)1804 TEST(MATH_TEST, expm1_intel) {
1805   DoMathDataTest<1>(g_expm1_intel_data, expm1);
1806 }
1807 
1808 #include "math_data/expm1f_intel_data.h"
TEST(MATH_TEST,expm1f_intel)1809 TEST(MATH_TEST, expm1f_intel) {
1810   DoMathDataTest<1>(g_expm1f_intel_data, expm1f);
1811 }
1812 
1813 #include "math_data/fabs_intel_data.h"
TEST(MATH_TEST,fabs_intel)1814 TEST(MATH_TEST, fabs_intel) {
1815   DoMathDataTest<1>(g_fabs_intel_data, fabs);
1816 }
1817 
1818 #include "math_data/fabsf_intel_data.h"
TEST(MATH_TEST,fabsf_intel)1819 TEST(MATH_TEST, fabsf_intel) {
1820   DoMathDataTest<1>(g_fabsf_intel_data, fabsf);
1821 }
1822 
1823 #include "math_data/fdim_intel_data.h"
TEST(MATH_TEST,fdim_intel)1824 TEST(MATH_TEST, fdim_intel) {
1825   DoMathDataTest<1>(g_fdim_intel_data, fdim);
1826 }
1827 
1828 #include "math_data/fdimf_intel_data.h"
TEST(MATH_TEST,fdimf_intel)1829 TEST(MATH_TEST, fdimf_intel) {
1830   DoMathDataTest<1>(g_fdimf_intel_data, fdimf);
1831 }
1832 
1833 #include "math_data/floor_intel_data.h"
TEST(MATH_TEST,floor_intel)1834 TEST(MATH_TEST, floor_intel) {
1835   DoMathDataTest<1>(g_floor_intel_data, floor);
1836 }
1837 
1838 #include "math_data/floorf_intel_data.h"
TEST(MATH_TEST,floorf_intel)1839 TEST(MATH_TEST, floorf_intel) {
1840   DoMathDataTest<1>(g_floorf_intel_data, floorf);
1841 }
1842 
1843 #include "math_data/fma_intel_data.h"
TEST(MATH_TEST,fma_intel)1844 TEST(MATH_TEST, fma_intel) {
1845   DoMathDataTest<1>(g_fma_intel_data, fma);
1846 }
1847 
1848 #include "math_data/fmaf_intel_data.h"
TEST(MATH_TEST,fmaf_intel)1849 TEST(MATH_TEST, fmaf_intel) {
1850   DoMathDataTest<1>(g_fmaf_intel_data, fmaf);
1851 }
1852 
1853 #include "math_data/fmax_intel_data.h"
TEST(MATH_TEST,fmax_intel)1854 TEST(MATH_TEST, fmax_intel) {
1855   DoMathDataTest<1>(g_fmax_intel_data, fmax);
1856 }
1857 
1858 #include "math_data/fmaxf_intel_data.h"
TEST(MATH_TEST,fmaxf_intel)1859 TEST(MATH_TEST, fmaxf_intel) {
1860   DoMathDataTest<1>(g_fmaxf_intel_data, fmaxf);
1861 }
1862 
1863 #include "math_data/fmin_intel_data.h"
TEST(MATH_TEST,fmin_intel)1864 TEST(MATH_TEST, fmin_intel) {
1865   DoMathDataTest<1>(g_fmin_intel_data, fmin);
1866 }
1867 
1868 #include "math_data/fminf_intel_data.h"
TEST(MATH_TEST,fminf_intel)1869 TEST(MATH_TEST, fminf_intel) {
1870   DoMathDataTest<1>(g_fminf_intel_data, fminf);
1871 }
1872 
1873 #include "math_data/fmod_intel_data.h"
TEST(MATH_TEST,fmod_intel)1874 TEST(MATH_TEST, fmod_intel) {
1875   DoMathDataTest<1>(g_fmod_intel_data, fmod);
1876 }
1877 
1878 #include "math_data/fmodf_intel_data.h"
TEST(MATH_TEST,fmodf_intel)1879 TEST(MATH_TEST, fmodf_intel) {
1880   DoMathDataTest<1>(g_fmodf_intel_data, fmodf);
1881 }
1882 
1883 #include "math_data/frexp_intel_data.h"
TEST(MATH_TEST,frexp_intel)1884 TEST(MATH_TEST, frexp_intel) {
1885   DoMathDataTest<1>(g_frexp_intel_data, frexp);
1886 }
1887 
1888 #include "math_data/frexpf_intel_data.h"
TEST(MATH_TEST,frexpf_intel)1889 TEST(MATH_TEST, frexpf_intel) {
1890   DoMathDataTest<1>(g_frexpf_intel_data, frexpf);
1891 }
1892 
1893 #include "math_data/hypot_intel_data.h"
TEST(MATH_TEST,hypot_intel)1894 TEST(MATH_TEST, hypot_intel) {
1895   DoMathDataTest<1>(g_hypot_intel_data, hypot);
1896 }
1897 
1898 #include "math_data/hypotf_intel_data.h"
TEST(MATH_TEST,hypotf_intel)1899 TEST(MATH_TEST, hypotf_intel) {
1900   DoMathDataTest<1>(g_hypotf_intel_data, hypotf);
1901 }
1902 
1903 #include "math_data/ilogb_intel_data.h"
TEST(MATH_TEST,ilogb_intel)1904 TEST(MATH_TEST, ilogb_intel) {
1905   DoMathDataTest<1>(g_ilogb_intel_data, ilogb);
1906 }
1907 
1908 #include "math_data/ilogbf_intel_data.h"
TEST(MATH_TEST,ilogbf_intel)1909 TEST(MATH_TEST, ilogbf_intel) {
1910   DoMathDataTest<1>(g_ilogbf_intel_data, ilogbf);
1911 }
1912 
1913 #include "math_data/ldexp_intel_data.h"
TEST(MATH_TEST,ldexp_intel)1914 TEST(MATH_TEST, ldexp_intel) {
1915   DoMathDataTest<1>(g_ldexp_intel_data, ldexp);
1916 }
1917 
1918 #include "math_data/ldexpf_intel_data.h"
TEST(MATH_TEST,ldexpf_intel)1919 TEST(MATH_TEST, ldexpf_intel) {
1920   DoMathDataTest<1>(g_ldexpf_intel_data, ldexpf);
1921 }
1922 
1923 #include "math_data/llrint_intel_data.h"
TEST(MATH_TEST,llrint_intel)1924 TEST(MATH_TEST, llrint_intel) {
1925   DoMathDataTest<1>(g_llrint_intel_data, llrint);
1926 }
1927 
1928 #include "math_data/llrintf_intel_data.h"
TEST(MATH_TEST,llrintf_intel)1929 TEST(MATH_TEST, llrintf_intel) {
1930   DoMathDataTest<1>(g_llrintf_intel_data, llrintf);
1931 }
1932 
1933 #include "math_data/log_intel_data.h"
TEST(MATH_TEST,log_intel)1934 TEST(MATH_TEST, log_intel) {
1935   DoMathDataTest<1>(g_log_intel_data, log);
1936 }
1937 
1938 #include "math_data/logf_intel_data.h"
TEST(MATH_TEST,logf_intel)1939 TEST(MATH_TEST, logf_intel) {
1940   DoMathDataTest<1>(g_logf_intel_data, logf);
1941 }
1942 
1943 #include "math_data/log10_intel_data.h"
TEST(MATH_TEST,log10_intel)1944 TEST(MATH_TEST, log10_intel) {
1945   DoMathDataTest<1>(g_log10_intel_data, log10);
1946 }
1947 
1948 #include "math_data/log10f_intel_data.h"
TEST(MATH_TEST,log10f_intel)1949 TEST(MATH_TEST, log10f_intel) {
1950   DoMathDataTest<1>(g_log10f_intel_data, log10f);
1951 }
1952 
1953 #include "math_data/log1p_intel_data.h"
TEST(MATH_TEST,log1p_intel)1954 TEST(MATH_TEST, log1p_intel) {
1955   DoMathDataTest<1>(g_log1p_intel_data, log1p);
1956 }
1957 
1958 #include "math_data/log1pf_intel_data.h"
TEST(MATH_TEST,log1pf_intel)1959 TEST(MATH_TEST, log1pf_intel) {
1960   DoMathDataTest<1>(g_log1pf_intel_data, log1pf);
1961 }
1962 
1963 #include "math_data/log2_intel_data.h"
TEST(MATH_TEST,log2_intel)1964 TEST(MATH_TEST, log2_intel) {
1965   DoMathDataTest<1>(g_log2_intel_data, log2);
1966 }
1967 
1968 #include "math_data/log2f_intel_data.h"
TEST(MATH_TEST,log2f_intel)1969 TEST(MATH_TEST, log2f_intel) {
1970   DoMathDataTest<1>(g_log2f_intel_data, log2f);
1971 }
1972 
1973 #include "math_data/logb_intel_data.h"
TEST(MATH_TEST,logb_intel)1974 TEST(MATH_TEST, logb_intel) {
1975   DoMathDataTest<1>(g_logb_intel_data, logb);
1976 }
1977 
1978 #include "math_data/logbf_intel_data.h"
TEST(MATH_TEST,logbf_intel)1979 TEST(MATH_TEST, logbf_intel) {
1980   DoMathDataTest<1>(g_logbf_intel_data, logbf);
1981 }
1982 
1983 #include "math_data/lrint_intel_data.h"
TEST(MATH_TEST,lrint_intel)1984 TEST(MATH_TEST, lrint_intel) {
1985   DoMathDataTest<1>(g_lrint_intel_data, lrint);
1986 }
1987 
1988 #include "math_data/lrintf_intel_data.h"
TEST(MATH_TEST,lrintf_intel)1989 TEST(MATH_TEST, lrintf_intel) {
1990   DoMathDataTest<1>(g_lrintf_intel_data, lrintf);
1991 }
1992 
1993 #include "math_data/modf_intel_data.h"
TEST(MATH_TEST,modf_intel)1994 TEST(MATH_TEST, modf_intel) {
1995   DoMathDataTest<1>(g_modf_intel_data, modf);
1996 }
1997 
1998 #include "math_data/modff_intel_data.h"
TEST(MATH_TEST,modff_intel)1999 TEST(MATH_TEST, modff_intel) {
2000   DoMathDataTest<1>(g_modff_intel_data, modff);
2001 }
2002 
2003 #include "math_data/nearbyint_intel_data.h"
TEST(MATH_TEST,nearbyint_intel)2004 TEST(MATH_TEST, nearbyint_intel) {
2005   DoMathDataTest<1>(g_nearbyint_intel_data, nearbyint);
2006 }
2007 
2008 #include "math_data/nearbyintf_intel_data.h"
TEST(MATH_TEST,nearbyintf_intel)2009 TEST(MATH_TEST, nearbyintf_intel) {
2010   DoMathDataTest<1>(g_nearbyintf_intel_data, nearbyintf);
2011 }
2012 
2013 #include "math_data/nextafter_intel_data.h"
TEST(MATH_TEST,nextafter_intel)2014 TEST(MATH_TEST, nextafter_intel) {
2015   DoMathDataTest<1>(g_nextafter_intel_data, nextafter);
2016 }
2017 
2018 #include "math_data/nextafterf_intel_data.h"
TEST(MATH_TEST,nextafterf_intel)2019 TEST(MATH_TEST, nextafterf_intel) {
2020   DoMathDataTest<1>(g_nextafterf_intel_data, nextafterf);
2021 }
2022 
2023 #include "math_data/pow_intel_data.h"
TEST(MATH_TEST,pow_intel)2024 TEST(MATH_TEST, pow_intel) {
2025   DoMathDataTest<1>(g_pow_intel_data, pow);
2026 }
2027 
2028 #include "math_data/powf_intel_data.h"
TEST(MATH_TEST,powf_intel)2029 TEST(MATH_TEST, powf_intel) {
2030   DoMathDataTest<1>(g_powf_intel_data, powf);
2031 }
2032 
2033 #include "math_data/remainder_intel_data.h"
TEST(MATH_TEST,remainder_intel)2034 TEST(MATH_TEST, remainder_intel) {
2035   DoMathDataTest<1>(g_remainder_intel_data, remainder);
2036 }
2037 
2038 #include "math_data/remainderf_intel_data.h"
TEST(MATH_TEST,remainderf_intel)2039 TEST(MATH_TEST, remainderf_intel) {
2040   DoMathDataTest<1>(g_remainderf_intel_data, remainderf);
2041 }
2042 
2043 #include "math_data/remquo_intel_data.h"
TEST(MATH_TEST,remquo_intel)2044 TEST(MATH_TEST, remquo_intel) {
2045   DoMathDataTest<1>(g_remquo_intel_data, remquo);
2046 }
2047 
2048 #include "math_data/remquof_intel_data.h"
TEST(MATH_TEST,remquof_intel)2049 TEST(MATH_TEST, remquof_intel) {
2050   DoMathDataTest<1>(g_remquof_intel_data, remquof);
2051 }
2052 
2053 #include "math_data/rint_intel_data.h"
TEST(MATH_TEST,rint_intel)2054 TEST(MATH_TEST, rint_intel) {
2055   DoMathDataTest<1>(g_rint_intel_data, rint);
2056 }
2057 
2058 #include "math_data/rintf_intel_data.h"
TEST(MATH_TEST,rintf_intel)2059 TEST(MATH_TEST, rintf_intel) {
2060   DoMathDataTest<1>(g_rintf_intel_data, rintf);
2061 }
2062 
2063 #include "math_data/round_intel_data.h"
TEST(MATH_TEST,round_intel)2064 TEST(MATH_TEST, round_intel) {
2065   DoMathDataTest<1>(g_round_intel_data, round);
2066 }
2067 
2068 #include "math_data/roundf_intel_data.h"
TEST(MATH_TEST,roundf_intel)2069 TEST(MATH_TEST, roundf_intel) {
2070   DoMathDataTest<1>(g_roundf_intel_data, roundf);
2071 }
2072 
2073 #include "math_data/scalb_intel_data.h"
TEST(MATH_TEST,scalb_intel)2074 TEST(MATH_TEST, scalb_intel) {
2075   DoMathDataTest<1>(g_scalb_intel_data, scalb);
2076 }
2077 
2078 #include "math_data/scalbf_intel_data.h"
TEST(MATH_TEST,scalbf_intel)2079 TEST(MATH_TEST, scalbf_intel) {
2080   DoMathDataTest<1>(g_scalbf_intel_data, scalbf);
2081 }
2082 
2083 #include "math_data/scalbn_intel_data.h"
TEST(MATH_TEST,scalbn_intel)2084 TEST(MATH_TEST, scalbn_intel) {
2085   DoMathDataTest<1>(g_scalbn_intel_data, scalbn);
2086 }
2087 
2088 #include "math_data/scalbnf_intel_data.h"
TEST(MATH_TEST,scalbnf_intel)2089 TEST(MATH_TEST, scalbnf_intel) {
2090   DoMathDataTest<1>(g_scalbnf_intel_data, scalbnf);
2091 }
2092 
2093 #include "math_data/significand_intel_data.h"
TEST(MATH_TEST,significand_intel)2094 TEST(MATH_TEST, significand_intel) {
2095   DoMathDataTest<1>(g_significand_intel_data, significand);
2096 }
2097 
2098 #include "math_data/significandf_intel_data.h"
TEST(MATH_TEST,significandf_intel)2099 TEST(MATH_TEST, significandf_intel) {
2100   DoMathDataTest<1>(g_significandf_intel_data, significandf);
2101 }
2102 
2103 #include "math_data/sin_intel_data.h"
TEST(MATH_TEST,sin_intel)2104 TEST(MATH_TEST, sin_intel) {
2105   DoMathDataTest<1>(g_sin_intel_data, sin);
2106 }
2107 
2108 #include "math_data/sinf_intel_data.h"
TEST(MATH_TEST,sinf_intel)2109 TEST(MATH_TEST, sinf_intel) {
2110   DoMathDataTest<1>(g_sinf_intel_data, sinf);
2111 }
2112 
2113 #include "math_data/sinh_intel_data.h"
TEST(MATH_TEST,sinh_intel)2114 TEST(MATH_TEST, sinh_intel) {
2115   DoMathDataTest<2>(g_sinh_intel_data, sinh);
2116 }
2117 
2118 #include "math_data/sinhf_intel_data.h"
TEST(MATH_TEST,sinhf_intel)2119 TEST(MATH_TEST, sinhf_intel) {
2120   DoMathDataTest<2>(g_sinhf_intel_data, sinhf);
2121 }
2122 
2123 #include "math_data/sincos_intel_data.h"
TEST(MATH_TEST,sincos_intel)2124 TEST(MATH_TEST, sincos_intel) {
2125   DoMathDataTest<1>(g_sincos_intel_data, sincos);
2126 }
2127 
2128 #include "math_data/sincosf_intel_data.h"
TEST(MATH_TEST,sincosf_intel)2129 TEST(MATH_TEST, sincosf_intel) {
2130   DoMathDataTest<1>(g_sincosf_intel_data, sincosf);
2131 }
2132 
2133 #include "math_data/sqrt_intel_data.h"
TEST(MATH_TEST,sqrt_intel)2134 TEST(MATH_TEST, sqrt_intel) {
2135   DoMathDataTest<1>(g_sqrt_intel_data, sqrt);
2136 }
2137 
2138 #include "math_data/sqrtf_intel_data.h"
TEST(MATH_TEST,sqrtf_intel)2139 TEST(MATH_TEST, sqrtf_intel) {
2140   DoMathDataTest<1>(g_sqrtf_intel_data, sqrtf);
2141 }
2142 
2143 #include "math_data/tan_intel_data.h"
TEST(MATH_TEST,tan_intel)2144 TEST(MATH_TEST, tan_intel) {
2145   DoMathDataTest<1>(g_tan_intel_data, tan);
2146 }
2147 
2148 #include "math_data/tanf_intel_data.h"
TEST(MATH_TEST,tanf_intel)2149 TEST(MATH_TEST, tanf_intel) {
2150   DoMathDataTest<1>(g_tanf_intel_data, tanf);
2151 }
2152 
2153 #include "math_data/tanh_intel_data.h"
TEST(MATH_TEST,tanh_intel)2154 TEST(MATH_TEST, tanh_intel) {
2155   DoMathDataTest<2>(g_tanh_intel_data, tanh);
2156 }
2157 
2158 #include "math_data/tanhf_intel_data.h"
TEST(MATH_TEST,tanhf_intel)2159 TEST(MATH_TEST, tanhf_intel) {
2160   DoMathDataTest<2>(g_tanhf_intel_data, tanhf);
2161 }
2162 
2163 #include "math_data/trunc_intel_data.h"
TEST(MATH_TEST,trunc_intel)2164 TEST(MATH_TEST, trunc_intel) {
2165   DoMathDataTest<1>(g_trunc_intel_data, trunc);
2166 }
2167 
2168 #include "math_data/truncf_intel_data.h"
TEST(MATH_TEST,truncf_intel)2169 TEST(MATH_TEST, truncf_intel) {
2170   DoMathDataTest<1>(g_truncf_intel_data, truncf);
2171 }
2172