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

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

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


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

commit 4636a45fce21d2be38d65f366eed817f806d50fa
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 65504e86c1..22461a106a 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.