summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/numerics/complex.number/layout.pass.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/std/numerics/complex.number/layout.pass.cpp')
-rw-r--r--libcxx/test/std/numerics/complex.number/layout.pass.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/libcxx/test/std/numerics/complex.number/layout.pass.cpp b/libcxx/test/std/numerics/complex.number/layout.pass.cpp
new file mode 100644
index 00000000000..a9f356d4a40
--- /dev/null
+++ b/libcxx/test/std/numerics/complex.number/layout.pass.cpp
@@ -0,0 +1,36 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <complex>
+
+#include <complex>
+#include <cassert>
+
+template <class T>
+void
+test()
+{
+ std::complex<T> z;
+ T* a = (T*)&z;
+ assert(0 == z.real());
+ assert(0 == z.imag());
+ assert(a[0] == z.real());
+ assert(a[1] == z.imag());
+ a[0] = 5;
+ a[1] = 6;
+ assert(a[0] == z.real());
+ assert(a[1] == z.imag());
+}
+
+int main()
+{
+ test<float>();
+ test<double>();
+ test<long double>();
+}
OpenPOWER on IntegriCloud