Skip to content

Commit 2cc05fa

Browse files
committed
Add B2CConverter version of large buffer test
Test converted by GPT-5.5
1 parent ffed1a2 commit 2cc05fa

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.nio.charset.Charset;
2323
import java.nio.charset.MalformedInputException;
2424
import java.nio.charset.StandardCharsets;
25+
import java.util.Arrays;
2526
import java.util.Locale;
2627

2728
import org.junit.Assert;
@@ -221,6 +222,23 @@ public void testLeftoverBuffer() throws Exception {
221222
}
222223

223224

225+
@Test
226+
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());
239+
}
240+
241+
224242
@Test
225243
public void testLeftoverChunkWithTrailingBytes() throws Exception {
226244
B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);

0 commit comments

Comments
 (0)