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