20 #include "gtest/gtest.h"
21 #include "absl/base/casts.h"
22 #include "absl/base/macros.h"
33 for (
int i = 0;
i < num_values; ++
i) {
36 T t1 = absl::bit_cast<T>(m0);
51 template <
typename T,
typename I>
53 for (
int i = 0;
i < num_values; ++
i) {
55 I i0 = absl::bit_cast<I>(
t0);
56 T t1 = absl::bit_cast<T>(i0);
57 I i1 = absl::bit_cast<I>(
t1);
64 static const bool bool_list[] = {
false,
true };
69 static const int32_t int_list[] =
70 { 0, 1, 100, 2147483647, -1, -100, -2147483647, -2147483647-1 };
75 static const int64_t int64_list[] =
76 { 0, 1, 1
LL << 40, -1, -(1
LL<<40) };
81 static const uint64_t uint64_list[] =
82 { 0, 1, 1LLU << 40, 1LLU << 63 };
87 static const float float_list[] =
88 { 0.0f, 1.0f, -1.0f, 10.0f, -10.0f,
89 1e10f, 1e20f, 1
e-10f, 1
e-20f,
93 TestIntegral<float, unsigned>(float_list,
ABSL_ARRAYSIZE(float_list));
97 static const double double_list[] =
98 { 0.0, 1.0, -1.0, 10.0, -10.0,
99 1e10, 1e100, 1
e-10, 1
e-100,
101 3.141592653589793238462643383279502884197169399375105820974944 };
103 TestIntegral<double, int64_t>(double_list,
ABSL_ARRAYSIZE(double_list));
104 TestIntegral<double, uint64_t>(double_list,
ABSL_ARRAYSIZE(double_list));