Workaround hexfloat inconsistency on windows (#2205)

This commit is contained in:
Victor Zverovich 2021-04-07 11:20:08 -07:00
parent 78776ee4e2
commit 5a8bf1f6a3

View File

@ -46,6 +46,7 @@ using fmt::wmemory_buffer;
using fmt::wstring_view;
using fmt::detail::max_value;
using testing::Contains;
using testing::Return;
using testing::StrictMock;
@ -224,7 +225,8 @@ TEST(BufferAppenderTest, BufferAppenderDefaultConstruct) {
static_assert(
std::is_default_constructible<
std::back_insert_iterator<fmt::detail::buffer<char>>>::value ==
std::is_default_constructible<fmt::detail::buffer_appender<char>>::value,
std::is_default_constructible<
fmt::detail::buffer_appender<char>>::value,
"");
}
@ -994,7 +996,8 @@ TEST(FormatterTest, Precision) {
"012970999954193198940908041656332452475714786901472678015935523861155013"
"480352649347201937902681071074917033322268447533357208324319361e-324",
format("{:.494}", 4.9406564584124654E-324));
EXPECT_EQ(
std::string outputs[] = {
"-0X1.41FE3FFE71C9E000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
@ -1007,7 +1010,20 @@ TEST(FormatterTest, Precision) {
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000P+127",
format("{:.838A}", -2.14001164E+38));
"-0XA.0FF1FFF38E4F0000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000P+124"};
EXPECT_THAT(outputs, Contains(format("{:.838A}", -2.14001164E+38)));
EXPECT_EQ("123.", format("{:#.0f}", 123.0));
EXPECT_EQ("1.23", format("{:.02f}", 1.234));
EXPECT_EQ("0.001", format("{:.1g}", 0.001));