File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ public ByteArrayByteBank() {
5858 * @param initialCapacity the initial capacity of this {@link ByteBank}
5959 */
6060 public ByteArrayByteBank (final int initialCapacity ) {
61- this (new ByteArray (initialCapacity ));
61+ this (emptyByteArrayOfCapacity (initialCapacity ));
6262 }
6363
6464 /**
@@ -148,4 +148,10 @@ public long size() {
148148 private void updateSize (final long newSize ) {
149149 size = newSize > size ? newSize : size ;
150150 }
151+
152+ private static ByteArray emptyByteArrayOfCapacity (final int capacity ) {
153+ final ByteArray byteArray = new ByteArray (new byte [capacity ]);
154+ byteArray .setSize (0 );
155+ return byteArray ;
156+ }
151157}
Original file line number Diff line number Diff line change 3232
3333package org .scijava .io ;
3434
35+ import org .junit .Test ;
36+
3537/**
3638 * Tests {@link ByteArrayByteBank}
3739 *
@@ -44,4 +46,10 @@ public class ByteArrayByteBankTest extends ByteBankTest {
4446 public ByteBank createByteBank () {
4547 return new ByteArrayByteBank ();
4648 }
49+
50+ @ Test (expected = ArrayIndexOutOfBoundsException .class )
51+ public void testCreateByteBankWithCapacity () {
52+ ByteArrayByteBank bank = new ByteArrayByteBank (50 );
53+ bank .getByte (0 );
54+ }
4755}
You can’t perform that action at this time.
0 commit comments