Adjust unit test to require __cpp_lib_bit_cast

This commit is contained in:
Mark Santaniello 2022-08-09 11:02:54 -07:00
parent 4a8a038144
commit 003ccb4271
2 changed files with 8 additions and 4 deletions

View File

@ -297,8 +297,6 @@ template <typename To, typename From, FMT_ENABLE_IF(sizeof(To) == sizeof(From))>
FMT_CONSTEXPR20 auto bit_cast(const From& from) -> To {
#ifdef __cpp_lib_bit_cast
if (is_constant_evaluated()) return std::bit_cast<To>(from);
#elif FMT_HAS_BUILTIN(__builtin_bit_cast)
return __builtin_bit_cast(To, from);
#endif
auto to = To();
// The cast suppresses a bogus -Wclass-memaccess on GCC.

View File

@ -228,9 +228,15 @@ TEST(compile_test, format_to_n) {
}
TEST(compile_test, formatted_size) {
FMT_CONSTEXPR20 size_t s1 = fmt::formatted_size(FMT_COMPILE("{0}"), 42);
#ifdef __cpp_lib_bit_cast
FMT_CONSTEXPR20
#endif
size_t s1 = fmt::formatted_size(FMT_COMPILE("{0}"), 42);
EXPECT_EQ(2, s1);
FMT_CONSTEXPR20 size_t s2 = fmt::formatted_size(FMT_COMPILE("{0:<4.2f}"), 42.0);
#ifdef __cpp_lib_bit_cast
FMT_CONSTEXPR20
#endif
size_t s2 = fmt::formatted_size(FMT_COMPILE("{0:<4.2f}"), 42.0);
EXPECT_EQ(5, s2);
}