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 | //===----------------------------------------------------------------------===// |
8 | |
9 | // UNSUPPORTED: c++03, c++11, c++14, c++17 |
10 | |
11 | #include <cassert> |
12 | #include <numbers> |
13 | |
14 | constexpr bool tests() { |
15 | [[maybe_unused]] float f0{std::numbers::e_v<float>}; |
16 | [[maybe_unused]] float f1{std::numbers::log2e_v<float>}; |
17 | [[maybe_unused]] float f2{std::numbers::log10e_v<float>}; |
18 | [[maybe_unused]] float f3{std::numbers::pi_v<float>}; |
19 | [[maybe_unused]] float f4{std::numbers::inv_pi_v<float>}; |
20 | [[maybe_unused]] float f5{std::numbers::inv_sqrtpi_v<float>}; |
21 | [[maybe_unused]] float f6{std::numbers::ln2_v<float>}; |
22 | [[maybe_unused]] float f7{std::numbers::ln10_v<float>}; |
23 | [[maybe_unused]] float f8{std::numbers::sqrt2_v<float>}; |
24 | [[maybe_unused]] float f9{std::numbers::sqrt3_v<float>}; |
25 | [[maybe_unused]] float f10{std::numbers::inv_sqrt3_v<float>}; |
26 | [[maybe_unused]] float f11{std::numbers::egamma_v<float>}; |
27 | [[maybe_unused]] float f12{std::numbers::phi_v<float>}; |
28 | |
29 | double d0{std::numbers::e_v<double>}; |
30 | double d1{std::numbers::log2e_v<double>}; |
31 | double d2{std::numbers::log10e_v<double>}; |
32 | double d3{std::numbers::pi_v<double>}; |
33 | double d4{std::numbers::inv_pi_v<double>}; |
34 | double d5{std::numbers::inv_sqrtpi_v<double>}; |
35 | double d6{std::numbers::ln2_v<double>}; |
36 | double d7{std::numbers::ln10_v<double>}; |
37 | double d8{std::numbers::sqrt2_v<double>}; |
38 | double d9{std::numbers::sqrt3_v<double>}; |
39 | double d10{std::numbers::inv_sqrt3_v<double>}; |
40 | double d11{std::numbers::egamma_v<double>}; |
41 | double d12{std::numbers::phi_v<double>}; |
42 | |
43 | assert(d0 == std::numbers::e); |
44 | assert(d1 == std::numbers::log2e); |
45 | assert(d2 == std::numbers::log10e); |
46 | assert(d3 == std::numbers::pi); |
47 | assert(d4 == std::numbers::inv_pi); |
48 | assert(d5 == std::numbers::inv_sqrtpi); |
49 | assert(d6 == std::numbers::ln2); |
50 | assert(d7 == std::numbers::ln10); |
51 | assert(d8 == std::numbers::sqrt2); |
52 | assert(d9 == std::numbers::sqrt3); |
53 | assert(d10 == std::numbers::inv_sqrt3); |
54 | assert(d11 == std::numbers::egamma); |
55 | assert(d12 == std::numbers::phi); |
56 | |
57 | [[maybe_unused]] long double ld0{std::numbers::e_v<long double>}; |
58 | [[maybe_unused]] long double ld1{std::numbers::log2e_v<long double>}; |
59 | [[maybe_unused]] long double ld2{std::numbers::log10e_v<long double>}; |
60 | [[maybe_unused]] long double ld3{std::numbers::pi_v<long double>}; |
61 | [[maybe_unused]] long double ld4{std::numbers::inv_pi_v<long double>}; |
62 | [[maybe_unused]] long double ld5{std::numbers::inv_sqrtpi_v<long double>}; |
63 | [[maybe_unused]] long double ld6{std::numbers::ln2_v<long double>}; |
64 | [[maybe_unused]] long double ld7{std::numbers::ln10_v<long double>}; |
65 | [[maybe_unused]] long double ld8{std::numbers::sqrt2_v<long double>}; |
66 | [[maybe_unused]] long double ld9{std::numbers::sqrt3_v<long double>}; |
67 | [[maybe_unused]] long double ld10{std::numbers::inv_sqrt3_v<long double>}; |
68 | [[maybe_unused]] long double ld11{std::numbers::egamma_v<long double>}; |
69 | [[maybe_unused]] long double ld12{std::numbers::phi_v<long double>}; |
70 | |
71 | return true; |
72 | } |
73 | |
74 | static_assert(tests()); |
75 | |
76 | int main(int, char**) { |
77 | tests(); |
78 | return 0; |
79 | } |
80 | |