mirror of
https://github.com/fmtlib/fmt.git
synced 2024-11-19 20:18:49 +00:00
Make hex float test more stable on different libc (#3762)
Signed-off-by: Vladislav Shchapov <vladislav@shchapov.ru>
This commit is contained in:
parent
9165434e5a
commit
6b07fff0d9
@ -1361,14 +1361,11 @@ TEST(format_test, format_double) {
|
||||
EXPECT_EQ(fmt::format("{0:e}", 392.65), "3.926500e+02");
|
||||
EXPECT_EQ(fmt::format("{0:E}", 392.65), "3.926500E+02");
|
||||
EXPECT_EQ(fmt::format("{0:+010.4g}", 392.65), "+0000392.6");
|
||||
char buffer[buffer_size];
|
||||
|
||||
#if FMT_CPLUSPLUS >= 201703L
|
||||
double xd = 0x1.ffffffffffp+2;
|
||||
safe_sprintf(buffer, "%.*a", 10, xd);
|
||||
EXPECT_EQ(fmt::format("{:.10a}", xd), buffer);
|
||||
safe_sprintf(buffer, "%.*a", 9, xd);
|
||||
EXPECT_EQ(fmt::format("{:.9a}", xd), buffer);
|
||||
EXPECT_EQ(fmt::format("{:.10a}", xd), "0x1.ffffffffffp+2");
|
||||
EXPECT_EQ(fmt::format("{:.9a}", xd), "0x2.000000000p+2");
|
||||
|
||||
if (std::numeric_limits<long double>::digits == 64) {
|
||||
auto ld = 0xf.ffffffffffp-3l;
|
||||
@ -1384,8 +1381,7 @@ TEST(format_test, format_double) {
|
||||
EXPECT_EQ(fmt::format("{:#a}", d), "0x1.p-1022");
|
||||
|
||||
d = (std::numeric_limits<double>::max)();
|
||||
safe_sprintf(buffer, "%a", d);
|
||||
EXPECT_EQ(fmt::format("{:a}", d), buffer);
|
||||
EXPECT_EQ(fmt::format("{:a}", d), "0x1.fffffffffffffp+1023");
|
||||
|
||||
d = std::numeric_limits<double>::denorm_min();
|
||||
EXPECT_EQ(fmt::format("{:a}", d), "0x0.0000000000001p-1022");
|
||||
@ -1402,8 +1398,7 @@ TEST(format_test, format_double) {
|
||||
EXPECT_EQ(fmt::format("{:a}", ld), "0x0.000000000000001p-16382");
|
||||
}
|
||||
|
||||
safe_sprintf(buffer, "%.*a", 10, 4.2);
|
||||
EXPECT_EQ(fmt::format("{:.10a}", 4.2), buffer);
|
||||
EXPECT_EQ(fmt::format("{:.10a}", 4.2), "0x1.0ccccccccdp+2");
|
||||
|
||||
EXPECT_EQ(fmt::format("{:a}", -42.0), "-0x1.5p+5");
|
||||
EXPECT_EQ(fmt::format("{:A}", -42.0), "-0X1.5P+5");
|
||||
|
Loading…
Reference in New Issue
Block a user