4
4
// (See accompanying file ../LICENSE_1_0.txt or copy at
5
5
// http://www.boost.org/LICENSE_1_0.txt)
6
6
7
+ #include < cnl/numbers.h>
8
+
7
9
#include < cnl/_impl/type_traits/identical.h>
8
10
#include < cnl/constant.h>
9
- #include < cnl/math.h>
10
11
11
12
#include < gtest/gtest.h>
12
13
15
16
namespace {
16
17
#if defined(__cpp_inline_variables)
17
18
18
- namespace test_math_constants {
19
+ namespace test_numbers {
19
20
template <typename T>
20
21
void test_type ()
21
22
{
@@ -25,19 +26,19 @@ namespace {
25
26
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
26
27
#define CNL_EXPECT_NEAR (expected, actual, epsilon ) EXPECT_NEAR(double (expected), double (actual), double (epsilon))
27
28
28
- CNL_EXPECT_NEAR (std::exp (T{1 }), cnl::math ::e_v<T>, epsilon);
29
- EXPECT_EQ (std::log2 (cnl::math ::e_v<T>), cnl::math ::log2e_v<T>);
30
- CNL_EXPECT_NEAR (std::log10 (cnl::math ::e_v<T>), cnl::math ::log10e_v<T>, epsilon);
31
- CNL_EXPECT_NEAR (std::atan (T{1 })*T{4 }, cnl::math ::pi_v<T>, epsilon);
32
- CNL_EXPECT_NEAR (T{1 }/cnl::math ::pi_v<T>, cnl::math ::inv_pi_v<T>, epsilon);
33
- CNL_EXPECT_NEAR (T{1 }/std::sqrt (cnl::math ::pi_v<T>), cnl::math ::inv_sqrtpi_v<T>, epsilon);
34
- CNL_EXPECT_NEAR (std::log (T{2 }), cnl::math ::ln2_v<T>, epsilon);
35
- CNL_EXPECT_NEAR (std::log (T{10 }), cnl::math ::ln10_v<T>, epsilon);
36
- CNL_EXPECT_NEAR (std::sqrt (T{2 }), cnl::math ::sqrt2_v<T>, epsilon);
37
- CNL_EXPECT_NEAR (std::sqrt (T{3 }), cnl::math ::sqrt3_v<T>, epsilon);
38
- CNL_EXPECT_NEAR (T{1 }/cnl::math ::sqrt3_v<T>, cnl::math ::inv_sqrt3_v<T>, epsilon);
39
- CNL_EXPECT_NEAR (0 .5772156649015328606065120900824024L , cnl::math ::egamma_v<T>, epsilon);
40
- CNL_EXPECT_NEAR (1 .6180339887498948482045868343656381L , cnl::math ::phi_v<T>, epsilon);
29
+ CNL_EXPECT_NEAR (std::exp (T{1 }), cnl::numbers ::e_v<T>, epsilon);
30
+ EXPECT_EQ (std::log2 (cnl::numbers ::e_v<T>), cnl::numbers ::log2e_v<T>);
31
+ CNL_EXPECT_NEAR (std::log10 (cnl::numbers ::e_v<T>), cnl::numbers ::log10e_v<T>, epsilon);
32
+ CNL_EXPECT_NEAR (std::atan (T{1 })*T{4 }, cnl::numbers ::pi_v<T>, epsilon);
33
+ CNL_EXPECT_NEAR (T{1 }/cnl::numbers ::pi_v<T>, cnl::numbers ::inv_pi_v<T>, epsilon);
34
+ CNL_EXPECT_NEAR (T{1 }/std::sqrt (cnl::numbers ::pi_v<T>), cnl::numbers ::inv_sqrtpi_v<T>, epsilon);
35
+ CNL_EXPECT_NEAR (std::log (T{2 }), cnl::numbers ::ln2_v<T>, epsilon);
36
+ CNL_EXPECT_NEAR (std::log (T{10 }), cnl::numbers ::ln10_v<T>, epsilon);
37
+ CNL_EXPECT_NEAR (std::sqrt (T{2 }), cnl::numbers ::sqrt2_v<T>, epsilon);
38
+ CNL_EXPECT_NEAR (std::sqrt (T{3 }), cnl::numbers ::sqrt3_v<T>, epsilon);
39
+ CNL_EXPECT_NEAR (T{1 }/cnl::numbers ::sqrt3_v<T>, cnl::numbers ::inv_sqrt3_v<T>, epsilon);
40
+ CNL_EXPECT_NEAR (0 .5772156649015328606065120900824024L , cnl::numbers ::egamma_v<T>, epsilon);
41
+ CNL_EXPECT_NEAR (1 .6180339887498948482045868343656381L , cnl::numbers ::phi_v<T>, epsilon);
41
42
}
42
43
43
44
TEST (numeric, float_constants) // NOLINT
0 commit comments