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