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