[RISCV] Fix mgather -> riscv.masked.strided.load combine not extending indices (...
[llvm-project.git] / libcxx / test / std / numerics / complex.number / complex.value.ops / abs.pass.cpp
blobd5ed2a6ba148cf0e28c795c4fd06a13b231bd725
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<class T>
12 // T
13 // abs(const complex<T>& x);
15 #include <complex>
16 #include <cassert>
18 #include "test_macros.h"
19 #include "../cases.h"
21 template <class T>
22 void
23 test()
25 std::complex<T> z(3, 4);
26 assert(abs(z) == 5);
29 void test_edges()
31 const unsigned N = sizeof(testcases) / sizeof(testcases[0]);
32 for (unsigned i = 0; i < N; ++i)
34 double r = abs(testcases[i]);
35 switch (classify(testcases[i]))
37 case zero:
38 assert(r == 0);
39 assert(!std::signbit(r));
40 break;
41 case non_zero:
42 assert(std::isfinite(r) && r > 0);
43 break;
44 case inf:
45 assert(std::isinf(r) && r > 0);
46 break;
47 case NaN:
48 assert(std::isnan(r));
49 break;
50 case non_zero_nan:
51 assert(std::isnan(r));
52 break;
57 int main(int, char**)
59 test<float>();
60 test<double>();
61 test<long double>();
62 test_edges();
64 return 0;