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