Skip to content

Commit

Permalink
Workaround hexfloat inconsistency on windows (#2205)
Browse files Browse the repository at this point in the history
  • Loading branch information
vitaut committed Apr 7, 2021
1 parent 78776ee commit 5a8bf1f
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions test/format-test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
"");
}

Expand Down Expand Up @@ -994,7 +996,8 @@ TEST(FormatterTest, Precision) {
"012970999954193198940908041656332452475714786901472678015935523861155013"
"480352649347201937902681071074917033322268447533357208324319361e-324",
format("{:.494}", 4.9406564584124654E-324));
EXPECT_EQ(

std::string outputs[] = {
"-0X1.41FE3FFE71C9E000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
"000000000000000000000000000000000000000000000000000000000000000000000000"
Expand All @@ -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));
Expand Down

0 comments on commit 5a8bf1f

Please sign in to comment.