Skip to content

Commit

Permalink
Add unittests for CTFE and correct error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
berni44 committed Jan 28, 2021
1 parent d4ab3e3 commit 9cc5185
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -2587,7 +2587,7 @@ private void formatUnsigned(Writer, T, Char)
}

private enum ctfpMessage = "Cannot format all floating point types at compile-time "
~ "(float and double with %a/%A and %e/%E do work)";
~ "(float and double with %a/%A, %e/%E and %f/%F do work)";

private enum RoundingMode { up, down, toZero, toNearestTiesToEven, toNearestTiesAwayFromZero }

Expand Down Expand Up @@ -3049,10 +3049,17 @@ useSnprintf:
static assert(format("%e",-1.234e156) == "-1.234000e+156");
static assert(format("%a",1.0) == "0x1p+0");
static assert(format("%a",-1.234e156) == "-0x1.7024c96ca3ce4p+518");
static assert(format("%f",1.0) == "1.000000");
static assert(format("%f",-1.234e156) ==
"-123399999999999990477495546305353609103201879173427886566531" ~
"0740685826234179310516880117527217443004051984432279880308552" ~
"009640198043032289366552939010719744.000000");
static assert(format("%e",1.0f) == "1.000000e+00");
static assert(format("%e",-1.234e23f) == "-1.234000e+23");
static assert(format("%a",1.0f) == "0x1p+0");
static assert(format("%a",-1.234e23f) == "-0x1.a2187p+76");
static assert(format("%f",1.0f) == "1.000000");
static assert(format("%f",-1.234e23f) == "-123399998884238311030784.000000");
}

/*
Expand Down

0 comments on commit 9cc5185

Please sign in to comment.