(commons-io) branch master updated: Add test for CircularByteBuffer clear() #620

2024-05-08 Thread ggregory
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-io.git


The following commit(s) were added to refs/heads/master by this push:
 new 5d7e64f35 Add test for CircularByteBuffer clear() #620
5d7e64f35 is described below

commit 5d7e64f35f14532cc486c8bd3bfec70d1f6b7267
Author: Gary Gregory 
AuthorDate: Wed May 8 08:22:48 2024 -0400

Add test for CircularByteBuffer clear() #620
---
 src/changes/changes.xml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3dbe91843..193be6015 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -47,6 +47,8 @@ The  type attribute can be add,update,fix,remove.
   
   
 
+   
+  Add 
test for CircularByteBuffer clear() #620.
   
   Add 
missing unit tests.
   FileUtils.lastModifiedFileTime(File) calls 
Objects.requireNonNull() on the wrong object.



(commons-io) branch master updated: Add test for CircularByteBuffer clear() (#620)

2024-05-08 Thread ggregory
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-io.git


The following commit(s) were added to refs/heads/master by this push:
 new bb361e487 Add test for CircularByteBuffer clear() (#620)
bb361e487 is described below

commit bb361e48754f28af34c601fdf82585ece2185e2f
Author: sullis 
AuthorDate: Wed May 8 05:21:29 2024 -0700

Add test for CircularByteBuffer clear() (#620)
---
 .../io/input/buffer/CircularByteBufferTest.java | 21 +
 1 file changed, 21 insertions(+)

diff --git 
a/src/test/java/org/apache/commons/io/input/buffer/CircularByteBufferTest.java 
b/src/test/java/org/apache/commons/io/input/buffer/CircularByteBufferTest.java
index 9d5a230f4..2c3bfe234 100644
--- 
a/src/test/java/org/apache/commons/io/input/buffer/CircularByteBufferTest.java
+++ 
b/src/test/java/org/apache/commons/io/input/buffer/CircularByteBufferTest.java
@@ -19,6 +19,7 @@ package org.apache.commons.io.input.buffer;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import org.junit.jupiter.api.Test;
 
@@ -81,4 +82,24 @@ public class CircularByteBufferTest {
 public void testPeekWithValidArguments() {
 assertFalse(new CircularByteBuffer().peek(new byte[] { 5, 10, 15, 20, 
25 }, 0, 5));
 }
+
+@Test
+public void testClear() {
+   final byte[] data = new byte[] { 1, 2, 3 };
+   final CircularByteBuffer buffer = new CircularByteBuffer(10);
+   assertEquals(0, buffer.getCurrentNumberOfBytes());
+   assertFalse(buffer.hasBytes());
+
+   buffer.add(data, 0, data.length);
+   assertEquals(3, buffer.getCurrentNumberOfBytes());
+   assertEquals(7, buffer.getSpace());
+   assertTrue(buffer.hasBytes());
+   assertTrue(buffer.hasSpace());
+
+   buffer.clear();
+   assertEquals(0, buffer.getCurrentNumberOfBytes());
+   assertEquals(10, buffer.getSpace());
+   assertFalse(buffer.hasBytes());
+   assertTrue(buffer.hasSpace());
+}
 }