blob: d39b2de132c1314ba468b91c4e3171d99c5c22d1 [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Chandler Carruth57b08b02019-01-19 10:56:40 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Howard Hinnant3e519522010-05-11 19:42:16 +00006//
7//===----------------------------------------------------------------------===//
8
9// <complex>
10
11#include <complex>
12#include <cassert>
13
Marshall Clow7fc6a552019-05-31 18:35:30 +000014#include "test_macros.h"
15
Howard Hinnant3e519522010-05-11 19:42:16 +000016template <class T>
17void
18test()
19{
20 std::complex<T> z;
21 T* a = (T*)&z;
22 assert(0 == z.real());
23 assert(0 == z.imag());
24 assert(a[0] == z.real());
25 assert(a[1] == z.imag());
26 a[0] = 5;
27 a[1] = 6;
28 assert(a[0] == z.real());
29 assert(a[1] == z.imag());
30}
31
JF Bastien2df59c52019-02-04 20:31:13 +000032int main(int, char**)
Howard Hinnant3e519522010-05-11 19:42:16 +000033{
34 test<float>();
35 test<double>();
36 test<long double>();
JF Bastien2df59c52019-02-04 20:31:13 +000037
38 return 0;
Howard Hinnant3e519522010-05-11 19:42:16 +000039}