cc7378c3a21f987d2ca92e7abeb7dc8057b4e473
[platform/upstream/m4.git] / tests / test-math-c++.cc
1 /* Test of <math.h> substitute in C++ mode.
2    Copyright (C) 2010-2016 Free Software Foundation, Inc.
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation; either version 3 of the License, or
7    (at your option) any later version.
8
9    This program 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
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
16
17 /* Written by Bruno Haible <bruno@clisp.org>, 2010.  */
18
19 #define GNULIB_NAMESPACE gnulib
20 #include <config.h>
21
22 #include <math.h>
23
24 #include "signature.h"
25
26 /* Signature check for a function that takes a real-floating argument.
27    Check that each overloaded function with the specified signature
28    exists in the GNULIB_NAMESPACE namespace.  */
29 #define REAL_FLOATING_CHECK(func,\
30                             rettype1, parameters1,\
31                             rettype2, parameters2,\
32                             rettype3, parameters3) \
33   OVERLOADED_CHECK (func, rettype1, parameters1, _1); \
34   OVERLOADED_CHECK (func, rettype2, parameters2, _2); \
35   OVERLOADED_CHECK (func, rettype3, parameters3, _3)
36 #define OVERLOADED_CHECK(func, rettype, parameters, suffix) \
37   static rettype (* _GL_UNUSED signature_check_ ## func ## suffix) parameters \
38     = static_cast<rettype(*)parameters>(GNULIB_NAMESPACE::func)
39
40
41 /* Keep these checks in the same order as math.in.h!  */
42
43 #if GNULIB_TEST_ACOSF
44 SIGNATURE_CHECK (GNULIB_NAMESPACE::acosf, float, (float));
45 #endif
46 //SIGNATURE_CHECK (GNULIB_NAMESPACE::acos, double, (double));
47 #if GNULIB_TEST_ACOSL
48 SIGNATURE_CHECK (GNULIB_NAMESPACE::acosl, long double, (long double));
49 #endif
50
51 #if GNULIB_TEST_ASINF
52 SIGNATURE_CHECK (GNULIB_NAMESPACE::asinf, float, (float));
53 #endif
54 //SIGNATURE_CHECK (GNULIB_NAMESPACE::asin, double, (double));
55 #if GNULIB_TEST_ASINL
56 SIGNATURE_CHECK (GNULIB_NAMESPACE::asinl, long double, (long double));
57 #endif
58
59 #if GNULIB_TEST_ATANF
60 SIGNATURE_CHECK (GNULIB_NAMESPACE::atanf, float, (float));
61 #endif
62 //SIGNATURE_CHECK (GNULIB_NAMESPACE::atan, double, (double));
63 #if GNULIB_TEST_ATANL
64 SIGNATURE_CHECK (GNULIB_NAMESPACE::atanl, long double, (long double));
65 #endif
66
67 #if GNULIB_TEST_ATAN2F
68 SIGNATURE_CHECK (GNULIB_NAMESPACE::atan2f, float, (float, float));
69 #endif
70 //SIGNATURE_CHECK (GNULIB_NAMESPACE::atan2, double, (double, double));
71
72 #if GNULIB_TEST_CBRTF
73 SIGNATURE_CHECK (GNULIB_NAMESPACE::cbrtf, float, (float));
74 #endif
75 #if GNULIB_TEST_CBRT
76 SIGNATURE_CHECK (GNULIB_NAMESPACE::cbrt, double, (double));
77 #endif
78 #if GNULIB_TEST_CBRTL
79 SIGNATURE_CHECK (GNULIB_NAMESPACE::cbrtl, long double, (long double));
80 #endif
81
82 #if GNULIB_TEST_CEILF
83 SIGNATURE_CHECK (GNULIB_NAMESPACE::ceilf, float, (float));
84 #endif
85 #if GNULIB_TEST_CEIL
86 SIGNATURE_CHECK (GNULIB_NAMESPACE::ceil, double, (double));
87 #endif
88 #if GNULIB_TEST_CEILL
89 SIGNATURE_CHECK (GNULIB_NAMESPACE::ceill, long double, (long double));
90 #endif
91
92 #if GNULIB_TEST_COPYSIGNF
93 SIGNATURE_CHECK (GNULIB_NAMESPACE::copysignf, float, (float, float));
94 #endif
95 #if GNULIB_TEST_COPYSIGN
96 SIGNATURE_CHECK (GNULIB_NAMESPACE::copysign, double, (double, double));
97 #endif
98 #if GNULIB_TEST_COPYSIGNL
99 SIGNATURE_CHECK (GNULIB_NAMESPACE::copysignl, long double,
100                  (long double, long double));
101 #endif
102
103 #if GNULIB_TEST_COSF
104 SIGNATURE_CHECK (GNULIB_NAMESPACE::cosf, float, (float));
105 #endif
106 //SIGNATURE_CHECK (GNULIB_NAMESPACE::cos, double, (double));
107 #if GNULIB_TEST_COSL
108 SIGNATURE_CHECK (GNULIB_NAMESPACE::cosl, long double, (long double));
109 #endif
110
111 #if GNULIB_TEST_COSHF
112 SIGNATURE_CHECK (GNULIB_NAMESPACE::coshf, float, (float));
113 #endif
114 //SIGNATURE_CHECK (GNULIB_NAMESPACE::cosh, double, (double));
115
116 //SIGNATURE_CHECK (GNULIB_NAMESPACE::erf, double, (double));
117
118 //SIGNATURE_CHECK (GNULIB_NAMESPACE::erfc, double, (double));
119
120 #if GNULIB_TEST_EXPF
121 SIGNATURE_CHECK (GNULIB_NAMESPACE::expf, float, (float));
122 #endif
123 //SIGNATURE_CHECK (GNULIB_NAMESPACE::exp, double, (double));
124 #if GNULIB_TEST_EXPL
125 SIGNATURE_CHECK (GNULIB_NAMESPACE::expl, long double, (long double));
126 #endif
127
128 #if GNULIB_TEST_EXP2F
129 SIGNATURE_CHECK (GNULIB_NAMESPACE::exp2f, float, (float));
130 #endif
131 #if GNULIB_TEST_EXP2
132 SIGNATURE_CHECK (GNULIB_NAMESPACE::exp2, double, (double));
133 #endif
134 #if GNULIB_TEST_EXP2L
135 SIGNATURE_CHECK (GNULIB_NAMESPACE::exp2l, long double, (long double));
136 #endif
137
138 #if GNULIB_TEST_EXPM1F
139 SIGNATURE_CHECK (GNULIB_NAMESPACE::expm1f, float, (float));
140 #endif
141 #if GNULIB_TEST_EXPM1
142 SIGNATURE_CHECK (GNULIB_NAMESPACE::expm1, double, (double));
143 #endif
144 #if GNULIB_TEST_EXPM1L
145 SIGNATURE_CHECK (GNULIB_NAMESPACE::expm1l, long double, (long double));
146 #endif
147
148 #if GNULIB_TEST_FABSF
149 SIGNATURE_CHECK (GNULIB_NAMESPACE::fabsf, float, (float));
150 #endif
151 //SIGNATURE_CHECK (GNULIB_NAMESPACE::fabs, double, (double));
152 #if GNULIB_TEST_FABSL
153 SIGNATURE_CHECK (GNULIB_NAMESPACE::fabsl, long double, (long double));
154 #endif
155
156 #if GNULIB_TEST_FLOORF
157 SIGNATURE_CHECK (GNULIB_NAMESPACE::floorf, float, (float));
158 #endif
159 #if GNULIB_TEST_FLOOR
160 SIGNATURE_CHECK (GNULIB_NAMESPACE::floor, double, (double));
161 #endif
162 #if GNULIB_TEST_FLOORL
163 SIGNATURE_CHECK (GNULIB_NAMESPACE::floorl, long double, (long double));
164 #endif
165
166 #if GNULIB_TEST_FMODF
167 SIGNATURE_CHECK (GNULIB_NAMESPACE::fmodf, float, (float, float));
168 #endif
169 #if GNULIB_TEST_FMOD
170 SIGNATURE_CHECK (GNULIB_NAMESPACE::fmod, double, (double, double));
171 #endif
172 #if GNULIB_TEST_FMODL
173 SIGNATURE_CHECK (GNULIB_NAMESPACE::fmodl, long double,
174                  (long double, long double));
175 #endif
176
177 #if GNULIB_TEST_FREXPF
178 SIGNATURE_CHECK (GNULIB_NAMESPACE::frexpf, float, (float, int *));
179 #endif
180 #if GNULIB_TEST_FREXP
181 SIGNATURE_CHECK (GNULIB_NAMESPACE::frexp, double, (double, int *));
182 #endif
183 #if GNULIB_TEST_FREXPL
184 SIGNATURE_CHECK (GNULIB_NAMESPACE::frexpl, long double, (long double, int *));
185 #endif
186
187 #if GNULIB_TEST_HYPOTF
188 SIGNATURE_CHECK (GNULIB_NAMESPACE::hypotf, float, (float, float));
189 #endif
190 #if GNULIB_TEST_HYPOT
191 SIGNATURE_CHECK (GNULIB_NAMESPACE::hypot, double, (double, double));
192 #endif
193 #if GNULIB_TEST_HYPOTL
194 SIGNATURE_CHECK (GNULIB_NAMESPACE::hypotl, long double,
195                  (long double, long double));
196 #endif
197
198 #if GNULIB_TEST_ILOGBF
199 SIGNATURE_CHECK (GNULIB_NAMESPACE::ilogbf, int, (float));
200 #endif
201 #if GNULIB_TEST_ILOGB
202 SIGNATURE_CHECK (GNULIB_NAMESPACE::ilogb, int, (double));
203 #endif
204 #if GNULIB_TEST_ILOGBL
205 SIGNATURE_CHECK (GNULIB_NAMESPACE::ilogbl, int, (long double));
206 #endif
207
208 //SIGNATURE_CHECK (GNULIB_NAMESPACE::j0, double, (double));
209
210 //SIGNATURE_CHECK (GNULIB_NAMESPACE::j1, double, (double));
211
212 //SIGNATURE_CHECK (GNULIB_NAMESPACE::jn, double, (int, double));
213
214 #if GNULIB_TEST_LDEXPF
215 SIGNATURE_CHECK (GNULIB_NAMESPACE::ldexpf, float, (float, int));
216 #endif
217 //SIGNATURE_CHECK (GNULIB_NAMESPACE::ldexp, double, (double, int));
218 #if GNULIB_TEST_LDEXPL
219 SIGNATURE_CHECK (GNULIB_NAMESPACE::ldexpl, long double, (long double, int));
220 #endif
221
222 //SIGNATURE_CHECK (GNULIB_NAMESPACE::lgamma, double, (double));
223
224 #if GNULIB_TEST_LOG10
225 SIGNATURE_CHECK (GNULIB_NAMESPACE::log10, double, (double));
226 #endif
227 #if GNULIB_TEST_LOG10L
228 SIGNATURE_CHECK (GNULIB_NAMESPACE::log10l, long double, (long double));
229 #endif
230
231 #if GNULIB_TEST_LOG1PF
232 SIGNATURE_CHECK (GNULIB_NAMESPACE::log1pf, float, (float));
233 #endif
234 #if GNULIB_TEST_LOG1P
235 SIGNATURE_CHECK (GNULIB_NAMESPACE::log1p, double, (double));
236 #endif
237 #if GNULIB_TEST_LOG1PL
238 SIGNATURE_CHECK (GNULIB_NAMESPACE::log1pl, long double, (long double));
239 #endif
240
241 #if GNULIB_TEST_LOGF
242 SIGNATURE_CHECK (GNULIB_NAMESPACE::logf, float, (float));
243 #endif
244 #if GNULIB_TEST_LOG
245 SIGNATURE_CHECK (GNULIB_NAMESPACE::log, double, (double));
246 #endif
247 #if GNULIB_TEST_LOGL
248 SIGNATURE_CHECK (GNULIB_NAMESPACE::logl, long double, (long double));
249 #endif
250
251 #if GNULIB_TEST_LOG10F
252 SIGNATURE_CHECK (GNULIB_NAMESPACE::log10f, float, (float));
253 #endif
254
255 #if GNULIB_TEST_LOG2F
256 SIGNATURE_CHECK (GNULIB_NAMESPACE::log2f, float, (float));
257 #endif
258 #if GNULIB_TEST_LOG2
259 SIGNATURE_CHECK (GNULIB_NAMESPACE::log2, double, (double));
260 #endif
261 #if GNULIB_TEST_LOG2L
262 SIGNATURE_CHECK (GNULIB_NAMESPACE::log2l, long double, (long double));
263 #endif
264
265 #if GNULIB_TEST_LOGBF
266 SIGNATURE_CHECK (GNULIB_NAMESPACE::logbf, float, (float));
267 #endif
268 #if GNULIB_TEST_LOGB
269 SIGNATURE_CHECK (GNULIB_NAMESPACE::logb, double, (double));
270 #endif
271 #if GNULIB_TEST_LOGBL
272 SIGNATURE_CHECK (GNULIB_NAMESPACE::logbl, long double, (long double));
273 #endif
274
275 #if GNULIB_TEST_MODFF
276 SIGNATURE_CHECK (GNULIB_NAMESPACE::modff, float, (float, float *));
277 #endif
278 #if GNULIB_TEST_MODF
279 SIGNATURE_CHECK (GNULIB_NAMESPACE::modf, double, (double, double *));
280 #endif
281 #if GNULIB_TEST_MODFL
282 SIGNATURE_CHECK (GNULIB_NAMESPACE::modfl, long double,
283                  (long double, long double *));
284 #endif
285
286 //SIGNATURE_CHECK (GNULIB_NAMESPACE::nextafter, double, (double, double));
287
288 #if GNULIB_TEST_POWF
289 SIGNATURE_CHECK (GNULIB_NAMESPACE::powf, float, (float, float));
290 #endif
291 //SIGNATURE_CHECK (GNULIB_NAMESPACE::pow, double, (double, double));
292
293 #if GNULIB_TEST_REMAINDERF
294 SIGNATURE_CHECK (GNULIB_NAMESPACE::remainderf, float, (float, float));
295 #endif
296 #if GNULIB_TEST_REMAINDER
297 SIGNATURE_CHECK (GNULIB_NAMESPACE::remainder, double, (double, double));
298 #endif
299 #if GNULIB_TEST_REMAINDERL
300 SIGNATURE_CHECK (GNULIB_NAMESPACE::remainderl, long double,
301                  (long double, long double));
302 #endif
303
304 #if GNULIB_TEST_RINTF
305 SIGNATURE_CHECK (GNULIB_NAMESPACE::rintf, float, (float));
306 #endif
307 #if GNULIB_TEST_RINT
308 SIGNATURE_CHECK (GNULIB_NAMESPACE::rint, double, (double));
309 #endif
310 #if GNULIB_TEST_RINTL
311 SIGNATURE_CHECK (GNULIB_NAMESPACE::rintl, long double, (long double));
312 #endif
313
314 #if GNULIB_TEST_ROUNDF
315 SIGNATURE_CHECK (GNULIB_NAMESPACE::roundf, float, (float));
316 #endif
317 #if GNULIB_TEST_ROUND
318 SIGNATURE_CHECK (GNULIB_NAMESPACE::round, double, (double));
319 #endif
320 #if GNULIB_TEST_ROUNDL
321 SIGNATURE_CHECK (GNULIB_NAMESPACE::roundl, long double, (long double));
322 #endif
323
324 #if GNULIB_TEST_SINF
325 SIGNATURE_CHECK (GNULIB_NAMESPACE::sinf, float, (float));
326 #endif
327 //SIGNATURE_CHECK (GNULIB_NAMESPACE::sin, double, (double));
328 #if GNULIB_TEST_SINL
329 SIGNATURE_CHECK (GNULIB_NAMESPACE::sinl, long double, (long double));
330 #endif
331
332 #if GNULIB_TEST_SINHF
333 SIGNATURE_CHECK (GNULIB_NAMESPACE::sinhf, float, (float));
334 #endif
335 //SIGNATURE_CHECK (GNULIB_NAMESPACE::sinh, double, (double));
336
337 #if GNULIB_TEST_SQRTF
338 SIGNATURE_CHECK (GNULIB_NAMESPACE::sqrtf, float, (float));
339 #endif
340 //SIGNATURE_CHECK (GNULIB_NAMESPACE::sqrt, double, (double));
341 #if GNULIB_TEST_SQRTL
342 SIGNATURE_CHECK (GNULIB_NAMESPACE::sqrtl, long double, (long double));
343 #endif
344
345 #if GNULIB_TEST_TANF
346 SIGNATURE_CHECK (GNULIB_NAMESPACE::tanf, float, (float));
347 #endif
348 //SIGNATURE_CHECK (GNULIB_NAMESPACE::tan, double, (double));
349 #if GNULIB_TEST_TANL
350 SIGNATURE_CHECK (GNULIB_NAMESPACE::tanl, long double, (long double));
351 #endif
352
353 #if GNULIB_TEST_TANHF
354 SIGNATURE_CHECK (GNULIB_NAMESPACE::tanhf, float, (float));
355 #endif
356 //SIGNATURE_CHECK (GNULIB_NAMESPACE::tanh, double, (double));
357
358 #if GNULIB_TEST_TRUNCF
359 SIGNATURE_CHECK (GNULIB_NAMESPACE::truncf, float, (float));
360 #endif
361 #if GNULIB_TEST_TRUNC
362 SIGNATURE_CHECK (GNULIB_NAMESPACE::trunc, double, (double));
363 #endif
364 #if GNULIB_TEST_TRUNCL
365 SIGNATURE_CHECK (GNULIB_NAMESPACE::truncl, long double, (long double));
366 #endif
367
368 //SIGNATURE_CHECK (GNULIB_NAMESPACE::y0, double, (double));
369
370 //SIGNATURE_CHECK (GNULIB_NAMESPACE::y1, double, (double));
371
372 //SIGNATURE_CHECK (GNULIB_NAMESPACE::yn, double, (int, double));
373
374 #if GNULIB_TEST_ISFINITE
375 # ifdef isfinite
376 #  error "isfinite should not be a macro in C++"
377 # endif
378 REAL_FLOATING_CHECK (isfinite, int, (float), int, (double), int, (long double));
379 #endif
380
381 #if GNULIB_TEST_ISINF
382 # ifdef isinf
383 #  error "isinf should not be a macro in C++"
384 # endif
385 REAL_FLOATING_CHECK (isinf, int, (float), int, (double), int, (long double));
386 #endif
387
388 #if GNULIB_TEST_ISNAN
389 # ifdef isnan
390 #  error "isnan should not be a macro in C++"
391 # endif
392 REAL_FLOATING_CHECK (isnan, int, (float), int, (double), int, (long double));
393 #endif
394
395 #if GNULIB_TEST_SIGNBIT
396 # ifdef signbit
397 #  error "signbit should not be a macro in C++"
398 # endif
399 REAL_FLOATING_CHECK (signbit, int, (float), int, (double), int, (long double));
400 #endif
401
402
403 int
404 main ()
405 {
406 }