www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21703] New: std.base64 : decoding a range with one element

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 puremagic.com
          Reporter: bugzilla 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"
}

--
Mar 12