Loading core/java/android/os/MemoryFile.java +4 −3 Original line number Diff line number Diff line Loading @@ -330,6 +330,7 @@ public class MemoryFile @Override public void write(byte buffer[], int offset, int count) throws IOException { writeBytes(buffer, offset, mOffset, count); mOffset += count; } @Override Loading core/tests/coretests/src/android/os/MemoryFileTest.java +20 −3 Original line number Diff line number Diff line Loading @@ -20,13 +20,11 @@ import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.SmallTest; import java.io.File; import java.io.FileDescriptor; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class MemoryFileTest extends AndroidTestCase { Loading Loading @@ -101,6 +99,25 @@ public class MemoryFileTest extends AndroidTestCase { file.close(); } // http://code.google.com/p/android/issues/detail?id=11415 public void testOutputStreamAdvances() throws IOException { MemoryFile file = new MemoryFile("MemoryFileTest", 10); OutputStream os = file.getOutputStream(); os.write(new byte[] { 1, 2, 3, 4, 5 }); os.write(new byte[] { -1, -1, 6, 7, 8, -1 }, 2, 3); os.write(9); try { os.write(new byte[] { -1, -1 }); fail(); } catch (IndexOutOfBoundsException expected) { } byte[] copy = new byte[file.length()]; file.readBytes(copy, 0, 0, file.length()); assertEquals("[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]", Arrays.toString(copy)); } // Tests for the IndexOutOfBoundsException cases in read(). private void readIndexOutOfBoundsException(int offset, int count, String msg) Loading Loading
core/java/android/os/MemoryFile.java +4 −3 Original line number Diff line number Diff line Loading @@ -330,6 +330,7 @@ public class MemoryFile @Override public void write(byte buffer[], int offset, int count) throws IOException { writeBytes(buffer, offset, mOffset, count); mOffset += count; } @Override Loading
core/tests/coretests/src/android/os/MemoryFileTest.java +20 −3 Original line number Diff line number Diff line Loading @@ -20,13 +20,11 @@ import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.LargeTest; import android.test.suitebuilder.annotation.SmallTest; import java.io.File; import java.io.FileDescriptor; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class MemoryFileTest extends AndroidTestCase { Loading Loading @@ -101,6 +99,25 @@ public class MemoryFileTest extends AndroidTestCase { file.close(); } // http://code.google.com/p/android/issues/detail?id=11415 public void testOutputStreamAdvances() throws IOException { MemoryFile file = new MemoryFile("MemoryFileTest", 10); OutputStream os = file.getOutputStream(); os.write(new byte[] { 1, 2, 3, 4, 5 }); os.write(new byte[] { -1, -1, 6, 7, 8, -1 }, 2, 3); os.write(9); try { os.write(new byte[] { -1, -1 }); fail(); } catch (IndexOutOfBoundsException expected) { } byte[] copy = new byte[file.length()]; file.readBytes(copy, 0, 0, file.length()); assertEquals("[1, 2, 3, 4, 5, 6, 7, 8, 9, 0]", Arrays.toString(copy)); } // Tests for the IndexOutOfBoundsException cases in read(). private void readIndexOutOfBoundsException(int offset, int count, String msg) Loading