Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | |
Josh Gao | ff504e6 | 2016-04-29 11:52:39 -0700 | [diff] [blame] | 17 | // This file is compiled against both glibc and bionic, and our complex.h |
| 18 | // depends on bionic-specific macros, so hack around that. |
| 19 | #include <sys/cdefs.h> |
| 20 | #if !defined(__INTRODUCED_IN) |
| 21 | #define __INTRODUCED_IN(x) |
| 22 | #endif |
| 23 | |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 24 | // libc++ actively gets in the way of including <complex.h> from C++, so we |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 25 | // have to be naughty. |
Dan Albert | b2ca031 | 2017-08-04 15:37:39 -0700 | [diff] [blame] | 26 | #include "../libc/include/complex.h" |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 27 | |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 28 | // (libc++ also seems to have really bad implementations of its own that ignore |
| 29 | // the intricacies of floating point math.) |
| 30 | // http://llvm.org/bugs/show_bug.cgi?id=21504 |
| 31 | |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 32 | #include <math.h> // For M_PI_2/M_PI_2l. |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 33 | |
Yi Kong | 43ccab8 | 2018-01-05 16:22:10 -0800 | [diff] [blame] | 34 | // Prettify gtest Complex printing. |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 35 | #include <iostream> |
Yi Kong | 43ccab8 | 2018-01-05 16:22:10 -0800 | [diff] [blame] | 36 | namespace testing { |
| 37 | namespace internal { |
| 38 | inline void PrintTo(const double _Complex& c, std::ostream* os) { |
| 39 | *os << "(" << creal(c) << "," << cimag(c) << "i)"; |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 40 | } |
Yi Kong | 43ccab8 | 2018-01-05 16:22:10 -0800 | [diff] [blame] | 41 | inline void PrintTo(const float _Complex& c, std::ostream* os) { |
| 42 | *os << "(" << crealf(c) << "," << cimagf(c) << "i)"; |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 43 | } |
Yi Kong | 43ccab8 | 2018-01-05 16:22:10 -0800 | [diff] [blame] | 44 | inline void PrintTo(const long double _Complex& c, std::ostream* os) { |
| 45 | *os << "(" << creall(c) << "," << cimagl(c) << "i)"; |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 46 | } |
Yi Kong | 43ccab8 | 2018-01-05 16:22:10 -0800 | [diff] [blame] | 47 | } |
| 48 | } |
| 49 | |
| 50 | // Macro 'I' defined in complex.h conflicts with gtest.h. |
| 51 | #pragma push_macro("I") |
| 52 | #undef I |
| 53 | #include <gtest/gtest.h> |
| 54 | #pragma pop_macro("I") |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 55 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 56 | TEST(complex_h, cabs) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 57 | ASSERT_EQ(0.0, cabs(0)); |
| 58 | } |
| 59 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 60 | TEST(complex_h, cabsf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 61 | ASSERT_EQ(0.0, cabsf(0)); |
| 62 | } |
| 63 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 64 | TEST(complex_h, cabsl) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 65 | ASSERT_EQ(0.0, cabsl(0)); |
| 66 | } |
| 67 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 68 | TEST(complex_h, cacos) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 69 | ASSERT_EQ(M_PI_2, cacos(0.0)); |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 70 | } |
| 71 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 72 | TEST(complex_h, cacosf) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 73 | ASSERT_EQ(static_cast<float>(M_PI_2), cacosf(0.0)); |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 74 | } |
| 75 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 76 | TEST(complex_h, cacosl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 77 | ASSERT_EQ(M_PI_2l, cacosl(0.0)); |
| 78 | } |
| 79 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 80 | TEST(complex_h, cacosh) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 81 | ASSERT_EQ(0.0, cacosh(1.0)); |
| 82 | } |
| 83 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 84 | TEST(complex_h, cacoshl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 85 | ASSERT_EQ(0.0, cacoshl(1.0)); |
| 86 | } |
| 87 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 88 | TEST(complex_h, cacoshf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 89 | ASSERT_EQ(0.0, cacoshf(1.0)); |
| 90 | } |
| 91 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 92 | TEST(complex_h, carg) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 93 | ASSERT_EQ(0.0, carg(0)); |
| 94 | } |
| 95 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 96 | TEST(complex_h, cargf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 97 | ASSERT_EQ(0.0, cargf(0)); |
| 98 | } |
| 99 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 100 | TEST(complex_h, cargl) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 101 | ASSERT_EQ(0.0, cargl(0)); |
| 102 | } |
| 103 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 104 | TEST(complex_h, casin) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 105 | ASSERT_EQ(0.0, casin(0)); |
| 106 | } |
| 107 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 108 | TEST(complex_h, casinf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 109 | ASSERT_EQ(0.0, casinf(0)); |
| 110 | } |
| 111 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 112 | TEST(complex_h, casinl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 113 | ASSERT_EQ(0.0, casinl(0)); |
| 114 | } |
| 115 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 116 | TEST(complex_h, casinh) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 117 | ASSERT_EQ(0.0, casinh(0)); |
| 118 | } |
| 119 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 120 | TEST(complex_h, casinhf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 121 | ASSERT_EQ(0.0, casinhf(0)); |
| 122 | } |
| 123 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 124 | TEST(complex_h, casinhl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 125 | ASSERT_EQ(0.0, casinhl(0)); |
| 126 | } |
| 127 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 128 | TEST(complex_h, catan) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 129 | ASSERT_EQ(0.0, catan(0)); |
| 130 | } |
| 131 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 132 | TEST(complex_h, catanf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 133 | ASSERT_EQ(0.0, catanf(0)); |
| 134 | } |
| 135 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 136 | TEST(complex_h, catanl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 137 | ASSERT_EQ(0.0, catanl(0)); |
| 138 | } |
| 139 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 140 | TEST(complex_h, catanh) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 141 | ASSERT_EQ(0.0, catanh(0)); |
| 142 | } |
| 143 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 144 | TEST(complex_h, catanhf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 145 | ASSERT_EQ(0.0, catanhf(0)); |
| 146 | } |
| 147 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 148 | TEST(complex_h, catanhl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 149 | ASSERT_EQ(0.0, catanhl(0)); |
| 150 | } |
| 151 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 152 | TEST(complex_h, ccos) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 153 | ASSERT_EQ(1.0, ccos(0)); |
| 154 | } |
| 155 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 156 | TEST(complex_h, ccosf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 157 | ASSERT_EQ(1.0, ccosf(0)); |
| 158 | } |
| 159 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 160 | TEST(complex_h, ccosl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 161 | ASSERT_EQ(1.0, ccosl(0)); |
| 162 | } |
| 163 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 164 | TEST(complex_h, ccosh) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 165 | ASSERT_EQ(1.0, ccosh(0)); |
| 166 | } |
| 167 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 168 | TEST(complex_h, ccoshf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 169 | ASSERT_EQ(1.0, ccoshf(0)); |
| 170 | } |
| 171 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 172 | TEST(complex_h, ccoshl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 173 | ASSERT_EQ(1.0, ccoshl(0)); |
| 174 | } |
| 175 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 176 | TEST(complex_h, cexp) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 177 | ASSERT_EQ(1.0, cexp(0)); |
| 178 | } |
| 179 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 180 | TEST(complex_h, cexpf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 181 | ASSERT_EQ(1.0, cexpf(0)); |
| 182 | } |
| 183 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 184 | TEST(complex_h, cexpl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 185 | ASSERT_EQ(1.0, cexpl(0)); |
| 186 | } |
| 187 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 188 | TEST(complex_h, cimag) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 189 | ASSERT_EQ(0.0, cimag(0)); |
| 190 | } |
| 191 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 192 | TEST(complex_h, cimagf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 193 | ASSERT_EQ(0.0f, cimagf(0)); |
| 194 | } |
| 195 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 196 | TEST(complex_h, cimagl) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 197 | ASSERT_EQ(0.0, cimagl(0)); |
| 198 | } |
| 199 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 200 | TEST(complex_h, clog) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 201 | ASSERT_EQ(0.0, clog(1.0)); |
| 202 | } |
| 203 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 204 | TEST(complex_h, clogf) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 205 | ASSERT_EQ(0.0f, clogf(1.0f)); |
| 206 | } |
| 207 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 208 | TEST(complex_h, clogl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 209 | ASSERT_EQ(0.0L, clogl(1.0L)); |
| 210 | } |
| 211 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 212 | TEST(complex_h, conj) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 213 | ASSERT_EQ(0.0, conj(0)); |
| 214 | } |
| 215 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 216 | TEST(complex_h, conjf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 217 | ASSERT_EQ(0.0f, conjf(0)); |
| 218 | } |
| 219 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 220 | TEST(complex_h, conjl) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 221 | ASSERT_EQ(0.0, conjl(0)); |
| 222 | } |
| 223 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 224 | TEST(complex_h, cpow) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 225 | ASSERT_EQ(8.0, cpow(2.0, 3.0)); |
| 226 | } |
| 227 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 228 | TEST(complex_h, cpowf) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 229 | ASSERT_EQ(8.0f, cpowf(2.0f, 3.0f)); |
| 230 | } |
| 231 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 232 | TEST(complex_h, cpowl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 233 | ASSERT_EQ(8.0L, cpowl(2.0L, 3.0L)); |
| 234 | } |
| 235 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 236 | TEST(complex_h, cproj) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 237 | ASSERT_EQ(0.0, cproj(0)); |
| 238 | } |
| 239 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 240 | TEST(complex_h, cprojf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 241 | ASSERT_EQ(0.0f, cprojf(0)); |
| 242 | } |
| 243 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 244 | TEST(complex_h, cprojl) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 245 | ASSERT_EQ(0.0, cprojl(0)); |
| 246 | } |
| 247 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 248 | TEST(complex_h, creal) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 249 | ASSERT_EQ(2.0, creal(2.0 + 3.0I)); |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 250 | } |
| 251 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 252 | TEST(complex_h, crealf) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 253 | ASSERT_EQ(2.0f, crealf(2.0f + 3.0fI)); |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 254 | } |
| 255 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 256 | TEST(complex_h, creall) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 257 | ASSERT_EQ(2.0, creall(2.0L + 3.0LI)); |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 258 | } |
| 259 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 260 | TEST(complex_h, csin) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 261 | ASSERT_EQ(0.0, csin(0)); |
| 262 | } |
| 263 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 264 | TEST(complex_h, csinf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 265 | ASSERT_EQ(0.0, csinf(0)); |
| 266 | } |
| 267 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 268 | TEST(complex_h, csinl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 269 | ASSERT_EQ(0.0, csinl(0)); |
| 270 | } |
| 271 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 272 | TEST(complex_h, csinh) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 273 | ASSERT_EQ(0.0, csinh(0)); |
| 274 | } |
| 275 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 276 | TEST(complex_h, csinhf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 277 | ASSERT_EQ(0.0, csinhf(0)); |
| 278 | } |
| 279 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 280 | TEST(complex_h, csinhl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 281 | ASSERT_EQ(0.0, csinhl(0)); |
| 282 | } |
| 283 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 284 | TEST(complex_h, csqrt) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 285 | ASSERT_EQ(0.0, csqrt(0)); |
| 286 | } |
| 287 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 288 | TEST(complex_h, csqrtf) { |
Elliott Hughes | e9719f3 | 2016-09-26 09:35:04 -0700 | [diff] [blame] | 289 | ASSERT_EQ(0.0f, csqrtf(0)); |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 290 | } |
| 291 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 292 | TEST(complex_h, csqrtl) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 293 | ASSERT_EQ(0.0, csqrtl(0)); |
| 294 | } |
| 295 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 296 | TEST(complex_h, ctan) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 297 | ASSERT_EQ(0.0, ctan(0)); |
| 298 | } |
| 299 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 300 | TEST(complex_h, ctanf) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 301 | ASSERT_EQ(0.0, ctanf(0)); |
| 302 | } |
| 303 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 304 | TEST(complex_h, ctanl) { |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 305 | ASSERT_EQ(0.0, ctanl(0)); |
| 306 | } |
| 307 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 308 | TEST(complex_h, ctanh) { |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 309 | ASSERT_EQ(0.0, ctanh(0)); |
Elliott Hughes | 505ecd6 | 2018-07-23 14:25:36 -0700 | [diff] [blame] | 310 | |
| 311 | double complex z; |
| 312 | |
| 313 | // If z is NaN+0i, the result is NaN+0i. |
| 314 | z = ctanh(nan("") + 0i); |
| 315 | ASSERT_TRUE(isnan(creal(z))); |
| 316 | ASSERT_EQ(0.0, cimag(z)); |
| 317 | |
| 318 | // If z is NaN+yi, the result is NaN+NaNi. |
| 319 | z = ctanh(nan("") + 2.0i); |
| 320 | ASSERT_TRUE(isnan(creal(z))); |
| 321 | ASSERT_TRUE(isnan(cimag(z))); |
| 322 | |
| 323 | // If z is NaN+NaNi, the result is NaN+NaNi. |
| 324 | z = ctanh(nan("") + nan("") * I); |
| 325 | ASSERT_TRUE(isnan(creal(z))); |
| 326 | ASSERT_TRUE(isnan(cimag(z))); |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 327 | } |
| 328 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 329 | TEST(complex_h, ctanhf) { |
Elliott Hughes | 505ecd6 | 2018-07-23 14:25:36 -0700 | [diff] [blame] | 330 | ASSERT_EQ(0.0f, ctanhf(0.0f)); |
| 331 | |
| 332 | float complex z; |
| 333 | |
| 334 | // If z is NaN+0i, the result is NaN+0i. |
| 335 | z = ctanhf(nanf("") + 0.0fi); |
| 336 | ASSERT_TRUE(isnan(crealf(z))); |
| 337 | ASSERT_EQ(0.0f, cimagf(z)); |
| 338 | |
| 339 | // If z is NaN+yi, the result is NaN+NaNi. |
| 340 | z = ctanhf(nanf("") + 2.0fi); |
| 341 | ASSERT_TRUE(isnan(crealf(z))); |
| 342 | ASSERT_TRUE(isnan(cimagf(z))); |
| 343 | |
| 344 | // If z is NaN+NaNi, the result is NaN+NaNi. |
| 345 | z = ctanhf(nanf("") + nanf("") * I); |
| 346 | ASSERT_TRUE(isnan(crealf(z))); |
| 347 | ASSERT_TRUE(isnan(cimagf(z))); |
Elliott Hughes | b8ee16f | 2014-11-06 11:16:55 -0800 | [diff] [blame] | 348 | } |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 349 | |
Elliott Hughes | ab2d3e1 | 2023-06-07 17:16:34 +0000 | [diff] [blame] | 350 | TEST(complex_h, ctanhl) { |
Elliott Hughes | 505ecd6 | 2018-07-23 14:25:36 -0700 | [diff] [blame] | 351 | ASSERT_EQ(0.0L, ctanhl(0.0L)); |
| 352 | |
| 353 | long double complex z; |
| 354 | |
| 355 | // If z is NaN+0i, the result is NaN+0i. |
| 356 | z = ctanhl(nanl("") + 0.0Li); |
| 357 | ASSERT_TRUE(isnan(creall(z))); |
| 358 | // TODO: this case is currently broken in the netbsd ctanhl. |
| 359 | // ASSERT_EQ(0.0L, cimagl(z)); |
| 360 | |
| 361 | // If z is NaN+yi, the result is NaN+NaNi. |
| 362 | z = ctanhl(nanl("") + 2.0Li); |
| 363 | ASSERT_TRUE(isnan(creall(z))); |
| 364 | ASSERT_TRUE(isnan(cimagl(z))); |
| 365 | |
| 366 | // If z is NaN+NaNi, the result is NaN+NaNi. |
| 367 | z = ctanhl(nanl("") + nanl("") * I); |
| 368 | ASSERT_TRUE(isnan(creall(z))); |
| 369 | ASSERT_TRUE(isnan(cimagl(z))); |
Elliott Hughes | 9ee6adb | 2016-03-11 14:49:13 -0800 | [diff] [blame] | 370 | } |