11592Srgrimes// { dg-do run { xfail broken_cplxf_arg } }
21592Srgrimes// { dg-options "-O0" }
31592Srgrimes// 2000-11-20
41592Srgrimes// Benjamin Kosnik bkoz@redhat.com
51592Srgrimes
61592Srgrimes// Copyright (C) 2000-2015 Free Software Foundation, Inc.
71592Srgrimes//
81592Srgrimes// This file is part of the GNU ISO C++ Library.  This library is free
91592Srgrimes// software; you can redistribute it and/or modify it under the
101592Srgrimes// terms of the GNU General Public License as published by the
111592Srgrimes// Free Software Foundation; either version 3, or (at your option)
121592Srgrimes// any later version.
131592Srgrimes
141592Srgrimes// This library is distributed in the hope that it will be useful,
151592Srgrimes// but WITHOUT ANY WARRANTY; without even the implied warranty of
161592Srgrimes// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
171592Srgrimes// GNU General Public License for more details.
181592Srgrimes
191592Srgrimes// You should have received a copy of the GNU General Public License along
201592Srgrimes// with this library; see the file COPYING3.  If not see
211592Srgrimes// <http://www.gnu.org/licenses/>.
221592Srgrimes
231592Srgrimes#include <complex>
241592Srgrimes#include <testsuite_hooks.h>
251592Srgrimes
261592Srgrimesvoid test01()
271592Srgrimes{
281592Srgrimes using namespace std;
291592Srgrimes bool test __attribute__((unused)) = true;
301592Srgrimes typedef complex<double> complex_type;
311592Srgrimes const double cd1 = -11.451;
328697Sdg const double cd2 = -442.1533;
3317478Smarkm
341592Srgrimes complex_type a(cd1, cd2);
351592Srgrimes double d;
3617478Smarkm d = a.real();
371592Srgrimes VERIFY( d == cd1 );
381592Srgrimes
391592Srgrimes d = a.imag();
401592Srgrimes VERIFY( d == cd2 );
411592Srgrimes
4217478Smarkm complex_type c(cd1, cd2);
431592Srgrimes double d6 = abs(c);
4417478Smarkm VERIFY( d6 >= 0 );
451592Srgrimes
461592Srgrimes double d7 = arg(c);
471592Srgrimes double d8 = atan2(c.imag(), c.real());
4817478Smarkm VERIFY( d7 == d8 );
491592Srgrimes
501592Srgrimes double d9 = norm(c);
511592Srgrimes double d10 = d6 * d6;
521592Srgrimes VERIFY( d9 - d10 == 0 );
531592Srgrimes
541592Srgrimes complex_type e __attribute__((unused)) = conj(c);
551592Srgrimes
561592Srgrimes complex_type f = polar(c.imag(), 0.0);
571592Srgrimes VERIFY( f.real() != 0 );
588240Swollman}
591592Srgrimes
601592Srgrimes
611592Srgrimesint main()
621592Srgrimes{
638240Swollman  test01();
641592Srgrimes  return 0;
651592Srgrimes}
661592Srgrimes