File tree Expand file tree Collapse file tree
src/test/java/org/apache/commons/io Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -536,6 +536,20 @@ public void testContentEquals_InputStream_InputStream() throws Exception {
536536 new ByteArrayInputStream ("ABC" .getBytes (StandardCharsets .UTF_8 ))));
537537 assertFalse (IOUtils .contentEquals (new ByteArrayInputStream ("ABC" .getBytes (StandardCharsets .UTF_8 )),
538538 new ByteArrayInputStream ("ABCD" .getBytes (StandardCharsets .UTF_8 ))));
539+ // Tests with larger inputs that DEFAULT_BUFFER_SIZE in case internal buffers are used.
540+ final byte [] bytes2XDefaultA = new byte [IOUtils .DEFAULT_BUFFER_SIZE * 2 ];
541+ final byte [] bytes2XDefaultB = new byte [IOUtils .DEFAULT_BUFFER_SIZE * 2 ];
542+ final byte [] bytes2XDefaultA2 = new byte [IOUtils .DEFAULT_BUFFER_SIZE * 2 ];
543+ Arrays .fill (bytes2XDefaultA , (byte ) 'a' );
544+ Arrays .fill (bytes2XDefaultB , (byte ) 'b' );
545+ Arrays .fill (bytes2XDefaultA2 , (byte ) 'a' );
546+ bytes2XDefaultA2 [bytes2XDefaultA2 .length - 1 ] = 'd' ;
547+ assertFalse (IOUtils .contentEquals (new ByteArrayInputStream (bytes2XDefaultA ),
548+ new ByteArrayInputStream (bytes2XDefaultB )));
549+ assertFalse (IOUtils .contentEquals (new ByteArrayInputStream (bytes2XDefaultA ),
550+ new ByteArrayInputStream (bytes2XDefaultA2 )));
551+ assertTrue (IOUtils .contentEquals (new ByteArrayInputStream (bytes2XDefaultA ),
552+ new ByteArrayInputStream (bytes2XDefaultA )));
539553 }
540554
541555 @ Test
You can’t perform that action at this time.
0 commit comments