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