[clang-format] Write in text mode with LF in dump_format_[help|style].py
[llvm-project.git] / libcxx / test / std / numerics / complex.number / cmplx.over / arg.pass.cpp
blob0152761da67cc2cf760bef900cfc96ad6d95f97f
1 //===----------------------------------------------------------------------===//
2 //
3 // 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
6 //
7 //===----------------------------------------------------------------------===//
9 // <complex>
11 // template<Arithmetic T>
12 // T
13 // arg(T x);
15 #include <complex>
16 #include <type_traits>
17 #include <cassert>
19 #include "test_macros.h"
20 #include "../cases.h"
22 template <class T>
23 void
24 test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0)
26 static_assert((std::is_same<decltype(std::arg(x)), double>::value), "");
27 assert(std::arg(x) == arg(std::complex<double>(static_cast<double>(x), 0)));
30 template <class T>
31 void
32 test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0)
34 static_assert((std::is_same<decltype(std::arg(x)), T>::value), "");
35 assert(std::arg(x) == arg(std::complex<T>(x, 0)));
38 template <class T>
39 void
40 test()
42 test<T>(0);
43 test<T>(1);
44 test<T>(10);
47 int main(int, char**)
49 test<float>();
50 test<double>();
51 test<long double>();
52 test<int>();
53 test<unsigned>();
54 test<long long>();
56 return 0;