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 2bd243b Tests with larger inputs that DEFAULT_BUFFER_SIZE in case internal buffers are used. 2bd243b is described below commit 2bd243b35d05bdd9a84be2c021180df95c4f9c3a Author: Gary Gregory <gardgreg...@gmail.com> AuthorDate: Sun Jan 24 11:38:29 2021 -0500 Tests with larger inputs that DEFAULT_BUFFER_SIZE in case internal buffers are used. --- src/test/java/org/apache/commons/io/IOUtilsTestCase.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java index 2ab18c5..9f7de4f 100644 --- a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java +++ b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java @@ -536,6 +536,20 @@ public class IOUtilsTestCase { new ByteArrayInputStream("ABC".getBytes(StandardCharsets.UTF_8)))); assertFalse(IOUtils.contentEquals(new ByteArrayInputStream("ABC".getBytes(StandardCharsets.UTF_8)), new ByteArrayInputStream("ABCD".getBytes(StandardCharsets.UTF_8)))); + // Tests with larger inputs that DEFAULT_BUFFER_SIZE in case internal buffers are used. + final byte[] bytes2XDefaultA = new byte[IOUtils.DEFAULT_BUFFER_SIZE * 2]; + final byte[] bytes2XDefaultB = new byte[IOUtils.DEFAULT_BUFFER_SIZE * 2]; + final byte[] bytes2XDefaultA2 = new byte[IOUtils.DEFAULT_BUFFER_SIZE * 2]; + Arrays.fill(bytes2XDefaultA, (byte) 'a'); + Arrays.fill(bytes2XDefaultB, (byte) 'b'); + Arrays.fill(bytes2XDefaultA2, (byte) 'a'); + bytes2XDefaultA2[bytes2XDefaultA2.length - 1] = 'd'; + assertFalse(IOUtils.contentEquals(new ByteArrayInputStream(bytes2XDefaultA), + new ByteArrayInputStream(bytes2XDefaultB))); + assertFalse(IOUtils.contentEquals(new ByteArrayInputStream(bytes2XDefaultA), + new ByteArrayInputStream(bytes2XDefaultA2))); + assertTrue(IOUtils.contentEquals(new ByteArrayInputStream(bytes2XDefaultA), + new ByteArrayInputStream(bytes2XDefaultA))); } @Test