2626 * @author Juraj Somorovsky <juraj.somorovsky@rub.de>
2727 */
2828public class ModifiableByteArrayTest {
29+
2930 private static final Logger LOGGER = LogManager .getLogger (ModifiableByteArray .class );
3031
3132 private ModifiableByteArray start ;
@@ -38,10 +39,10 @@ public class ModifiableByteArrayTest {
3839
3940 @ Before
4041 public void setUp () {
41- originalValue = new byte [] { (byte ) 0 , (byte ) 1 , (byte ) 2 , (byte ) 3 , (byte ) 4 , (byte ) 5 , (byte ) 6 };
42- modification1 = new byte [] { (byte ) 2 , (byte ) 3 };
43- modification2 = new byte [] { (byte ) 2 , (byte ) 1 , (byte ) 0 , (byte ) 1 , (byte ) 2 , (byte ) 3 , (byte ) 4 , (byte ) 5 ,
44- (byte ) 6 };
42+ originalValue = new byte []{ (byte ) 0 , (byte ) 1 , (byte ) 2 , (byte ) 3 , (byte ) 4 , (byte ) 5 , (byte ) 6 };
43+ modification1 = new byte []{ (byte ) 2 , (byte ) 3 };
44+ modification2 = new byte []{ (byte ) 2 , (byte ) 1 , (byte ) 0 , (byte ) 1 , (byte ) 2 , (byte ) 3 , (byte ) 4 , (byte ) 5 ,
45+ (byte ) 6 };
4546 start = new ModifiableByteArray ();
4647 start .setOriginalValue (originalValue );
4748 }
@@ -361,13 +362,13 @@ public void testInsertBytes() {
361362 @ Test
362363 public void testIsOriginalValueModified () {
363364 assertFalse (start .isOriginalValueModified ());
364- VariableModification <byte []> modifier = ByteArrayModificationFactory .xor (new byte [] {}, 0 );
365+ VariableModification <byte []> modifier = ByteArrayModificationFactory .xor (new byte []{}, 0 );
365366 start .setModification (modifier );
366367 assertFalse (start .isOriginalValueModified ());
367- modifier = ByteArrayModificationFactory .xor (new byte [] { 1 }, 0 );
368+ modifier = ByteArrayModificationFactory .xor (new byte []{ 1 }, 0 );
368369 start .setModification (modifier );
369370 assertTrue (start .isOriginalValueModified ());
370- modifier = ByteArrayModificationFactory .xor (new byte [] { 0 , 0 }, originalValue .length - 2 );
371+ modifier = ByteArrayModificationFactory .xor (new byte []{ 0 , 0 }, originalValue .length - 2 );
371372 start .setModification (modifier );
372373 assertFalse (start .isOriginalValueModified ());
373374 }
@@ -398,13 +399,13 @@ public void testExplicitValueFromFile() {
398399
399400 modifier = ByteArrayModificationFactory .explicitValueFromFile (1 );
400401 start .setModification (modifier );
401- expectedResult = new byte [] { 00 };
402+ expectedResult = new byte []{ 00 };
402403 result = start .getValue ();
403404 assertArrayEquals (expectedResult , result );
404405
405406 modifier = ByteArrayModificationFactory .explicitValueFromFile (17 );
406407 start .setModification (modifier );
407- expectedResult = new byte [] { (byte ) 255 };
408+ expectedResult = new byte []{ (byte ) 255 };
408409 result = start .getValue ();
409410 assertArrayEquals (expectedResult , result );
410411 }
@@ -415,42 +416,30 @@ public void testExplicitValueFromFile() {
415416 @ Test
416417 public void testShuffle () {
417418 LOGGER .info ("testShuffle" );
418- VariableModification <byte []> modifier = ByteArrayModificationFactory .shuffle (new byte [] { 0 , 1 });
419+ VariableModification <byte []> modifier = ByteArrayModificationFactory .shuffle (new byte []{ 0 , 1 });
419420 start .setModification (modifier );
420- byte [] result = { 1 , 0 , 2 , 3 , 4 , 5 , 6 };
421+ byte [] result = {1 , 0 , 2 , 3 , 4 , 5 , 6 };
421422 assertArrayEquals (result , start .getValue ());
422423
423- modifier = ByteArrayModificationFactory .shuffle (new byte [] { 0 , 1 , 2 , 3 , 4 , 5 , 6 });
424+ modifier = ByteArrayModificationFactory .shuffle (new byte []{ 0 , 1 , 2 , 3 , 4 , 5 , 6 });
424425 start .setModification (modifier );
425- result = new byte [] { 1 , 0 , 3 , 2 , 5 , 4 , 6 };
426+ result = new byte []{ 1 , 0 , 3 , 2 , 5 , 4 , 6 };
426427 assertArrayEquals (result , start .getValue ());
427428
428- modifier = ByteArrayModificationFactory .shuffle (new byte [] { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 });
429+ modifier = ByteArrayModificationFactory .shuffle (new byte []{ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 });
429430 start .setModification (modifier );
430- result = new byte [] { 6 , 0 , 3 , 2 , 5 , 4 , 1 };
431+ result = new byte []{ 6 , 0 , 3 , 2 , 5 , 4 , 1 };
431432 assertArrayEquals (result , start .getValue ());
432433 }
433-
434+
434435 @ Test
435436 public void toStringTest () {
436- ModifiableByteArray toTest = new ModifiableByteArray ();
437+ ModifiableByteArray toTest = new ModifiableByteArray ();
437438 toTest = ModifiableVariableFactory .safelySetValue (toTest , new byte []{0x00 , 0x11 , 0x22 , 0x33 , 0x44 });
438- assertEquals ("00 11 22 33 44" , toTest .toString ());
439-
440- toTest = ModifiableVariableFactory .safelySetValue (toTest , new byte []{0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 });
441- assertEquals ("00 01 02 03 04 05 06 07 08" , toTest .toString ());
442-
443- toTest = ModifiableVariableFactory .safelySetValue (toTest , new byte []{0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x10 });
444- assertEquals ("00 01 02 03 04 05 06 07 08 09 10" , toTest .toString ());
445-
446- toTest = ModifiableVariableFactory .safelySetValue (toTest , new byte []{0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 ,
447- 0x07 ,});
448- assertEquals ("\n 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07" , toTest .toString ());
439+ assertEquals ("Original byte value is: 00 11 22 33 44" , toTest .toString ());
449440
450- toTest = ModifiableVariableFactory .safelySetValue (toTest , new byte []{0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 ,
451- 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 ,});
452- assertEquals (
453- "\n 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07\n 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07" ,
454- toTest .toString ());
441+ VariableModification modificatoin = new ByteArrayExplicitValueModification (new byte []{0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 });
442+ toTest .setModification (modificatoin );
443+ assertEquals ("Actual byte value is: 00 01 02 03 04 05 06 07 08\n Original value was: 00 11 22 33 44" , toTest .toString ());
455444 }
456445}
0 commit comments