www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21777] New: std.format: several issues when formatting

https://issues.dlang.org/show_bug.cgi?id=21777

          Issue ID: 21777
           Summary: std.format: several issues when formatting integers
                    with precision
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: bugzilla bernis-buecher.de

All of the following tests fail:

unittest
{
    assert(format!"%20.5,d"(cast(short) 120) == "              00,120"); //
comma missing
    assert(format!"%20.5,o"(cast(short) 120) == "              00,170"); //
comma missing
    assert(format!"%20.5,x"(cast(short) 120) == "              00,078"); // one
space too much
    assert(format!"%20.5,2d"(cast(short) 120) == "             0,01,20"); //
one space too much
    assert(format!"%20.5,2o"(cast(short) 120) == "             0,01,70"); //
one space too much
    assert(format!"%20.5,4d"(cast(short) 120) == "              0,0120"); //
comma missing
    assert(format!"%20.5,4o"(cast(short) 120) == "              0,0170"); //
comma missing
    assert(format!"%20.5,4x"(cast(short) 120) == "              0,0170"); //
comma missing
    assert(format!"%20.5,2x"(3000) == "             0,0b,b8"); // one space too
much
    assert(format!"%20.5,4d"(3000) == "              0,3000"); // comma missing
    assert(format!"%20.5,4o"(3000) == "              0,5670"); // comma missing
    assert(format!"%20.5,4x"(3000) == "              0,0bb8"); // comma missing
    assert(format!"%20.5,d"(-400) == "             -0,0400"); // one space too
much
    assert(format!"%20.30d"(-400) == "-00000000000000000000000000400"); // one
zero too much
}

--
Mar 28