| 1 |
// Copyright (C) 2023-2025 Free Software Foundation, Inc. |
| 2 |
// |
| 3 |
// This file is part of the GNU ISO C++ Library. This library is free |
| 4 |
// software; you can redistribute it and/or modify it under the |
| 5 |
// terms of the GNU General Public License as published by the |
| 6 |
// Free Software Foundation; either version 3, or (at your option) |
| 7 |
// any later version. |
| 8 |
|
| 9 |
// This library is distributed in the hope that it will be useful, |
| 10 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
// GNU General Public License for more details. |
| 13 |
|
| 14 |
// You should have received a copy of the GNU General Public License along |
| 15 |
// with this library; see the file COPYING3. If not see |
| 16 |
// <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
// { dg-do run { target c++11 } } |
| 19 |
|
| 20 |
#include <testsuite_hooks.h> |
| 21 |
|
| 22 |
#include <type_traits> |
| 23 |
#include <cmath> |
| 24 |
// also include functions in global namespace |
| 25 |
#include <math.h> |
| 26 |
|
| 27 |
static_assert(std::is_same<decltype(std::acosf(0.0)), float>::value, ""); |
| 28 |
static_assert(std::is_same<decltype(std::asinf(0.0)), float>::value, ""); |
| 29 |
static_assert(std::is_same<decltype(std::atanf(0.0)), float>::value, ""); |
| 30 |
static_assert(std::is_same<decltype(std::atan2f(0.0, 0.0)), float>::value, ""); |
| 31 |
static_assert(std::is_same<decltype(std::ceilf(0.0)), float>::value, ""); |
| 32 |
static_assert(std::is_same<decltype(std::cosf(0.0)), float>::value, ""); |
| 33 |
static_assert(std::is_same<decltype(std::coshf(0.0)), float>::value, ""); |
| 34 |
static_assert(std::is_same<decltype(std::expf(0.0)), float>::value, ""); |
| 35 |
static_assert(std::is_same<decltype(std::fabsf(0.0)), float>::value, ""); |
| 36 |
static_assert(std::is_same<decltype(std::floorf(0.0)), float>::value, ""); |
| 37 |
static_assert(std::is_same<decltype(std::fmodf(0.0, 0.0)), float>::value, ""); |
| 38 |
static_assert(std::is_same<decltype(std::frexpf(0.0, nullptr)), float>::value, ""); |
| 39 |
static_assert(std::is_same<decltype(std::ldexpf(0.0, 0)), float>::value, ""); |
| 40 |
static_assert(std::is_same<decltype(std::logf(0.0)), float>::value, ""); |
| 41 |
static_assert(std::is_same<decltype(std::log10f(0.0)), float>::value, ""); |
| 42 |
static_assert(std::is_same<decltype(std::modff(0.0, nullptr)), float>::value, ""); |
| 43 |
static_assert(std::is_same<decltype(std::powf(0.0, 0.0)), float>::value, ""); |
| 44 |
static_assert(std::is_same<decltype(std::sinf(0.0)), float>::value, ""); |
| 45 |
static_assert(std::is_same<decltype(std::sinhf(0.0)), float>::value, ""); |
| 46 |
static_assert(std::is_same<decltype(std::sqrtf(0.0)), float>::value, ""); |
| 47 |
static_assert(std::is_same<decltype(std::tanf(0.0)), float>::value, ""); |
| 48 |
static_assert(std::is_same<decltype(std::tanhf(0.0)), float>::value, ""); |
| 49 |
|
| 50 |
static_assert(std::is_same<decltype(std::acosl(0.0)), long double>::value, ""); |
| 51 |
static_assert(std::is_same<decltype(std::asinl(0.0)), long double>::value, ""); |
| 52 |
static_assert(std::is_same<decltype(std::atanl(0.0)), long double>::value, ""); |
| 53 |
static_assert(std::is_same<decltype(std::atan2l(0.0, 0.0)), long double>::value, ""); |
| 54 |
static_assert(std::is_same<decltype(std::ceill(0.0)), long double>::value, ""); |
| 55 |
static_assert(std::is_same<decltype(std::cosl(0.0)), long double>::value, ""); |
| 56 |
static_assert(std::is_same<decltype(std::coshl(0.0)), long double>::value, ""); |
| 57 |
static_assert(std::is_same<decltype(std::expl(0.0)), long double>::value, ""); |
| 58 |
static_assert(std::is_same<decltype(std::fabsl(0.0)), long double>::value, ""); |
| 59 |
static_assert(std::is_same<decltype(std::floorl(0.0)), long double>::value, ""); |
| 60 |
static_assert(std::is_same<decltype(std::fmodl(0.0, 0.0)), long double>::value, ""); |
| 61 |
static_assert(std::is_same<decltype(std::frexpl(0.0, nullptr)), long double>::value, ""); |
| 62 |
static_assert(std::is_same<decltype(std::ldexpl(0.0, 0)), long double>::value, ""); |
| 63 |
static_assert(std::is_same<decltype(std::logl(0.0)), long double>::value, ""); |
| 64 |
static_assert(std::is_same<decltype(std::log10l(0.0)), long double>::value, ""); |
| 65 |
static_assert(std::is_same<decltype(std::modfl(0.0, nullptr)), long double>::value, ""); |
| 66 |
static_assert(std::is_same<decltype(std::powl(0.0, 0.0)), long double>::value, ""); |
| 67 |
static_assert(std::is_same<decltype(std::sinl(0.0)), long double>::value, ""); |
| 68 |
static_assert(std::is_same<decltype(std::sinhl(0.0)), long double>::value, ""); |
| 69 |
static_assert(std::is_same<decltype(std::sqrtl(0.0)), long double>::value, ""); |
| 70 |
static_assert(std::is_same<decltype(std::tanl(0.0)), long double>::value, ""); |
| 71 |
static_assert(std::is_same<decltype(std::tanhl(0.0)), long double>::value, ""); |
| 72 |
|
| 73 |
void |
| 74 |
test_float_global() |
| 75 |
{ |
| 76 |
float x = 1.0f; |
| 77 |
|
| 78 |
int e1 = 0; |
| 79 |
int e2 = 0; |
| 80 |
float i1 = 0.0f; |
| 81 |
float i2 = 0.0f; |
| 82 |
|
| 83 |
VERIFY(::acosf(x) == std::acosf(x)); |
| 84 |
VERIFY(::asinf(x) == std::asinf(x)); |
| 85 |
VERIFY(::atanf(x) == std::atanf(x)); |
| 86 |
VERIFY(::atan2f(x, x) == std::atan2f(x, x)); |
| 87 |
VERIFY(::ceilf(x) == std::ceilf(x)); |
| 88 |
VERIFY(::cosf(x) == std::cosf(x)); |
| 89 |
VERIFY(::coshf(x) == std::coshf(x)); |
| 90 |
VERIFY(::expf(x) == std::expf(x)); |
| 91 |
VERIFY(::fabsf(x) == std::fabsf(x)); |
| 92 |
VERIFY(::floorf(x) == std::floorf(x)); |
| 93 |
VERIFY(::fmodf(x, x) == std::fmodf(x, x)); |
| 94 |
VERIFY(::frexpf(x, &e1) == std::frexpf(x, &e2)); |
| 95 |
VERIFY(e1 == e2); |
| 96 |
VERIFY(::ldexpf(x, 1) == std::ldexpf(x, 1)); |
| 97 |
VERIFY(::logf(x) == std::logf(x)); |
| 98 |
VERIFY(::log10f(x) == std::log10f(x)); |
| 99 |
VERIFY(::modff(x, &i1) == std::modff(x, &i2)); |
| 100 |
VERIFY(i1 == i2); |
| 101 |
VERIFY(::powf(x, x) == std::powf(x, x)); |
| 102 |
VERIFY(::sinf(x) == std::sinf(x)); |
| 103 |
VERIFY(::sinhf(x) == std::sinhf(x)); |
| 104 |
VERIFY(::sqrtf(x) == std::sqrtf(x)); |
| 105 |
VERIFY(::tanf(x) == std::tanf(x)); |
| 106 |
VERIFY(::tanhf(x) == std::tanhf(x)); |
| 107 |
} |
| 108 |
|
| 109 |
void |
| 110 |
test_float_overload() |
| 111 |
{ |
| 112 |
float x = 1.0f; |
| 113 |
|
| 114 |
int e1 = 0; |
| 115 |
int e2 = 0; |
| 116 |
float i1 = 0.0f; |
| 117 |
float i2 = 0.0f; |
| 118 |
|
| 119 |
VERIFY(std::acos(x) == std::acosf(x)); |
| 120 |
VERIFY(std::asin(x) == std::asinf(x)); |
| 121 |
VERIFY(std::atan(x) == std::atanf(x)); |
| 122 |
VERIFY(std::atan2(x, x) == std::atan2f(x, x)); |
| 123 |
VERIFY(std::ceil(x) == std::ceilf(x)); |
| 124 |
VERIFY(std::cos(x) == std::cosf(x)); |
| 125 |
VERIFY(std::cosh(x) == std::coshf(x)); |
| 126 |
VERIFY(std::exp(x) == std::expf(x)); |
| 127 |
VERIFY(std::fabs(x) == std::fabsf(x)); |
| 128 |
VERIFY(std::floor(x) == std::floorf(x)); |
| 129 |
VERIFY(std::fmod(x, x) == std::fmodf(x, x)); |
| 130 |
VERIFY(std::frexp(x, &e1) == std::frexpf(x, &e2)); |
| 131 |
VERIFY(e1 == e2); |
| 132 |
VERIFY(std::ldexp(x, 1) == std::ldexpf(x, 1)); |
| 133 |
VERIFY(std::log(x) == std::logf(x)); |
| 134 |
VERIFY(std::log10(x) == std::log10f(x)); |
| 135 |
VERIFY(std::modf(x, &i1) == std::modff(x, &i2)); |
| 136 |
VERIFY(i1 == i2); |
| 137 |
VERIFY(std::pow(x, x) == std::powf(x, x)); |
| 138 |
VERIFY(std::sin(x) == std::sinf(x)); |
| 139 |
VERIFY(std::sinh(x) == std::sinhf(x)); |
| 140 |
VERIFY(std::sqrt(x) == std::sqrtf(x)); |
| 141 |
VERIFY(std::tan(x) == std::tanf(x)); |
| 142 |
VERIFY(std::tanh(x) == std::tanhf(x)); |
| 143 |
} |
| 144 |
|
| 145 |
void |
| 146 |
test_long_double_global() |
| 147 |
{ |
| 148 |
long double x = 1.0L; |
| 149 |
|
| 150 |
int e1 = 0; |
| 151 |
int e2 = 0; |
| 152 |
long double i1 = 0.0L; |
| 153 |
long double i2 = 0.0L; |
| 154 |
|
| 155 |
VERIFY(::acosl(x) == std::acosl(x)); |
| 156 |
VERIFY(::asinl(x) == std::asinl(x)); |
| 157 |
VERIFY(::atanl(x) == std::atanl(x)); |
| 158 |
VERIFY(::atan2l(x, x) == std::atan2l(x, x)); |
| 159 |
VERIFY(::ceill(x) == std::ceill(x)); |
| 160 |
VERIFY(::cosl(x) == std::cosl(x)); |
| 161 |
VERIFY(::coshl(x) == std::coshl(x)); |
| 162 |
VERIFY(::expl(x) == std::expl(x)); |
| 163 |
VERIFY(::fabsl(x) == std::fabsl(x)); |
| 164 |
VERIFY(::floorl(x) == std::floorl(x)); |
| 165 |
VERIFY(::fmodl(x, x) == std::fmodl(x, x)); |
| 166 |
VERIFY(::frexpl(x, &e1) == std::frexpl(x, &e2)); |
| 167 |
VERIFY(e1 == e2); |
| 168 |
VERIFY(::ldexpl(x, 1) == std::ldexpl(x, 1)); |
| 169 |
VERIFY(::logl(x) == std::logl(x)); |
| 170 |
VERIFY(::log10l(x) == std::log10l(x)); |
| 171 |
VERIFY(::modfl(x, &i1) == std::modfl(x, &i2)); |
| 172 |
VERIFY(i1 == i2); |
| 173 |
VERIFY(::powl(x, x) == std::powl(x, x)); |
| 174 |
VERIFY(::sinl(x) == std::sinl(x)); |
| 175 |
VERIFY(::sinhl(x) == std::sinhl(x)); |
| 176 |
VERIFY(::sqrtl(x) == std::sqrtl(x)); |
| 177 |
VERIFY(::tanl(x) == std::tanl(x)); |
| 178 |
VERIFY(::tanhl(x) == std::tanhl(x)); |
| 179 |
} |
| 180 |
|
| 181 |
void |
| 182 |
test_long_double_overload() |
| 183 |
{ |
| 184 |
long double x = 1.0L; |
| 185 |
|
| 186 |
int e1 = 0; |
| 187 |
int e2 = 0; |
| 188 |
long double i1 = 0.0L; |
| 189 |
long double i2 = 0.0L; |
| 190 |
|
| 191 |
VERIFY(std::acos(x) == std::acosl(x)); |
| 192 |
VERIFY(std::asin(x) == std::asinl(x)); |
| 193 |
VERIFY(std::atan(x) == std::atanl(x)); |
| 194 |
VERIFY(std::atan2(x, x) == std::atan2l(x, x)); |
| 195 |
VERIFY(std::ceil(x) == std::ceill(x)); |
| 196 |
VERIFY(std::cos(x) == std::cosl(x)); |
| 197 |
VERIFY(std::cosh(x) == std::coshl(x)); |
| 198 |
VERIFY(std::exp(x) == std::expl(x)); |
| 199 |
VERIFY(std::fabs(x) == std::fabsl(x)); |
| 200 |
VERIFY(std::floor(x) == std::floorl(x)); |
| 201 |
VERIFY(std::fmod(x, x) == std::fmodl(x, x)); |
| 202 |
VERIFY(std::frexp(x, &e1) == std::frexpl(x, &e2)); |
| 203 |
VERIFY(e1 == e2); |
| 204 |
VERIFY(std::ldexp(x, 1) == std::ldexpl(x, 1)); |
| 205 |
VERIFY(std::log(x) == std::logl(x)); |
| 206 |
VERIFY(std::log10(x) == std::log10l(x)); |
| 207 |
VERIFY(std::modf(x, &i1) == std::modfl(x, &i2)); |
| 208 |
VERIFY(i1 == i2); |
| 209 |
VERIFY(std::pow(x, x) == std::powl(x, x)); |
| 210 |
VERIFY(std::sin(x) == std::sinl(x)); |
| 211 |
VERIFY(std::sinh(x) == std::sinhl(x)); |
| 212 |
VERIFY(std::sqrt(x) == std::sqrtl(x)); |
| 213 |
VERIFY(std::tan(x) == std::tanl(x)); |
| 214 |
VERIFY(std::tanh(x) == std::tanhl(x)); |
| 215 |
} |
| 216 |
|
| 217 |
int |
| 218 |
main () |
| 219 |
{ |
| 220 |
test_float_global(); |
| 221 |
test_float_overload(); |
| 222 |
test_long_double_global(); |
| 223 |
test_long_double_overload(); |
| 224 |
} |