Skip to content

Commit d599fe2

Browse files
committed
Expand test to cover range of input sizes
1 parent 2cc05fa commit d599fe2

1 file changed

Lines changed: 15 additions & 12 deletions

File tree

test/org/apache/tomcat/util/buf/TestB2CConverter.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,21 @@ public void testLeftoverBuffer() throws Exception {
224224

225225
@Test
226226
public void testOverflowWithLargeReadBuffer() throws Exception {
227-
B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);
228-
byte[] bytes = new byte[10500];
229-
Arrays.fill(bytes, (byte) '0');
230-
ByteBuffer bb = ByteBuffer.wrap(bytes);
231-
CharBuffer cb = newCharBuffer(InputBuffer.DEFAULT_BUFFER_SIZE);
232-
TesterInputBuffer ib = new TesterInputBuffer(bb);
233-
234-
conv.convert(bb, cb, ib, false);
235-
236-
Assert.assertEquals(InputBuffer.DEFAULT_BUFFER_SIZE, cb.remaining());
237-
Assert.assertEquals(InputBuffer.DEFAULT_BUFFER_SIZE, bb.position());
238-
Assert.assertEquals(bytes.length - InputBuffer.DEFAULT_BUFFER_SIZE, bb.remaining());
227+
// Test range of input sizes from default (8kB) to 12kB.
228+
for (int i = 0; i < 4096; i++) {
229+
B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);
230+
byte[] bytes = new byte[8192 + i];
231+
Arrays.fill(bytes, (byte) '0');
232+
ByteBuffer bb = ByteBuffer.wrap(bytes);
233+
CharBuffer cb = newCharBuffer(InputBuffer.DEFAULT_BUFFER_SIZE);
234+
TesterInputBuffer ib = new TesterInputBuffer(bb);
235+
236+
conv.convert(bb, cb, ib, false);
237+
238+
Assert.assertEquals(InputBuffer.DEFAULT_BUFFER_SIZE, cb.remaining());
239+
Assert.assertEquals(InputBuffer.DEFAULT_BUFFER_SIZE, bb.position());
240+
Assert.assertEquals(bytes.length - InputBuffer.DEFAULT_BUFFER_SIZE, bb.remaining());
241+
}
239242
}
240243

241244

0 commit comments

Comments
 (0)