@@ -259,8 +259,6 @@ public synchronized void close() throws IOException {
259259 new ByteArrayInputStream ("ABC" .getBytes (StandardCharsets .UTF_8 ))));
260260 assertFalse (IOUtils .contentEquals (new ByteArrayInputStream ("ABC" .getBytes (StandardCharsets .UTF_8 )),
261261 new ByteArrayInputStream ("ABCD" .getBytes (StandardCharsets .UTF_8 ))));
262- assertFalse (IOUtils .contentEquals (new ByteArrayInputStream ("apache" .getBytes (StandardCharsets .UTF_8 )),
263- new ByteArrayInputStream ("apacha" .getBytes (StandardCharsets .UTF_8 ))));
264262 }
265263
266264 @ Test public void testContentEquals_Reader_Reader () throws Exception {
@@ -289,7 +287,6 @@ public synchronized void close() throws IOException {
289287 assertTrue (IOUtils .contentEquals (new StringReader ("ABC" ), new StringReader ("ABC" )));
290288 assertFalse (IOUtils .contentEquals (new StringReader ("ABCD" ), new StringReader ("ABC" )));
291289 assertFalse (IOUtils .contentEquals (new StringReader ("ABC" ), new StringReader ("ABCD" )));
292- assertFalse (IOUtils .contentEquals (new StringReader ("apache" ), new StringReader ("apacha" )));
293290 }
294291
295292 @ Test public void testContentEqualsIgnoreEOL () throws Exception {
@@ -314,38 +311,28 @@ public synchronized void close() throws IOException {
314311 assertTrue (IOUtils .contentEqualsIgnoreEOL (input1 , input1 ));
315312 }
316313
317- testSingleEOL ("" , "" , true );
318- testSingleEOL ("" , "\n " , true );
319- testSingleEOL ("" , "\r " , true );
320- testSingleEOL ("" , "\r \n " , true );
321- testSingleEOL ("" , "\r \r " , false );
322- testSingleEOL ("" , "\n \n " , false );
323- testSingleEOL ("1" , "1" , true );
324- testSingleEOL ("1" , "2" , false );
325- testSingleEOL ("123\r abc" , "123\n abc" , true );
326- testSingleEOL ("321" , "321\r \n " , true );
327- testSingleEOL ("321" , "321\r \n aabb" , false );
328- testSingleEOL ("321" , "321\n " , true );
329- testSingleEOL ("321" , "321\r " , true );
330- testSingleEOL ("321" , "321\r \n " , true );
331- testSingleEOL ("321" , "321\r \r " , false );
332- testSingleEOL ("321" , "321\n \r " , false );
333- testSingleEOL ("321\n " , "321" , true );
334- testSingleEOL ("321\n " , "321\n \r " , false );
335- testSingleEOL ("321\n " , "321\r \n " , true );
336- testSingleEOL ("321\r " , "321\r \n " , true );
337- testSingleEOL ("321\r \n " , "321\r \n \r " , false );
338- testSingleEOL ("123" , "1234" , false );
339- }
340-
341- public void testSingleEOL (String s1 , String s2 , boolean ifEquals ) throws IOException {
342- assertEquals (ifEquals , IOUtils .contentEqualsIgnoreEOL (new CharArrayReader (s1 .toCharArray ()),
343- new CharArrayReader (s2 .toCharArray ())), "failed at :{" + s1 + "," + s2 + "}" );
344- assertEquals (ifEquals , IOUtils .contentEqualsIgnoreEOL (new CharArrayReader (s2 .toCharArray ()),
345- new CharArrayReader (s1 .toCharArray ())), "failed at :{" + s2 + "," + s1 + "}" );
346- assertTrue (IOUtils .contentEqualsIgnoreEOL (new CharArrayReader (s1 .toCharArray ()),
347- new CharArrayReader (s1 .toCharArray ())), "failed at :{" + s1 + "," + s1 + "}" );
348- assertTrue (IOUtils .contentEqualsIgnoreEOL (new CharArrayReader (s2 .toCharArray ()), new CharArrayReader (s2 .toCharArray ())), "failed at :{" + s2 + "," + s2 + "}" );
314+ Reader r1 ;
315+ Reader r2 ;
316+
317+ r1 = new CharArrayReader ("" .toCharArray ());
318+ r2 = new CharArrayReader ("" .toCharArray ());
319+ assertTrue (IOUtils .contentEqualsIgnoreEOL (r1 , r2 ));
320+
321+ r1 = new CharArrayReader ("1" .toCharArray ());
322+ r2 = new CharArrayReader ("1" .toCharArray ());
323+ assertTrue (IOUtils .contentEqualsIgnoreEOL (r1 , r2 ));
324+
325+ r1 = new CharArrayReader ("1" .toCharArray ());
326+ r2 = new CharArrayReader ("2" .toCharArray ());
327+ assertFalse (IOUtils .contentEqualsIgnoreEOL (r1 , r2 ));
328+
329+ r1 = new CharArrayReader ("123\r abc" .toCharArray ());
330+ r2 = new CharArrayReader ("123\n abc" .toCharArray ());
331+ assertTrue (IOUtils .contentEqualsIgnoreEOL (r1 , r2 ));
332+
333+ r1 = new CharArrayReader ("321" .toCharArray ());
334+ r2 = new CharArrayReader ("321\r \n " .toCharArray ());
335+ assertTrue (IOUtils .contentEqualsIgnoreEOL (r1 , r2 ));
349336 }
350337
351338 @ Test public void testCopy_ByteArray_OutputStream () throws Exception {
0 commit comments