@@ -48,7 +48,7 @@ public void testCopyChannel() throws IOException {
4848
4949 ReadableByteChannel inChannel = Channels .newChannel (new ByteArrayInputStream (expected ));
5050 ByteStreams .copy (inChannel , outChannel );
51- assertEquals ( expected , out .toByteArray ());
51+ assertThat ( out .toByteArray ()). isEqualTo ( expected );
5252 }
5353
5454 public void testCopyFileChannel () throws IOException {
@@ -68,7 +68,7 @@ public void testCopyFileChannel() throws IOException {
6868 }
6969 byte [] actual = out .toByteArray ();
7070 for (int i = 0 ; i < 500 * chunkSize ; i += chunkSize ) {
71- assertEquals ( dummyData , Arrays .copyOfRange (actual , i , i + chunkSize ));
71+ assertThat ( Arrays .copyOfRange (actual , i , i + chunkSize )). isEqualTo ( dummyData );
7272 }
7373 }
7474
@@ -119,15 +119,15 @@ public void testReadFully() throws IOException {
119119
120120 Arrays .fill (b , (byte ) 0 );
121121 ByteStreams .readFully (newTestStream (10 ), b , 0 , 0 );
122- assertEquals ( new byte [10 ], b );
122+ assertThat ( b ). isEqualTo ( new byte [10 ]);
123123
124124 Arrays .fill (b , (byte ) 0 );
125125 ByteStreams .readFully (newTestStream (10 ), b , 0 , 10 );
126- assertEquals ( newPreFilledByteArray (10 ), b );
126+ assertThat ( b ). isEqualTo ( newPreFilledByteArray (10 ));
127127
128128 Arrays .fill (b , (byte ) 0 );
129129 ByteStreams .readFully (newTestStream (10 ), b , 0 , 5 );
130- assertEquals ( new byte [] {0 , 1 , 2 , 3 , 4 , 0 , 0 , 0 , 0 , 0 }, b );
130+ assertThat ( b ). isEqualTo ( new byte [] {0 , 1 , 2 , 3 , 4 , 0 , 0 , 0 , 0 , 0 });
131131 }
132132
133133 public void testSkipFully () throws IOException {
@@ -177,7 +177,7 @@ public void testNewDataInput_readFully() {
177177 ByteArrayDataInput in = ByteStreams .newDataInput (bytes );
178178 byte [] actual = new byte [bytes .length ];
179179 in .readFully (actual );
180- assertEquals ( bytes , actual );
180+ assertThat ( actual ). isEqualTo ( bytes );
181181 }
182182
183183 public void testNewDataInput_readFullyAndThenSome () {
@@ -317,54 +317,54 @@ public void testNewDataOutput_writeInt() {
317317 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
318318 out .writeInt (0x12345678 );
319319 out .writeInt (0x76543210 );
320- assertEquals ( bytes , out .toByteArray ());
320+ assertThat ( out .toByteArray ()). isEqualTo ( bytes );
321321 }
322322
323323 public void testNewDataOutput_sized () {
324324 ByteArrayDataOutput out = ByteStreams .newDataOutput (4 );
325325 out .writeInt (0x12345678 );
326326 out .writeInt (0x76543210 );
327- assertEquals ( bytes , out .toByteArray ());
327+ assertThat ( out .toByteArray ()). isEqualTo ( bytes );
328328 }
329329
330330 public void testNewDataOutput_writeLong () {
331331 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
332332 out .writeLong (0x1234567876543210L );
333- assertEquals ( bytes , out .toByteArray ());
333+ assertThat ( out .toByteArray ()). isEqualTo ( bytes );
334334 }
335335
336336 public void testNewDataOutput_writeByteArray () {
337337 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
338338 out .write (bytes );
339- assertEquals ( bytes , out .toByteArray ());
339+ assertThat ( out .toByteArray ()). isEqualTo ( bytes );
340340 }
341341
342342 public void testNewDataOutput_writeByte () {
343343 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
344344 out .write (0x12 );
345345 out .writeByte (0x34 );
346- assertEquals ( new byte [] {0x12 , 0x34 }, out . toByteArray () );
346+ assertThat ( out . toByteArray ()). isEqualTo ( new byte [] {0x12 , 0x34 });
347347 }
348348
349349 public void testNewDataOutput_writeByteOffset () {
350350 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
351351 out .write (bytes , 4 , 2 );
352352 byte [] expected = {bytes [4 ], bytes [5 ]};
353- assertEquals ( expected , out .toByteArray ());
353+ assertThat ( out .toByteArray ()). isEqualTo ( expected );
354354 }
355355
356356 public void testNewDataOutput_writeBoolean () {
357357 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
358358 out .writeBoolean (true );
359359 out .writeBoolean (false );
360360 byte [] expected = {(byte ) 1 , (byte ) 0 };
361- assertEquals ( expected , out .toByteArray ());
361+ assertThat ( out .toByteArray ()). isEqualTo ( expected );
362362 }
363363
364364 public void testNewDataOutput_writeChar () {
365365 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
366366 out .writeChar ('a' );
367- assertEquals ( new byte [] {0 , 97 }, out . toByteArray () );
367+ assertThat ( out . toByteArray ()). isEqualTo ( new byte [] {0 , 97 });
368368 }
369369
370370 // Hardcoded because of Android problems. See testUtf16Expected.
@@ -376,14 +376,14 @@ public void testNewDataOutput_writeChars() {
376376 out .writeChars ("r\u00C9 sum\u00C9 " );
377377 // need to remove byte order mark before comparing
378378 byte [] expected = Arrays .copyOfRange (utf16ExpectedWithBom , 2 , 14 );
379- assertEquals ( expected , out .toByteArray ());
379+ assertThat ( out .toByteArray ()). isEqualTo ( expected );
380380 }
381381
382382 @ AndroidIncompatible // https://code.google.com/p/android/issues/detail?id=196848
383383 public void testUtf16Expected () {
384384 byte [] hardcodedExpected = utf16ExpectedWithBom ;
385385 byte [] computedExpected = "r\u00C9 sum\u00C9 " .getBytes (Charsets .UTF_16 );
386- assertEquals ( hardcodedExpected , computedExpected );
386+ assertThat ( computedExpected ). isEqualTo ( hardcodedExpected );
387387 }
388388
389389 public void testNewDataOutput_writeUTF () {
@@ -394,93 +394,93 @@ public void testNewDataOutput_writeUTF() {
394394 // writeUTF writes the length of the string in 2 bytes
395395 assertEquals (0 , actual [0 ]);
396396 assertEquals (expected .length , actual [1 ]);
397- assertEquals ( expected , Arrays .copyOfRange (actual , 2 , actual .length ));
397+ assertThat ( Arrays .copyOfRange (actual , 2 , actual .length )). isEqualTo ( expected );
398398 }
399399
400400 public void testNewDataOutput_writeShort () {
401401 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
402402 out .writeShort (0x1234 );
403- assertEquals ( new byte [] {0x12 , 0x34 }, out . toByteArray () );
403+ assertThat ( out . toByteArray ()). isEqualTo ( new byte [] {0x12 , 0x34 });
404404 }
405405
406406 public void testNewDataOutput_writeDouble () {
407407 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
408408 out .writeDouble (Double .longBitsToDouble (0x1234567876543210L ));
409- assertEquals ( bytes , out .toByteArray ());
409+ assertThat ( out .toByteArray ()). isEqualTo ( bytes );
410410 }
411411
412412 public void testNewDataOutput_writeFloat () {
413413 ByteArrayDataOutput out = ByteStreams .newDataOutput ();
414414 out .writeFloat (Float .intBitsToFloat (0x12345678 ));
415415 out .writeFloat (Float .intBitsToFloat (0x76543210 ));
416- assertEquals ( bytes , out .toByteArray ());
416+ assertThat ( out .toByteArray ()). isEqualTo ( bytes );
417417 }
418418
419419 public void testNewDataOutput_BAOS () {
420420 ByteArrayOutputStream baos = new ByteArrayOutputStream ();
421421 ByteArrayDataOutput out = ByteStreams .newDataOutput (baos );
422422 out .writeInt (0x12345678 );
423423 assertEquals (4 , baos .size ());
424- assertEquals ( new byte [] {0x12 , 0x34 , 0x56 , 0x78 }, baos . toByteArray () );
424+ assertThat ( baos . toByteArray ()). isEqualTo ( new byte [] {0x12 , 0x34 , 0x56 , 0x78 });
425425 }
426426
427427 private static final byte [] PRE_FILLED_100 = newPreFilledByteArray (100 );
428428
429429 public void testToByteArray () throws IOException {
430430 InputStream in = new ByteArrayInputStream (PRE_FILLED_100 );
431431 byte [] b = ByteStreams .toByteArray (in );
432- assertEquals ( PRE_FILLED_100 , b );
432+ assertThat ( b ). isEqualTo ( PRE_FILLED_100 );
433433 }
434434
435435 public void testToByteArray_emptyStream () throws IOException {
436436 InputStream in = newTestStream (0 );
437437 byte [] b = ByteStreams .toByteArray (in );
438- assertEquals ( new byte [0 ], b );
438+ assertThat ( b ). isEqualTo ( new byte [0 ]);
439439 }
440440
441441 public void testToByteArray_largeStream () throws IOException {
442442 // well, large enough to require multiple buffers
443443 byte [] expected = newPreFilledByteArray (10000000 );
444444 InputStream in = new ByteArrayInputStream (expected );
445445 byte [] b = ByteStreams .toByteArray (in );
446- assertEquals ( expected , b );
446+ assertThat ( b ). isEqualTo ( expected );
447447 }
448448
449449 public void testToByteArray_withSize_givenCorrectSize () throws IOException {
450450 InputStream in = new ByteArrayInputStream (PRE_FILLED_100 );
451451 byte [] b = ByteStreams .toByteArray (in , 100 );
452- assertEquals ( PRE_FILLED_100 , b );
452+ assertThat ( b ). isEqualTo ( PRE_FILLED_100 );
453453 }
454454
455455 public void testToByteArray_withSize_givenSmallerSize () throws IOException {
456456 InputStream in = new ByteArrayInputStream (PRE_FILLED_100 );
457457 byte [] b = ByteStreams .toByteArray (in , 80 );
458- assertEquals ( PRE_FILLED_100 , b );
458+ assertThat ( b ). isEqualTo ( PRE_FILLED_100 );
459459 }
460460
461461 public void testToByteArray_withSize_givenLargerSize () throws IOException {
462462 InputStream in = new ByteArrayInputStream (PRE_FILLED_100 );
463463 byte [] b = ByteStreams .toByteArray (in , 120 );
464- assertEquals ( PRE_FILLED_100 , b );
464+ assertThat ( b ). isEqualTo ( PRE_FILLED_100 );
465465 }
466466
467467 public void testToByteArray_withSize_givenSizeZero () throws IOException {
468468 InputStream in = new ByteArrayInputStream (PRE_FILLED_100 );
469469 byte [] b = ByteStreams .toByteArray (in , 0 );
470- assertEquals ( PRE_FILLED_100 , b );
470+ assertThat ( b ). isEqualTo ( PRE_FILLED_100 );
471471 }
472472
473473 public void testToByteArray_withSize_givenSizeOneSmallerThanActual () throws IOException {
474474 InputStream in = new ByteArrayInputStream (PRE_FILLED_100 );
475475 // this results in toByteArrayInternal being called when the stream is actually exhausted
476476 byte [] b = ByteStreams .toByteArray (in , 99 );
477- assertEquals ( PRE_FILLED_100 , b );
477+ assertThat ( b ). isEqualTo ( PRE_FILLED_100 );
478478 }
479479
480480 public void testToByteArray_withSize_givenSizeTwoSmallerThanActual () throws IOException {
481481 InputStream in = new ByteArrayInputStream (PRE_FILLED_100 );
482482 byte [] b = ByteStreams .toByteArray (in , 98 );
483- assertEquals ( PRE_FILLED_100 , b );
483+ assertThat ( b ). isEqualTo ( PRE_FILLED_100 );
484484 }
485485
486486 public void testExhaust () throws IOException {
@@ -515,8 +515,8 @@ public long skip(long n) throws IOException {
515515
516516 public void testReadBytes () throws IOException {
517517 final byte [] array = newPreFilledByteArray (1000 );
518- assertEquals (
519- array , ByteStreams . readBytes ( new ByteArrayInputStream ( array ), new TestByteProcessor ()) );
518+ assertThat ( ByteStreams . readBytes ( new ByteArrayInputStream ( array ), new TestByteProcessor ()))
519+ . isEqualTo ( array );
520520 }
521521
522522 private static class TestByteProcessor implements ByteProcessor <byte []> {
@@ -543,7 +543,8 @@ public void testByteProcessorStopEarly() throws IOException {
543543 new ByteProcessor <Integer >() {
544544 @ Override
545545 public boolean processBytes (byte [] buf , int off , int len ) {
546- assertEquals (Arrays .copyOfRange (buf , off , off + len ), newPreFilledByteArray (8192 ));
546+ assertThat (newPreFilledByteArray (8192 ))
547+ .isEqualTo (Arrays .copyOfRange (buf , off , off + len ));
547548 return false ;
548549 }
549550
@@ -670,9 +671,4 @@ public boolean markSupported() {
670671 return false ;
671672 }
672673 }
673-
674- // TODO(cpovirk): Inline this.
675- private static void assertEquals (byte [] expected , byte [] actual ) {
676- assertThat (actual ).isEqualTo (expected );
677- }
678674}
0 commit comments