This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new d599fe2d5a Expand test to cover range of input sizes
d599fe2d5a is described below
commit d599fe2d5ab517988b48ca13f8e20ff1f669f171
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 c826aef1fc..38a6bf0c2b 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());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]