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,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 = make_scope_guard([]() {
779 fesetenv(FE_DFL_ENV);
780 });
781
782 fesetround(FE_UPWARD); // lrint/lrintf/lrintl obey the rounding mode.
783 ASSERT_EQ(1235, lrint(1234.01));
784 ASSERT_EQ(1235, lrintf(1234.01f));
785 ASSERT_EQ(1235, lrintl(1234.01L));
786 fesetround(FE_TOWARDZERO); // lrint/lrintf/lrintl obey the rounding mode.
787 ASSERT_EQ(1234, lrint(1234.01));
788 ASSERT_EQ(1234, lrintf(1234.01f));
789 ASSERT_EQ(1234, lrintl(1234.01L));
790
791 fesetround(FE_UPWARD); // llrint/llrintf/llrintl obey the rounding mode.
792 ASSERT_EQ(1235L, llrint(1234.01));
793 ASSERT_EQ(1235L, llrintf(1234.01f));
794 ASSERT_EQ(1235L, llrintl(1234.01L));
795 fesetround(FE_TOWARDZERO); // llrint/llrintf/llrintl obey the rounding mode.
796 ASSERT_EQ(1234L, llrint(1234.01));
797 ASSERT_EQ(1234L, llrintf(1234.01f));
798 ASSERT_EQ(1234L, llrintl(1234.01L));
799 }
800
TEST(math,rint)801 TEST(math, rint) {
802 auto guard = make_scope_guard([]() {
803 fesetenv(FE_DFL_ENV);
804 });
805
806 fesetround(FE_UPWARD); // rint/rintf/rintl obey the rounding mode.
807 feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
808 ASSERT_EQ(1234.0, rint(1234.0));
809 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
810 ASSERT_EQ(1235.0, rint(1234.01));
811 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
812
813 feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
814 ASSERT_EQ(1234.0f, rintf(1234.0f));
815 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
816 ASSERT_EQ(1235.0f, rintf(1234.01f));
817 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
818
819 feclearexcept(FE_ALL_EXCEPT); // rint/rintf/rintl do set the FE_INEXACT flag.
820 ASSERT_EQ(1234.0, rintl(1234.0L));
821 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
822 ASSERT_EQ(1235.0, rintl(1234.01L));
823 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) != 0);
824
825 fesetround(FE_TOWARDZERO); // rint/rintf obey the rounding mode.
826 ASSERT_EQ(1234.0, rint(1234.01));
827 ASSERT_EQ(1234.0f, rintf(1234.01f));
828 ASSERT_EQ(1234.0, rintl(1234.01L));
829 }
830
TEST(math,nearbyint)831 TEST(math, nearbyint) {
832 auto guard = make_scope_guard([]() {
833 fesetenv(FE_DFL_ENV);
834 });
835 fesetround(FE_UPWARD); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
836 feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
837 ASSERT_EQ(1234.0, nearbyint(1234.0));
838 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
839 ASSERT_EQ(1235.0, nearbyint(1234.01));
840 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
841
842 feclearexcept(FE_ALL_EXCEPT);
843 ASSERT_EQ(1234.0f, nearbyintf(1234.0f));
844 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
845 ASSERT_EQ(1235.0f, nearbyintf(1234.01f));
846 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
847
848 feclearexcept(FE_ALL_EXCEPT); // nearbyint/nearbyintf/nearbyintl don't set the FE_INEXACT flag.
849 ASSERT_EQ(1234.0, nearbyintl(1234.0L));
850 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
851 ASSERT_EQ(1235.0, nearbyintl(1234.01L));
852 ASSERT_TRUE((fetestexcept(FE_ALL_EXCEPT) & FE_INEXACT) == 0);
853
854 fesetround(FE_TOWARDZERO); // nearbyint/nearbyintf/nearbyintl obey the rounding mode.
855 ASSERT_EQ(1234.0, nearbyint(1234.01));
856 ASSERT_EQ(1234.0f, nearbyintf(1234.01f));
857 ASSERT_EQ(1234.0, nearbyintl(1234.01L));
858 }
859
TEST(math,lround)860 TEST(math, lround) {
861 auto guard = make_scope_guard([]() {
862 fesetenv(FE_DFL_ENV);
863 });
864 fesetround(FE_UPWARD); // lround ignores the rounding mode.
865 ASSERT_EQ(1234, lround(1234.01));
866 ASSERT_EQ(1234, lroundf(1234.01f));
867 ASSERT_EQ(1234, lroundl(1234.01L));
868 }
869
TEST(math,llround)870 TEST(math, llround) {
871 auto guard = make_scope_guard([]() {
872 fesetenv(FE_DFL_ENV);
873 });
874 fesetround(FE_UPWARD); // llround ignores the rounding mode.
875 ASSERT_EQ(1234L, llround(1234.01));
876 ASSERT_EQ(1234L, llroundf(1234.01f));
877 ASSERT_EQ(1234L, llroundl(1234.01L));
878 }
879
TEST(math,ilogb)880 TEST(math, ilogb) {
881 ASSERT_EQ(FP_ILOGB0, ilogb(0.0));
882 ASSERT_EQ(FP_ILOGBNAN, ilogb(nan("")));
883 ASSERT_EQ(INT_MAX, ilogb(HUGE_VAL));
884 ASSERT_EQ(0, ilogb(1.0));
885 ASSERT_EQ(3, ilogb(10.0));
886 }
887
TEST(math,ilogbf)888 TEST(math, ilogbf) {
889 ASSERT_EQ(FP_ILOGB0, ilogbf(0.0f));
890 ASSERT_EQ(FP_ILOGBNAN, ilogbf(nanf("")));
891 ASSERT_EQ(INT_MAX, ilogbf(HUGE_VALF));
892 ASSERT_EQ(0, ilogbf(1.0f));
893 ASSERT_EQ(3, ilogbf(10.0f));
894 }
895
TEST(math,ilogbl)896 TEST(math, ilogbl) {
897 ASSERT_EQ(FP_ILOGB0, ilogbl(0.0L));
898 ASSERT_EQ(FP_ILOGBNAN, ilogbl(nanl("")));
899 ASSERT_EQ(INT_MAX, ilogbl(HUGE_VALL));
900 ASSERT_EQ(0L, ilogbl(1.0L));
901 ASSERT_EQ(3L, ilogbl(10.0L));
902 }
903
TEST(math,logb)904 TEST(math, logb) {
905 ASSERT_EQ(-HUGE_VAL, logb(0.0));
906 ASSERT_TRUE(isnan(logb(nan(""))));
907 ASSERT_TRUE(isinf(logb(HUGE_VAL)));
908 ASSERT_EQ(0.0, logb(1.0));
909 ASSERT_EQ(3.0, logb(10.0));
910 }
911
TEST(math,logbf)912 TEST(math, logbf) {
913 ASSERT_EQ(-HUGE_VALF, logbf(0.0f));
914 ASSERT_TRUE(isnanf(logbf(nanf(""))));
915 ASSERT_TRUE(__isinff(logbf(HUGE_VALF)));
916 ASSERT_EQ(0.0f, logbf(1.0f));
917 ASSERT_EQ(3.0f, logbf(10.0f));
918 }
919
TEST(math,logbl)920 TEST(math, logbl) {
921 ASSERT_EQ(-HUGE_VAL, logbl(0.0L));
922 ASSERT_TRUE(isnan(logbl(nanl(""))));
923 ASSERT_TRUE(isinf(logbl(HUGE_VALL)));
924 ASSERT_EQ(0.0L, logbl(1.0L));
925 ASSERT_EQ(3.0L, logbl(10.0L));
926 }
927
TEST(math,log1p)928 TEST(math, log1p) {
929 ASSERT_EQ(-HUGE_VAL, log1p(-1.0));
930 ASSERT_TRUE(isnan(log1p(nan(""))));
931 ASSERT_TRUE(isinf(log1p(HUGE_VAL)));
932 ASSERT_DOUBLE_EQ(1.0, log1p(M_E - 1.0));
933 }
934
TEST(math,log1pf)935 TEST(math, log1pf) {
936 ASSERT_EQ(-HUGE_VALF, log1pf(-1.0f));
937 ASSERT_TRUE(isnanf(log1pf(nanf(""))));
938 ASSERT_TRUE(__isinff(log1pf(HUGE_VALF)));
939 ASSERT_FLOAT_EQ(1.0f, log1pf(static_cast<float>(M_E) - 1.0f));
940 }
941
TEST(math,log1pl)942 TEST(math, log1pl) {
943 ASSERT_EQ(-HUGE_VALL, log1pl(-1.0L));
944 ASSERT_TRUE(isnan(log1pl(nanl(""))));
945 ASSERT_TRUE(isinf(log1pl(HUGE_VALL)));
946 ASSERT_DOUBLE_EQ(1.0L, log1pl(M_E - 1.0L));
947 }
948
TEST(math,fdim)949 TEST(math, fdim) {
950 ASSERT_DOUBLE_EQ(0.0, fdim(1.0, 1.0));
951 ASSERT_DOUBLE_EQ(1.0, fdim(2.0, 1.0));
952 ASSERT_DOUBLE_EQ(0.0, fdim(1.0, 2.0));
953 }
954
TEST(math,fdimf)955 TEST(math, fdimf) {
956 ASSERT_FLOAT_EQ(0.0f, fdimf(1.0f, 1.0f));
957 ASSERT_FLOAT_EQ(1.0f, fdimf(2.0f, 1.0f));
958 ASSERT_FLOAT_EQ(0.0f, fdimf(1.0f, 2.0f));
959 }
960
TEST(math,fdiml)961 TEST(math, fdiml) {
962 ASSERT_DOUBLE_EQ(0.0L, fdiml(1.0L, 1.0L));
963 ASSERT_DOUBLE_EQ(1.0L, fdiml(2.0L, 1.0L));
964 ASSERT_DOUBLE_EQ(0.0L, fdiml(1.0L, 2.0L));
965 }
966
TEST(math,round)967 TEST(math, round) {
968 auto guard = make_scope_guard([]() {
969 fesetenv(FE_DFL_ENV);
970 });
971 fesetround(FE_TOWARDZERO); // round ignores the rounding mode and always rounds away from zero.
972 ASSERT_DOUBLE_EQ(1.0, round(0.5));
973 ASSERT_DOUBLE_EQ(-1.0, round(-0.5));
974 ASSERT_DOUBLE_EQ(0.0, round(0.0));
975 ASSERT_DOUBLE_EQ(-0.0, round(-0.0));
976 ASSERT_TRUE(isnan(round(nan(""))));
977 ASSERT_DOUBLE_EQ(HUGE_VAL, round(HUGE_VAL));
978 }
979
TEST(math,roundf)980 TEST(math, roundf) {
981 auto guard = make_scope_guard([]() {
982 fesetenv(FE_DFL_ENV);
983 });
984 fesetround(FE_TOWARDZERO); // roundf ignores the rounding mode and always rounds away from zero.
985 ASSERT_FLOAT_EQ(1.0f, roundf(0.5f));
986 ASSERT_FLOAT_EQ(-1.0f, roundf(-0.5f));
987 ASSERT_FLOAT_EQ(0.0f, roundf(0.0f));
988 ASSERT_FLOAT_EQ(-0.0f, roundf(-0.0f));
989 ASSERT_TRUE(isnanf(roundf(nanf(""))));
990 ASSERT_FLOAT_EQ(HUGE_VALF, roundf(HUGE_VALF));
991 }
992
TEST(math,roundl)993 TEST(math, roundl) {
994 auto guard = make_scope_guard([]() {
995 fesetenv(FE_DFL_ENV);
996 });
997 fesetround(FE_TOWARDZERO); // roundl ignores the rounding mode and always rounds away from zero.
998 ASSERT_DOUBLE_EQ(1.0L, roundl(0.5L));
999 ASSERT_DOUBLE_EQ(-1.0L, roundl(-0.5L));
1000 ASSERT_DOUBLE_EQ(0.0L, roundl(0.0L));
1001 ASSERT_DOUBLE_EQ(-0.0L, roundl(-0.0L));
1002 ASSERT_TRUE(isnan(roundl(nanl(""))));
1003 ASSERT_DOUBLE_EQ(HUGE_VALL, roundl(HUGE_VALL));
1004 }
1005
TEST(math,trunc)1006 TEST(math, trunc) {
1007 auto guard = make_scope_guard([]() {
1008 fesetenv(FE_DFL_ENV);
1009 });
1010 fesetround(FE_UPWARD); // trunc ignores the rounding mode and always rounds toward zero.
1011 ASSERT_DOUBLE_EQ(1.0, trunc(1.5));
1012 ASSERT_DOUBLE_EQ(-1.0, trunc(-1.5));
1013 ASSERT_DOUBLE_EQ(0.0, trunc(0.0));
1014 ASSERT_DOUBLE_EQ(-0.0, trunc(-0.0));
1015 ASSERT_TRUE(isnan(trunc(nan(""))));
1016 ASSERT_DOUBLE_EQ(HUGE_VAL, trunc(HUGE_VAL));
1017 }
1018
TEST(math,truncf)1019 TEST(math, truncf) {
1020 auto guard = make_scope_guard([]() {
1021 fesetenv(FE_DFL_ENV);
1022 });
1023 fesetround(FE_UPWARD); // truncf ignores the rounding mode and always rounds toward zero.
1024 ASSERT_FLOAT_EQ(1.0f, truncf(1.5f));
1025 ASSERT_FLOAT_EQ(-1.0f, truncf(-1.5f));
1026 ASSERT_FLOAT_EQ(0.0f, truncf(0.0f));
1027 ASSERT_FLOAT_EQ(-0.0f, truncf(-0.0f));
1028 ASSERT_TRUE(isnan(truncf(nanf(""))));
1029 ASSERT_FLOAT_EQ(HUGE_VALF, truncf(HUGE_VALF));
1030 }
1031
TEST(math,truncl)1032 TEST(math, truncl) {
1033 auto guard = make_scope_guard([]() {
1034 fesetenv(FE_DFL_ENV);
1035 });
1036 fesetround(FE_UPWARD); // truncl ignores the rounding mode and always rounds toward zero.
1037 ASSERT_DOUBLE_EQ(1.0L, truncl(1.5L));
1038 ASSERT_DOUBLE_EQ(-1.0L, truncl(-1.5L));
1039 ASSERT_DOUBLE_EQ(0.0L, truncl(0.0L));
1040 ASSERT_DOUBLE_EQ(-0.0L, truncl(-0.0L));
1041 ASSERT_TRUE(isnan(truncl(nan(""))));
1042 ASSERT_DOUBLE_EQ(HUGE_VALL, truncl(HUGE_VALL));
1043 }
1044
TEST(math,nextafter)1045 TEST(math, nextafter) {
1046 ASSERT_DOUBLE_EQ(0.0, nextafter(0.0, 0.0));
1047 ASSERT_DOUBLE_EQ(4.9406564584124654e-324, nextafter(0.0, 1.0));
1048 ASSERT_DOUBLE_EQ(-4.9406564584124654e-324, nextafter(0.0, -1.0));
1049 }
1050
TEST(math,nextafterf)1051 TEST(math, nextafterf) {
1052 ASSERT_FLOAT_EQ(0.0f, nextafterf(0.0f, 0.0f));
1053 ASSERT_FLOAT_EQ(1.4012985e-45f, nextafterf(0.0f, 1.0f));
1054 ASSERT_FLOAT_EQ(-1.4012985e-45f, nextafterf(0.0f, -1.0f));
1055 }
1056
TEST(math,nextafterl)1057 TEST(math, nextafterl) {
1058 ASSERT_DOUBLE_EQ(0.0L, nextafterl(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, nextafterl(0.0L, 1.0L));
1063 ASSERT_DOUBLE_EQ(-smallest_positive, nextafterl(0.0L, -1.0L));
1064 }
1065
TEST(math,nexttoward)1066 TEST(math, nexttoward) {
1067 ASSERT_DOUBLE_EQ(0.0, nexttoward(0.0, 0.0L));
1068 ASSERT_DOUBLE_EQ(4.9406564584124654e-324, nexttoward(0.0, 1.0L));
1069 ASSERT_DOUBLE_EQ(-4.9406564584124654e-324, nexttoward(0.0, -1.0L));
1070 }
1071
TEST(math,nexttowardf)1072 TEST(math, nexttowardf) {
1073 ASSERT_FLOAT_EQ(0.0f, nexttowardf(0.0f, 0.0L));
1074 ASSERT_FLOAT_EQ(1.4012985e-45f, nexttowardf(0.0f, 1.0L));
1075 ASSERT_FLOAT_EQ(-1.4012985e-45f, nexttowardf(0.0f, -1.0L));
1076 }
1077
TEST(math,nexttowardl)1078 TEST(math, nexttowardl) {
1079 ASSERT_DOUBLE_EQ(0.0L, nexttowardl(0.0L, 0.0L));
1080 // Use a runtime value to accomodate the case when
1081 // sizeof(double) == sizeof(long double)
1082 long double smallest_positive = ldexpl(1.0L, LDBL_MIN_EXP - LDBL_MANT_DIG);
1083 ASSERT_DOUBLE_EQ(smallest_positive, nexttowardl(0.0L, 1.0L));
1084 ASSERT_DOUBLE_EQ(-smallest_positive, nexttowardl(0.0L, -1.0L));
1085 }
1086
TEST(math,copysign)1087 TEST(math, copysign) {
1088 ASSERT_DOUBLE_EQ(0.0, copysign(0.0, 1.0));
1089 ASSERT_DOUBLE_EQ(-0.0, copysign(0.0, -1.0));
1090 ASSERT_DOUBLE_EQ(2.0, copysign(2.0, 1.0));
1091 ASSERT_DOUBLE_EQ(-2.0, copysign(2.0, -1.0));
1092 }
1093
TEST(math,copysignf)1094 TEST(math, copysignf) {
1095 ASSERT_FLOAT_EQ(0.0f, copysignf(0.0f, 1.0f));
1096 ASSERT_FLOAT_EQ(-0.0f, copysignf(0.0f, -1.0f));
1097 ASSERT_FLOAT_EQ(2.0f, copysignf(2.0f, 1.0f));
1098 ASSERT_FLOAT_EQ(-2.0f, copysignf(2.0f, -1.0f));
1099 }
1100
TEST(math,copysignl)1101 TEST(math, copysignl) {
1102 ASSERT_DOUBLE_EQ(0.0L, copysignl(0.0L, 1.0L));
1103 ASSERT_DOUBLE_EQ(-0.0L, copysignl(0.0L, -1.0L));
1104 ASSERT_DOUBLE_EQ(2.0L, copysignl(2.0L, 1.0L));
1105 ASSERT_DOUBLE_EQ(-2.0L, copysignl(2.0L, -1.0L));
1106 }
1107
TEST(math,significand)1108 TEST(math, significand) {
1109 ASSERT_DOUBLE_EQ(0.0, significand(0.0));
1110 ASSERT_DOUBLE_EQ(1.2, significand(1.2));
1111 ASSERT_DOUBLE_EQ(1.53125, significand(12.25));
1112 }
1113
TEST(math,significandf)1114 TEST(math, significandf) {
1115 ASSERT_FLOAT_EQ(0.0f, significandf(0.0f));
1116 ASSERT_FLOAT_EQ(1.2f, significandf(1.2f));
1117 ASSERT_FLOAT_EQ(1.53125f, significandf(12.25f));
1118 }
1119
TEST(math,significandl)1120 TEST(math, significandl) {
1121 ASSERT_DOUBLE_EQ(0.0L, significandl(0.0L));
1122 ASSERT_DOUBLE_EQ(1.2L, significandl(1.2L));
1123 ASSERT_DOUBLE_EQ(1.53125L, significandl(12.25L));
1124 }
1125
TEST(math,scalb)1126 TEST(math, scalb) {
1127 ASSERT_DOUBLE_EQ(12.0, scalb(3.0, 2.0));
1128 }
1129
TEST(math,scalbf)1130 TEST(math, scalbf) {
1131 ASSERT_FLOAT_EQ(12.0f, scalbf(3.0f, 2.0f));
1132 }
1133
TEST(math,scalbln)1134 TEST(math, scalbln) {
1135 ASSERT_DOUBLE_EQ(12.0, scalbln(3.0, 2L));
1136 }
1137
TEST(math,scalblnf)1138 TEST(math, scalblnf) {
1139 ASSERT_FLOAT_EQ(12.0f, scalblnf(3.0f, 2L));
1140 }
1141
TEST(math,scalblnl)1142 TEST(math, scalblnl) {
1143 ASSERT_DOUBLE_EQ(12.0L, scalblnl(3.0L, 2L));
1144 }
1145
TEST(math,scalbn)1146 TEST(math, scalbn) {
1147 ASSERT_DOUBLE_EQ(12.0, scalbn(3.0, 2));
1148 }
1149
TEST(math,scalbnf)1150 TEST(math, scalbnf) {
1151 ASSERT_FLOAT_EQ(12.0f, scalbnf(3.0f, 2));
1152 }
1153
TEST(math,scalbnl)1154 TEST(math, scalbnl) {
1155 ASSERT_DOUBLE_EQ(12.0L, scalbnl(3.0L, 2));
1156 }
1157
TEST(math,gamma)1158 TEST(math, gamma) {
1159 ASSERT_DOUBLE_EQ(log(24.0), gamma(5.0));
1160 }
1161
TEST(math,gammaf)1162 TEST(math, gammaf) {
1163 ASSERT_FLOAT_EQ(logf(24.0f), gammaf(5.0f));
1164 }
1165
TEST(math,gamma_r)1166 TEST(math, gamma_r) {
1167 #if defined(__BIONIC__)
1168 int sign;
1169 ASSERT_DOUBLE_EQ(log(24.0), gamma_r(5.0, &sign));
1170 ASSERT_EQ(1, sign);
1171 #else // __BIONIC__
1172 GTEST_LOG_(INFO) << "glibc doesn't have gamma_r.\n";
1173 #endif // __BIONIC__
1174 }
1175
TEST(math,gammaf_r)1176 TEST(math, gammaf_r) {
1177 #if defined(__BIONIC__)
1178 int sign;
1179 ASSERT_FLOAT_EQ(logf(24.0f), gammaf_r(5.0f, &sign));
1180 ASSERT_EQ(1, sign);
1181 #else // __BIONIC__
1182 GTEST_LOG_(INFO) << "glibc doesn't have gammaf_r.\n";
1183 #endif // __BIONIC__
1184 }
1185
TEST(math,lgamma)1186 TEST(math, lgamma) {
1187 ASSERT_DOUBLE_EQ(log(24.0), lgamma(5.0));
1188 }
1189
TEST(math,lgammaf)1190 TEST(math, lgammaf) {
1191 ASSERT_FLOAT_EQ(logf(24.0f), lgammaf(5.0f));
1192 }
1193
TEST(math,lgammal)1194 TEST(math, lgammal) {
1195 ASSERT_DOUBLE_EQ(logl(24.0L), lgammal(5.0L));
1196 }
1197
TEST(math,lgamma_r)1198 TEST(math, lgamma_r) {
1199 int sign;
1200 ASSERT_DOUBLE_EQ(log(24.0), lgamma_r(5.0, &sign));
1201 ASSERT_EQ(1, sign);
1202 }
1203
TEST(math,lgamma_r_17471883)1204 TEST(math, lgamma_r_17471883) {
1205 int sign;
1206
1207 sign = 0;
1208 ASSERT_DOUBLE_EQ(HUGE_VAL, lgamma_r(0.0, &sign));
1209 ASSERT_EQ(1, sign);
1210 sign = 0;
1211 ASSERT_DOUBLE_EQ(HUGE_VAL, lgamma_r(-0.0, &sign));
1212 ASSERT_EQ(-1, sign);
1213 }
1214
TEST(math,lgammaf_r)1215 TEST(math, lgammaf_r) {
1216 int sign;
1217 ASSERT_FLOAT_EQ(logf(24.0f), lgammaf_r(5.0f, &sign));
1218 ASSERT_EQ(1, sign);
1219 }
1220
TEST(math,lgammaf_r_17471883)1221 TEST(math, lgammaf_r_17471883) {
1222 int sign;
1223
1224 sign = 0;
1225 ASSERT_FLOAT_EQ(HUGE_VALF, lgammaf_r(0.0f, &sign));
1226 ASSERT_EQ(1, sign);
1227 sign = 0;
1228 ASSERT_FLOAT_EQ(HUGE_VALF, lgammaf_r(-0.0f, &sign));
1229 ASSERT_EQ(-1, sign);
1230 }
1231
TEST(math,lgammal_r)1232 TEST(math, lgammal_r) {
1233 int sign;
1234 ASSERT_DOUBLE_EQ(log(24.0L), lgamma_r(5.0L, &sign));
1235 ASSERT_EQ(1, sign);
1236 }
1237
TEST(math,lgammal_r_17471883)1238 TEST(math, lgammal_r_17471883) {
1239 int sign;
1240
1241 sign = 0;
1242 ASSERT_DOUBLE_EQ(HUGE_VAL, lgammal_r(0.0L, &sign));
1243 ASSERT_EQ(1, sign);
1244 sign = 0;
1245 ASSERT_DOUBLE_EQ(HUGE_VAL, lgammal_r(-0.0L, &sign));
1246 ASSERT_EQ(-1, sign);
1247 }
1248
TEST(math,tgamma)1249 TEST(math, tgamma) {
1250 ASSERT_DOUBLE_EQ(24.0, tgamma(5.0));
1251 }
1252
TEST(math,tgammaf)1253 TEST(math, tgammaf) {
1254 ASSERT_FLOAT_EQ(24.0f, tgammaf(5.0f));
1255 }
1256
TEST(math,tgammal)1257 TEST(math, tgammal) {
1258 ASSERT_DOUBLE_EQ(24.0L, tgammal(5.0L));
1259 }
1260
TEST(math,j0)1261 TEST(math, j0) {
1262 ASSERT_DOUBLE_EQ(1.0, j0(0.0));
1263 ASSERT_DOUBLE_EQ(0.76519768655796661, j0(1.0));
1264 }
1265
TEST(math,j0f)1266 TEST(math, j0f) {
1267 ASSERT_FLOAT_EQ(1.0f, j0f(0.0f));
1268 ASSERT_FLOAT_EQ(0.76519769f, j0f(1.0f));
1269 }
1270
TEST(math,j1)1271 TEST(math, j1) {
1272 ASSERT_DOUBLE_EQ(0.0, j1(0.0));
1273 ASSERT_DOUBLE_EQ(0.44005058574493355, j1(1.0));
1274 }
1275
TEST(math,j1f)1276 TEST(math, j1f) {
1277 ASSERT_FLOAT_EQ(0.0f, j1f(0.0f));
1278 ASSERT_FLOAT_EQ(0.44005057f, j1f(1.0f));
1279 }
1280
TEST(math,jn)1281 TEST(math, jn) {
1282 ASSERT_DOUBLE_EQ(0.0, jn(4, 0.0));
1283 ASSERT_DOUBLE_EQ(0.0024766389641099553, jn(4, 1.0));
1284 }
1285
TEST(math,jnf)1286 TEST(math, jnf) {
1287 ASSERT_FLOAT_EQ(0.0f, jnf(4, 0.0f));
1288 ASSERT_FLOAT_EQ(0.0024766389f, jnf(4, 1.0f));
1289 }
1290
TEST(math,y0)1291 TEST(math, y0) {
1292 ASSERT_DOUBLE_EQ(-HUGE_VAL, y0(0.0));
1293 ASSERT_DOUBLE_EQ(0.08825696421567697, y0(1.0));
1294 }
1295
TEST(math,y0f)1296 TEST(math, y0f) {
1297 ASSERT_FLOAT_EQ(-HUGE_VALF, y0f(0.0f));
1298 ASSERT_FLOAT_EQ(0.088256963f, y0f(1.0f));
1299 }
1300
TEST(math,y1)1301 TEST(math, y1) {
1302 ASSERT_DOUBLE_EQ(-HUGE_VAL, y1(0.0));
1303 ASSERT_DOUBLE_EQ(-0.78121282130028868, y1(1.0));
1304 }
1305
TEST(math,y1f)1306 TEST(math, y1f) {
1307 ASSERT_FLOAT_EQ(-HUGE_VALF, y1f(0.0f));
1308 ASSERT_FLOAT_EQ(-0.78121281f, y1f(1.0f));
1309 }
1310
TEST(math,yn)1311 TEST(math, yn) {
1312 ASSERT_DOUBLE_EQ(-HUGE_VAL, yn(4, 0.0));
1313 ASSERT_DOUBLE_EQ(-33.278423028972114, yn(4, 1.0));
1314 }
1315
TEST(math,ynf)1316 TEST(math, ynf) {
1317 ASSERT_FLOAT_EQ(-HUGE_VALF, ynf(4, 0.0f));
1318 ASSERT_FLOAT_EQ(-33.278423f, ynf(4, 1.0f));
1319 }
1320
TEST(math,frexp)1321 TEST(math, frexp) {
1322 int exp;
1323 double dr = frexp(1024.0, &exp);
1324 ASSERT_DOUBLE_EQ(1024.0, scalbn(dr, exp));
1325 }
1326
TEST(math,frexpf)1327 TEST(math, frexpf) {
1328 int exp;
1329 float fr = frexpf(1024.0f, &exp);
1330 ASSERT_FLOAT_EQ(1024.0f, scalbnf(fr, exp));
1331 }
1332
TEST(math,frexpl)1333 TEST(math, frexpl) {
1334 int exp;
1335 long double ldr = frexpl(1024.0L, &exp);
1336 ASSERT_DOUBLE_EQ(1024.0L, scalbnl(ldr, exp));
1337 }
1338
TEST(math,modf)1339 TEST(math, modf) {
1340 double di;
1341 double df = modf(123.75, &di);
1342 ASSERT_DOUBLE_EQ(123.0, di);
1343 ASSERT_DOUBLE_EQ(0.75, df);
1344 }
1345
TEST(math,modff)1346 TEST(math, modff) {
1347 float fi;
1348 float ff = modff(123.75f, &fi);
1349 ASSERT_FLOAT_EQ(123.0f, fi);
1350 ASSERT_FLOAT_EQ(0.75f, ff);
1351 }
1352
TEST(math,modfl)1353 TEST(math, modfl) {
1354 long double ldi;
1355 long double ldf = modfl(123.75L, &ldi);
1356 ASSERT_DOUBLE_EQ(123.0L, ldi);
1357 ASSERT_DOUBLE_EQ(0.75L, ldf);
1358 }
1359
TEST(math,remquo)1360 TEST(math, remquo) {
1361 int q;
1362 double d = remquo(13.0, 4.0, &q);
1363 ASSERT_EQ(3, q);
1364 ASSERT_DOUBLE_EQ(1.0, d);
1365 }
1366
TEST(math,remquof)1367 TEST(math, remquof) {
1368 int q;
1369 float f = remquof(13.0f, 4.0f, &q);
1370 ASSERT_EQ(3, q);
1371 ASSERT_FLOAT_EQ(1.0, f);
1372 }
1373
TEST(math,remquol)1374 TEST(math, remquol) {
1375 int q;
1376 long double ld = remquol(13.0L, 4.0L, &q);
1377 ASSERT_DOUBLE_EQ(3L, q);
1378 ASSERT_DOUBLE_EQ(1.0L, ld);
1379 }
1380
1381 // https://code.google.com/p/android/issues/detail?id=6697
TEST(math,frexpf_public_bug_6697)1382 TEST(math, frexpf_public_bug_6697) {
1383 int exp;
1384 float fr = frexpf(14.1f, &exp);
1385 ASSERT_FLOAT_EQ(14.1f, scalbnf(fr, exp));
1386 }
1387
TEST(math,exp2_STRICT_ALIGN_OpenBSD_bug)1388 TEST(math, exp2_STRICT_ALIGN_OpenBSD_bug) {
1389 // OpenBSD/x86's libm had a bug here, but it was already fixed in FreeBSD:
1390 // http://svnweb.FreeBSD.org/base/head/lib/msun/src/math_private.h?revision=240827&view=markup
1391 ASSERT_DOUBLE_EQ(5.0, exp2(log2(5)));
1392 ASSERT_FLOAT_EQ(5.0f, exp2f(log2f(5)));
1393 ASSERT_DOUBLE_EQ(5.0L, exp2l(log2l(5)));
1394 }
1395
TEST(math,nextafterl_OpenBSD_bug)1396 TEST(math, nextafterl_OpenBSD_bug) {
1397 // OpenBSD/x86's libm had a bug here.
1398 ASSERT_TRUE(nextafter(1.0, 0.0) - 1.0 < 0.0);
1399 ASSERT_TRUE(nextafterf(1.0f, 0.0f) - 1.0f < 0.0f);
1400 ASSERT_TRUE(nextafterl(1.0L, 0.0L) - 1.0L < 0.0L);
1401 }
1402
1403 #include "math_data/acos_intel_data.h"
TEST(math,acos_intel)1404 TEST(math, acos_intel) {
1405 DoMathDataTest<1>(g_acos_intel_data, acos);
1406 }
1407
1408 #include "math_data/acosf_intel_data.h"
TEST(math,acosf_intel)1409 TEST(math, acosf_intel) {
1410 DoMathDataTest<1>(g_acosf_intel_data, acosf);
1411 }
1412
1413 #include "math_data/acosh_intel_data.h"
TEST(math,acosh_intel)1414 TEST(math, acosh_intel) {
1415 DoMathDataTest<2>(g_acosh_intel_data, acosh);
1416 }
1417
1418 #include "math_data/acoshf_intel_data.h"
TEST(math,acoshf_intel)1419 TEST(math, acoshf_intel) {
1420 DoMathDataTest<2>(g_acoshf_intel_data, acoshf);
1421 }
1422
1423 #include "math_data/asin_intel_data.h"
TEST(math,asin_intel)1424 TEST(math, asin_intel) {
1425 DoMathDataTest<1>(g_asin_intel_data, asin);
1426 }
1427
1428 #include "math_data/asinf_intel_data.h"
TEST(math,asinf_intel)1429 TEST(math, asinf_intel) {
1430 DoMathDataTest<1>(g_asinf_intel_data, asinf);
1431 }
1432
1433 #include "math_data/asinh_intel_data.h"
TEST(math,asinh_intel)1434 TEST(math, asinh_intel) {
1435 DoMathDataTest<2>(g_asinh_intel_data, asinh);
1436 }
1437
1438 #include "math_data/asinhf_intel_data.h"
TEST(math,asinhf_intel)1439 TEST(math, asinhf_intel) {
1440 DoMathDataTest<2>(g_asinhf_intel_data, asinhf);
1441 }
1442
1443 #include "math_data/atan2_intel_data.h"
TEST(math,atan2_intel)1444 TEST(math, atan2_intel) {
1445 DoMathDataTest<2>(g_atan2_intel_data, atan2);
1446 }
1447
1448 #include "math_data/atan2f_intel_data.h"
TEST(math,atan2f_intel)1449 TEST(math, atan2f_intel) {
1450 DoMathDataTest<2>(g_atan2f_intel_data, atan2f);
1451 }
1452
1453 #include "math_data/atan_intel_data.h"
TEST(math,atan_intel)1454 TEST(math, atan_intel) {
1455 DoMathDataTest<1>(g_atan_intel_data, atan);
1456 }
1457
1458 #include "math_data/atanf_intel_data.h"
TEST(math,atanf_intel)1459 TEST(math, atanf_intel) {
1460 DoMathDataTest<1>(g_atanf_intel_data, atanf);
1461 }
1462
1463 #include "math_data/atanh_intel_data.h"
TEST(math,atanh_intel)1464 TEST(math, atanh_intel) {
1465 DoMathDataTest<2>(g_atanh_intel_data, atanh);
1466 }
1467
1468 #include "math_data/atanhf_intel_data.h"
TEST(math,atanhf_intel)1469 TEST(math, atanhf_intel) {
1470 DoMathDataTest<2>(g_atanhf_intel_data, atanhf);
1471 }
1472
1473 #include "math_data/cbrt_intel_data.h"
TEST(math,cbrt_intel)1474 TEST(math, cbrt_intel) {
1475 DoMathDataTest<1>(g_cbrt_intel_data, cbrt);
1476 }
1477
1478 #include "math_data/cbrtf_intel_data.h"
TEST(math,cbrtf_intel)1479 TEST(math, cbrtf_intel) {
1480 DoMathDataTest<1>(g_cbrtf_intel_data, cbrtf);
1481 }
1482
1483 #include "math_data/ceil_intel_data.h"
TEST(math,ceil_intel)1484 TEST(math, ceil_intel) {
1485 DoMathDataTest<1>(g_ceil_intel_data, ceil);
1486 }
1487
1488 #include "math_data/ceilf_intel_data.h"
TEST(math,ceilf_intel)1489 TEST(math, ceilf_intel) {
1490 DoMathDataTest<1>(g_ceilf_intel_data, ceilf);
1491 }
1492
1493 #include "math_data/copysign_intel_data.h"
TEST(math,copysign_intel)1494 TEST(math, copysign_intel) {
1495 DoMathDataTest<1>(g_copysign_intel_data, copysign);
1496 }
1497
1498 #include "math_data/copysignf_intel_data.h"
TEST(math,copysignf_intel)1499 TEST(math, copysignf_intel) {
1500 DoMathDataTest<1>(g_copysignf_intel_data, copysignf);
1501 }
1502
1503 #include "math_data/cos_intel_data.h"
TEST(math,cos_intel)1504 TEST(math, cos_intel) {
1505 DoMathDataTest<1>(g_cos_intel_data, cos);
1506 }
1507
1508 #include "math_data/cosf_intel_data.h"
TEST(math,cosf_intel)1509 TEST(math, cosf_intel) {
1510 DoMathDataTest<1>(g_cosf_intel_data, cosf);
1511 }
1512
1513 #include "math_data/cosh_intel_data.h"
TEST(math,cosh_intel)1514 TEST(math, cosh_intel) {
1515 DoMathDataTest<2>(g_cosh_intel_data, cosh);
1516 }
1517
1518 #include "math_data/coshf_intel_data.h"
TEST(math,coshf_intel)1519 TEST(math, coshf_intel) {
1520 DoMathDataTest<2>(g_coshf_intel_data, coshf);
1521 }
1522
1523 #include "math_data/exp_intel_data.h"
TEST(math,exp_intel)1524 TEST(math, exp_intel) {
1525 DoMathDataTest<1>(g_exp_intel_data, exp);
1526 }
1527
1528 #include "math_data/expf_intel_data.h"
TEST(math,expf_intel)1529 TEST(math, expf_intel) {
1530 DoMathDataTest<1>(g_expf_intel_data, expf);
1531 }
1532
1533 #include "math_data/exp2_intel_data.h"
TEST(math,exp2_intel)1534 TEST(math, exp2_intel) {
1535 DoMathDataTest<1>(g_exp2_intel_data, exp2);
1536 }
1537
1538 #include "math_data/exp2f_intel_data.h"
TEST(math,exp2f_intel)1539 TEST(math, exp2f_intel) {
1540 DoMathDataTest<1>(g_exp2f_intel_data, exp2f);
1541 }
1542
1543 #include "math_data/expm1_intel_data.h"
TEST(math,expm1_intel)1544 TEST(math, expm1_intel) {
1545 DoMathDataTest<1>(g_expm1_intel_data, expm1);
1546 }
1547
1548 #include "math_data/expm1f_intel_data.h"
TEST(math,expm1f_intel)1549 TEST(math, expm1f_intel) {
1550 DoMathDataTest<1>(g_expm1f_intel_data, expm1f);
1551 }
1552
1553 #include "math_data/fabs_intel_data.h"
TEST(math,fabs_intel)1554 TEST(math, fabs_intel) {
1555 DoMathDataTest<1>(g_fabs_intel_data, fabs);
1556 }
1557
1558 #include "math_data/fabsf_intel_data.h"
TEST(math,fabsf_intel)1559 TEST(math, fabsf_intel) {
1560 DoMathDataTest<1>(g_fabsf_intel_data, fabsf);
1561 }
1562
1563 #include "math_data/fdim_intel_data.h"
TEST(math,fdim_intel)1564 TEST(math, fdim_intel) {
1565 DoMathDataTest<1>(g_fdim_intel_data, fdim);
1566 }
1567
1568 #include "math_data/fdimf_intel_data.h"
TEST(math,fdimf_intel)1569 TEST(math, fdimf_intel) {
1570 DoMathDataTest<1>(g_fdimf_intel_data, fdimf);
1571 }
1572
1573 #include "math_data/floor_intel_data.h"
TEST(math,floor_intel)1574 TEST(math, floor_intel) {
1575 DoMathDataTest<1>(g_floor_intel_data, floor);
1576 }
1577
1578 #include "math_data/floorf_intel_data.h"
TEST(math,floorf_intel)1579 TEST(math, floorf_intel) {
1580 DoMathDataTest<1>(g_floorf_intel_data, floorf);
1581 }
1582
1583 #include "math_data/fma_intel_data.h"
TEST(math,fma_intel)1584 TEST(math, fma_intel) {
1585 DoMathDataTest<1>(g_fma_intel_data, fma);
1586 }
1587
1588 #include "math_data/fmaf_intel_data.h"
TEST(math,fmaf_intel)1589 TEST(math, fmaf_intel) {
1590 DoMathDataTest<1>(g_fmaf_intel_data, fmaf);
1591 }
1592
1593 #include "math_data/fmax_intel_data.h"
TEST(math,fmax_intel)1594 TEST(math, fmax_intel) {
1595 DoMathDataTest<1>(g_fmax_intel_data, fmax);
1596 }
1597
1598 #include "math_data/fmaxf_intel_data.h"
TEST(math,fmaxf_intel)1599 TEST(math, fmaxf_intel) {
1600 DoMathDataTest<1>(g_fmaxf_intel_data, fmaxf);
1601 }
1602
1603 #include "math_data/fmin_intel_data.h"
TEST(math,fmin_intel)1604 TEST(math, fmin_intel) {
1605 DoMathDataTest<1>(g_fmin_intel_data, fmin);
1606 }
1607
1608 #include "math_data/fminf_intel_data.h"
TEST(math,fminf_intel)1609 TEST(math, fminf_intel) {
1610 DoMathDataTest<1>(g_fminf_intel_data, fminf);
1611 }
1612
1613 #include "math_data/fmod_intel_data.h"
TEST(math,fmod_intel)1614 TEST(math, fmod_intel) {
1615 DoMathDataTest<1>(g_fmod_intel_data, fmod);
1616 }
1617
1618 #include "math_data/fmodf_intel_data.h"
TEST(math,fmodf_intel)1619 TEST(math, fmodf_intel) {
1620 DoMathDataTest<1>(g_fmodf_intel_data, fmodf);
1621 }
1622
1623 #include "math_data/frexp_intel_data.h"
TEST(math,frexp_intel)1624 TEST(math, frexp_intel) {
1625 DoMathDataTest<1>(g_frexp_intel_data, frexp);
1626 }
1627
1628 #include "math_data/frexpf_intel_data.h"
TEST(math,frexpf_intel)1629 TEST(math, frexpf_intel) {
1630 DoMathDataTest<1>(g_frexpf_intel_data, frexpf);
1631 }
1632
1633 #include "math_data/hypot_intel_data.h"
TEST(math,hypot_intel)1634 TEST(math, hypot_intel) {
1635 DoMathDataTest<1>(g_hypot_intel_data, hypot);
1636 }
1637
1638 #include "math_data/hypotf_intel_data.h"
TEST(math,hypotf_intel)1639 TEST(math, hypotf_intel) {
1640 DoMathDataTest<1>(g_hypotf_intel_data, hypotf);
1641 }
1642
1643 #include "math_data/ilogb_intel_data.h"
TEST(math,ilogb_intel)1644 TEST(math, ilogb_intel) {
1645 DoMathDataTest<1>(g_ilogb_intel_data, ilogb);
1646 }
1647
1648 #include "math_data/ilogbf_intel_data.h"
TEST(math,ilogbf_intel)1649 TEST(math, ilogbf_intel) {
1650 DoMathDataTest<1>(g_ilogbf_intel_data, ilogbf);
1651 }
1652
1653 #include "math_data/ldexp_intel_data.h"
TEST(math,ldexp_intel)1654 TEST(math, ldexp_intel) {
1655 DoMathDataTest<1>(g_ldexp_intel_data, ldexp);
1656 }
1657
1658 #include "math_data/ldexpf_intel_data.h"
TEST(math,ldexpf_intel)1659 TEST(math, ldexpf_intel) {
1660 DoMathDataTest<1>(g_ldexpf_intel_data, ldexpf);
1661 }
1662
1663 #include "math_data/llrint_intel_data.h"
TEST(math,llrint_intel)1664 TEST(math, llrint_intel) {
1665 DoMathDataTest<1>(g_llrint_intel_data, llrint);
1666 }
1667
1668 #include "math_data/llrintf_intel_data.h"
TEST(math,llrintf_intel)1669 TEST(math, llrintf_intel) {
1670 DoMathDataTest<1>(g_llrintf_intel_data, llrintf);
1671 }
1672
1673 #include "math_data/log_intel_data.h"
TEST(math,log_intel)1674 TEST(math, log_intel) {
1675 DoMathDataTest<1>(g_log_intel_data, log);
1676 }
1677
1678 #include "math_data/logf_intel_data.h"
TEST(math,logf_intel)1679 TEST(math, logf_intel) {
1680 DoMathDataTest<1>(g_logf_intel_data, logf);
1681 }
1682
1683 #include "math_data/log10_intel_data.h"
TEST(math,log10_intel)1684 TEST(math, log10_intel) {
1685 DoMathDataTest<1>(g_log10_intel_data, log10);
1686 }
1687
1688 #include "math_data/log10f_intel_data.h"
TEST(math,log10f_intel)1689 TEST(math, log10f_intel) {
1690 DoMathDataTest<1>(g_log10f_intel_data, log10f);
1691 }
1692
1693 #include "math_data/log1p_intel_data.h"
TEST(math,log1p_intel)1694 TEST(math, log1p_intel) {
1695 DoMathDataTest<1>(g_log1p_intel_data, log1p);
1696 }
1697
1698 #include "math_data/log1pf_intel_data.h"
TEST(math,log1pf_intel)1699 TEST(math, log1pf_intel) {
1700 DoMathDataTest<1>(g_log1pf_intel_data, log1pf);
1701 }
1702
1703 #include "math_data/log2_intel_data.h"
TEST(math,log2_intel)1704 TEST(math, log2_intel) {
1705 DoMathDataTest<1>(g_log2_intel_data, log2);
1706 }
1707
1708 #include "math_data/log2f_intel_data.h"
TEST(math,log2f_intel)1709 TEST(math, log2f_intel) {
1710 DoMathDataTest<1>(g_log2f_intel_data, log2f);
1711 }
1712
1713 #include "math_data/logb_intel_data.h"
TEST(math,logb_intel)1714 TEST(math, logb_intel) {
1715 DoMathDataTest<1>(g_logb_intel_data, logb);
1716 }
1717
1718 #include "math_data/logbf_intel_data.h"
TEST(math,logbf_intel)1719 TEST(math, logbf_intel) {
1720 DoMathDataTest<1>(g_logbf_intel_data, logbf);
1721 }
1722
1723 #include "math_data/lrint_intel_data.h"
TEST(math,lrint_intel)1724 TEST(math, lrint_intel) {
1725 DoMathDataTest<1>(g_lrint_intel_data, lrint);
1726 }
1727
1728 #include "math_data/lrintf_intel_data.h"
TEST(math,lrintf_intel)1729 TEST(math, lrintf_intel) {
1730 DoMathDataTest<1>(g_lrintf_intel_data, lrintf);
1731 }
1732
1733 #include "math_data/modf_intel_data.h"
TEST(math,modf_intel)1734 TEST(math, modf_intel) {
1735 DoMathDataTest<1>(g_modf_intel_data, modf);
1736 }
1737
1738 #include "math_data/modff_intel_data.h"
TEST(math,modff_intel)1739 TEST(math, modff_intel) {
1740 DoMathDataTest<1>(g_modff_intel_data, modff);
1741 }
1742
1743 #include "math_data/nearbyint_intel_data.h"
TEST(math,nearbyint_intel)1744 TEST(math, nearbyint_intel) {
1745 DoMathDataTest<1>(g_nearbyint_intel_data, nearbyint);
1746 }
1747
1748 #include "math_data/nearbyintf_intel_data.h"
TEST(math,nearbyintf_intel)1749 TEST(math, nearbyintf_intel) {
1750 DoMathDataTest<1>(g_nearbyintf_intel_data, nearbyintf);
1751 }
1752
1753 #include "math_data/nextafter_intel_data.h"
TEST(math,nextafter_intel)1754 TEST(math, nextafter_intel) {
1755 DoMathDataTest<1>(g_nextafter_intel_data, nextafter);
1756 }
1757
1758 #include "math_data/nextafterf_intel_data.h"
TEST(math,nextafterf_intel)1759 TEST(math, nextafterf_intel) {
1760 DoMathDataTest<1>(g_nextafterf_intel_data, nextafterf);
1761 }
1762
1763 #include "math_data/pow_intel_data.h"
TEST(math,pow_intel)1764 TEST(math, pow_intel) {
1765 DoMathDataTest<1>(g_pow_intel_data, pow);
1766 }
1767
1768 #include "math_data/powf_intel_data.h"
TEST(math,powf_intel)1769 TEST(math, powf_intel) {
1770 DoMathDataTest<1>(g_powf_intel_data, powf);
1771 }
1772
1773 #include "math_data/remainder_intel_data.h"
TEST(math,remainder_intel)1774 TEST(math, remainder_intel) {
1775 DoMathDataTest<1>(g_remainder_intel_data, remainder);
1776 }
1777
1778 #include "math_data/remainderf_intel_data.h"
TEST(math,remainderf_intel)1779 TEST(math, remainderf_intel) {
1780 DoMathDataTest<1>(g_remainderf_intel_data, remainderf);
1781 }
1782
1783 #include "math_data/remquo_intel_data.h"
TEST(math,remquo_intel)1784 TEST(math, remquo_intel) {
1785 DoMathDataTest<1>(g_remquo_intel_data, remquo);
1786 }
1787
1788 #include "math_data/remquof_intel_data.h"
TEST(math,remquof_intel)1789 TEST(math, remquof_intel) {
1790 DoMathDataTest<1>(g_remquof_intel_data, remquof);
1791 }
1792
1793 #include "math_data/rint_intel_data.h"
TEST(math,rint_intel)1794 TEST(math, rint_intel) {
1795 DoMathDataTest<1>(g_rint_intel_data, rint);
1796 }
1797
1798 #include "math_data/rintf_intel_data.h"
TEST(math,rintf_intel)1799 TEST(math, rintf_intel) {
1800 DoMathDataTest<1>(g_rintf_intel_data, rintf);
1801 }
1802
1803 #include "math_data/round_intel_data.h"
TEST(math,round_intel)1804 TEST(math, round_intel) {
1805 DoMathDataTest<1>(g_round_intel_data, round);
1806 }
1807
1808 #include "math_data/roundf_intel_data.h"
TEST(math,roundf_intel)1809 TEST(math, roundf_intel) {
1810 DoMathDataTest<1>(g_roundf_intel_data, roundf);
1811 }
1812
1813 #include "math_data/scalb_intel_data.h"
TEST(math,scalb_intel)1814 TEST(math, scalb_intel) {
1815 DoMathDataTest<1>(g_scalb_intel_data, scalb);
1816 }
1817
1818 #include "math_data/scalbf_intel_data.h"
TEST(math,scalbf_intel)1819 TEST(math, scalbf_intel) {
1820 DoMathDataTest<1>(g_scalbf_intel_data, scalbf);
1821 }
1822
1823 #include "math_data/scalbn_intel_data.h"
TEST(math,scalbn_intel)1824 TEST(math, scalbn_intel) {
1825 DoMathDataTest<1>(g_scalbn_intel_data, scalbn);
1826 }
1827
1828 #include "math_data/scalbnf_intel_data.h"
TEST(math,scalbnf_intel)1829 TEST(math, scalbnf_intel) {
1830 DoMathDataTest<1>(g_scalbnf_intel_data, scalbnf);
1831 }
1832
1833 #include "math_data/significand_intel_data.h"
TEST(math,significand_intel)1834 TEST(math, significand_intel) {
1835 DoMathDataTest<1>(g_significand_intel_data, significand);
1836 }
1837
1838 #include "math_data/significandf_intel_data.h"
TEST(math,significandf_intel)1839 TEST(math, significandf_intel) {
1840 DoMathDataTest<1>(g_significandf_intel_data, significandf);
1841 }
1842
1843 #include "math_data/sin_intel_data.h"
TEST(math,sin_intel)1844 TEST(math, sin_intel) {
1845 DoMathDataTest<1>(g_sin_intel_data, sin);
1846 }
1847
1848 #include "math_data/sinf_intel_data.h"
TEST(math,sinf_intel)1849 TEST(math, sinf_intel) {
1850 DoMathDataTest<1>(g_sinf_intel_data, sinf);
1851 }
1852
1853 #include "math_data/sinh_intel_data.h"
TEST(math,sinh_intel)1854 TEST(math, sinh_intel) {
1855 DoMathDataTest<2>(g_sinh_intel_data, sinh);
1856 }
1857
1858 #include "math_data/sinhf_intel_data.h"
TEST(math,sinhf_intel)1859 TEST(math, sinhf_intel) {
1860 DoMathDataTest<2>(g_sinhf_intel_data, sinhf);
1861 }
1862
1863 #include "math_data/sincos_intel_data.h"
TEST(math,sincos_intel)1864 TEST(math, sincos_intel) {
1865 DoMathDataTest<1>(g_sincos_intel_data, sincos);
1866 }
1867
1868 #include "math_data/sincosf_intel_data.h"
TEST(math,sincosf_intel)1869 TEST(math, sincosf_intel) {
1870 DoMathDataTest<1>(g_sincosf_intel_data, sincosf);
1871 }
1872
1873 #include "math_data/sqrt_intel_data.h"
TEST(math,sqrt_intel)1874 TEST(math, sqrt_intel) {
1875 DoMathDataTest<1>(g_sqrt_intel_data, sqrt);
1876 }
1877
1878 #include "math_data/sqrtf_intel_data.h"
TEST(math,sqrtf_intel)1879 TEST(math, sqrtf_intel) {
1880 DoMathDataTest<1>(g_sqrtf_intel_data, sqrtf);
1881 }
1882
1883 #include "math_data/tan_intel_data.h"
TEST(math,tan_intel)1884 TEST(math, tan_intel) {
1885 DoMathDataTest<1>(g_tan_intel_data, tan);
1886 }
1887
1888 #include "math_data/tanf_intel_data.h"
TEST(math,tanf_intel)1889 TEST(math, tanf_intel) {
1890 DoMathDataTest<1>(g_tanf_intel_data, tanf);
1891 }
1892
1893 #include "math_data/tanh_intel_data.h"
TEST(math,tanh_intel)1894 TEST(math, tanh_intel) {
1895 DoMathDataTest<2>(g_tanh_intel_data, tanh);
1896 }
1897
1898 #include "math_data/tanhf_intel_data.h"
TEST(math,tanhf_intel)1899 TEST(math, tanhf_intel) {
1900 DoMathDataTest<2>(g_tanhf_intel_data, tanhf);
1901 }
1902
1903 #include "math_data/trunc_intel_data.h"
TEST(math,trunc_intel)1904 TEST(math, trunc_intel) {
1905 DoMathDataTest<1>(g_trunc_intel_data, trunc);
1906 }
1907
1908 #include "math_data/truncf_intel_data.h"
TEST(math,truncf_intel)1909 TEST(math, truncf_intel) {
1910 DoMathDataTest<1>(g_truncf_intel_data, truncf);
1911 }
1912