This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new e2c7b16bf Add more assertions to
SeekableInMemoryByteChannelTest.testThrowWhenSettingIncorrectPosition()
e2c7b16bf is described below
commit e2c7b16bfbba02591bf099b4d4026dbfdcbf0c1f
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Dec 8 13:39:01 2025 -0500
Add more assertions to
SeekableInMemoryByteChannelTest.testThrowWhenSettingIncorrectPosition()
---
.../commons/compress/utils/SeekableInMemoryByteChannelTest.java | 6 ++++++
1 file changed, 6 insertions(+)
diff --git
a/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java
b/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java
index e3d4f9aa2..d5f4d2762 100644
---
a/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java
+++
b/src/test/java/org/apache/commons/compress/utils/SeekableInMemoryByteChannelTest.java
@@ -220,13 +220,19 @@ void
testThrowsIOExceptionWhenPositionIsSetToANegativeValue() throws Exception {
void testThrowWhenSettingIncorrectPosition() throws IOException {
try (SeekableInMemoryByteChannel c = new
SeekableInMemoryByteChannel()) {
final ByteBuffer buffer = ByteBuffer.allocate(1);
+ // write
+ c.write(buffer);
+ assertEquals(1, c.position());
+ // bad pos A
c.position(c.size() + 1);
assertEquals(c.size() + 1, c.position());
assertEquals(-1, c.read(buffer));
+ // bad pos B
c.position(Integer.MAX_VALUE + 1L);
assertEquals(Integer.MAX_VALUE + 1L, c.position());
assertEquals(-1, c.read(buffer));
assertThrows(IOException.class, () -> c.write(buffer));
+ // negative input is the only illegal input
assertThrows(IllegalArgumentException.class, () -> c.position(-1));
assertThrows(IllegalArgumentException.class, () ->
c.position(Integer.MIN_VALUE));
assertThrows(IllegalArgumentException.class, () ->
c.position(Long.MIN_VALUE));