Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eaa2cabf authored by Jesse Wilson's avatar Jesse Wilson Committed by Android (Google) Code Review
Browse files

Merge "Fix problem where Base64InputStream single-byte reads were unsigned." into gingerbread

parents 32371695 64b25cf7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -112,7 +112,7 @@ public class Base64InputStream extends FilterInputStream {
        if (outputStart >= outputEnd) {
            return -1;
        } else {
            return coder.output[outputStart++];
            return coder.output[outputStart++] & 0xff;
        }
    }

+11 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package android.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import junit.framework.TestCase;

import java.io.ByteArrayInputStream;
@@ -404,6 +407,14 @@ public class Base64Test extends TestCase {
        }
    }

    /** http://b/3026478 */
    public void testSingleByteReads() throws IOException {
        InputStream in = new Base64InputStream(
                new ByteArrayInputStream("/v8=".getBytes()), Base64.DEFAULT);
        assertEquals(254, in.read());
        assertEquals(255, in.read());
    }

    /**
     * Tests that Base64OutputStream produces exactly the same results
     * as calling Base64.encode/.decode on an in-memory array.