(tomcat) branch 10.1.x updated: Expand test to cover range of input sizes

[email protected]
Newsgroups gmane.comp.jakarta.tomcat.devel
Message-ID <178289964285.3834340.8532224749897981857@gitbox3-he-fi.apache.org>
This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new da3bf6113b Expand test to cover range of input sizes
da3bf6113b is described below

commit da3bf6113b6b8053ebfb9102f068a48e70b278ac
Author: Mark Thomas <[email protected]>
AuthorDate: Wed Jul 1 10:52:09 2026 +0100

    Expand test to cover range of input sizes
---
 .../apache/tomcat/util/buf/TestB2CConverter.java   | 27 ++++++++++++----------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/test/org/apache/tomcat/util/buf/TestB2CConverter.java b/test/org/apache/tomcat/util/buf/TestB2CConverter.java
index e5edf0bf2d..0d77079dd5 100644
--- a/test/org/apache/tomcat/util/buf/TestB2CConverter.java
+++ b/test/org/apache/tomcat/util/buf/TestB2CConverter.java
@@ -224,18 +224,21 @@ public class TestB2CConverter {
 
     @Test
     public void testOverflowWithLargeReadBuffer() throws Exception {
-        B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);
-        byte[] bytes = new byte[10500];
-        Arrays.fill(bytes, (byte) '0');
-        ByteBuffer bb = ByteBuffer.wrap(bytes);
-        CharBuffer cb = newCharBuffer(InputBuffer.DEFAULT_BUFFER_SIZE);
-        TesterInputBuffer ib = new TesterInputBuffer(bb);
-
-        conv.convert(bb, cb, ib, false);
-
-        Assert.assertEquals(InputBuffer.DEFAULT_BUFFER_SIZE, cb.remaining());
-        Assert.assertEquals(InputBuffer.DEFAULT_BUFFER_SIZE, bb.position());
-        Assert.assertEquals(bytes.length - InputBuffer.DEFAULT_BUFFER_SIZE, bb.remaining());
+        // Test range of input sizes from default (8kB) to 12kB.
+        for (int i = 0; i < 4096; i++) {
+            B2CConverter conv = new B2CConverter(StandardCharsets.UTF_8);
+            byte[] bytes = new byte[8192 + i];
+            Arrays.fill(bytes, (byte) '0');
+            ByteBuffer bb = ByteBuffer.wrap(bytes);
+            CharBuffer cb = newCharBuffer(InputBuffer.DEFAULT_BUFFER_SIZE);
+            TesterInputBuffer ib = new TesterInputBuffer(bb);
+
+            conv.convert(bb, cb, ib, false);
+
+            Assert.assertEquals(InputBuffer.DEFAULT_BUFFER_SIZE, cb.remaining());
+            Assert.assertEquals(InputBuffer.DEFAULT_BUFFER_SIZE, bb.position());
+            Assert.assertEquals(bytes.length - InputBuffer.DEFAULT_BUFFER_SIZE, bb.remaining());
+        }
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.