diff options
Diffstat (limited to 'test/std/numerics/complex.number/cmplx.over/arg.pass.cpp')
-rw-r--r-- | test/std/numerics/complex.number/cmplx.over/arg.pass.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/test/std/numerics/complex.number/cmplx.over/arg.pass.cpp b/test/std/numerics/complex.number/cmplx.over/arg.pass.cpp new file mode 100644 index 0000000000000..978c6255ac38b --- /dev/null +++ b/test/std/numerics/complex.number/cmplx.over/arg.pass.cpp @@ -0,0 +1,55 @@ +//===----------------------------------------------------------------------===// +// +// 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> + +// template<Arithmetic T> +// T +// arg(T x); + +#include <complex> +#include <type_traits> +#include <cassert> + +#include "../cases.h" + +template <class T> +void +test(T x, typename std::enable_if<std::is_integral<T>::value>::type* = 0) +{ + static_assert((std::is_same<decltype(std::arg(x)), double>::value), ""); + assert(std::arg(x) == arg(std::complex<double>(x, 0))); +} + +template <class T> +void +test(T x, typename std::enable_if<!std::is_integral<T>::value>::type* = 0) +{ + static_assert((std::is_same<decltype(std::arg(x)), T>::value), ""); + assert(std::arg(x) == arg(std::complex<T>(x, 0))); +} + +template <class T> +void +test() +{ + test<T>(0); + test<T>(1); + test<T>(10); +} + +int main() +{ + test<float>(); + test<double>(); + test<long double>(); + test<int>(); + test<unsigned>(); + test<long long>(); +} |