[Issue 21703] New: std.base64 : decoding a range with one element does not work properly

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 12 20:09:51 UTC 2021


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

          Issue ID: 21703
           Summary: std.base64 : decoding a range with one element does
                    not work properly
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: bugzilla at bernis-buecher.de

unittest
{
    struct InputRange
    {
        ubyte[] impl = [ 'e', 'a', '=', '=' ];
        bool empty() { return impl.length == 0; }
        ubyte front() { return impl[0]; }
        void popFront() { impl = impl[1 .. $]; }
        size_t length() { return impl.length; }
    }

    struct OutputRange
    {
        ubyte[] result;
        void put(ubyte b) { result ~= b; }
    }

    InputRange ir;
    OutputRange or;

    assert(Base64.decode(ir, or) == 1);
    assert(or.result == "x"); // fails, output is "y"
}

--


More information about the Digitalmars-d-bugs mailing list