Home | History | Annotate | Download | only in complex.members
      1 //===----------------------------------------------------------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 // <complex>
     11 
     12 // void real(T val);
     13 // void imag(T val);
     14 
     15 #include <complex>
     16 #include <cassert>
     17 
     18 template <class T>
     19 void
     20 test()
     21 {
     22     std::complex<T> c;
     23     assert(c.real() == 0);
     24     assert(c.imag() == 0);
     25     c.real(3.5);
     26     assert(c.real() == 3.5);
     27     assert(c.imag() == 0);
     28     c.imag(4.5);
     29     assert(c.real() == 3.5);
     30     assert(c.imag() == 4.5);
     31     c.real(-4.5);
     32     assert(c.real() == -4.5);
     33     assert(c.imag() == 4.5);
     34     c.imag(-5.5);
     35     assert(c.real() == -4.5);
     36     assert(c.imag() == -5.5);
     37 }
     38 
     39 int main()
     40 {
     41     test<float>();
     42     test<double>();
     43     test<long double>();
     44 }
     45