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