]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/26_numerics/complex/13450.cc
Update copyright years in libstdc++-v3/
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / 26_numerics / complex / 13450.cc
CommitLineData
ecddf99e 1// { dg-do run { xfail broken_cplxf_arg } }
75d1ddc1 2
aa118a03 3// Copyright (C) 2004-2014 Free Software Foundation, Inc.
52ddaf41
PK
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
52ddaf41
PK
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License along
748086b7
JJ
17// with this library; see the file COPYING3. If not see
18// <http://www.gnu.org/licenses/>.
52ddaf41
PK
19
20// 26.2.8 complex transcendentals
21
22#include <complex>
23#include <limits>
24#include <testsuite_hooks.h>
25
26template<typename T>
27 void test01_do(T a, T b)
28 {
29 using namespace std;
30 bool test __attribute__((unused)) = true;
31 typedef complex<T> cplx;
32
c6feb697 33 T eps = numeric_limits<T>::epsilon() * 100;
52ddaf41
PK
34
35 cplx ref = pow(cplx(a, T()), cplx(b, T()));
36 cplx res1 = pow(a, cplx(b, T()));
37 cplx res2 = pow(cplx(a, T()), b);
38
39 VERIFY( abs(ref - res1) < eps );
40 VERIFY( abs(ref - res2) < eps );
41 VERIFY( abs(res1 - res2) < eps );
42 }
43
44// libstdc++/13450
45void test01()
46{
47 float f1 = -1.0f;
48 float f2 = 0.5f;
49 test01_do(f1, f2);
50
51 f1 = -3.2f;
52 f2 = 1.4f;
53 test01_do(f1, f2);
54
55 double d1 = -1.0;
56 double d2 = 0.5;
57 test01_do(d1, d2);
58
59 d1 = -3.2;
60 d2 = 1.4;
61 test01_do(d1, d2);
62
30cc5540
JM
63#if __LDBL_MANT_DIG__ != 106
64 /* For IBM long double, epsilon is too small (since 1.0 plus any
65 double is representable) to be able to expect results within
66 epsilon * 100 (which may be much less than 1ulp for a particular
67 long double value). */
52ddaf41
PK
68 long double ld1 = -1.0l;
69 long double ld2 = 0.5l;
70 test01_do(ld1, ld2);
71
72 ld1 = -3.2l;
73 ld2 = 1.4l;
74 test01_do(ld1, ld2);
30cc5540 75#endif
52ddaf41
PK
76}
77
78int main()
79{
80 test01();
81 return 0;
82}