77 * http://www.apache.org/licenses/LICENSE-2.0
88 */
99package de .rub .nds .modifiablevariable .util ;
10+
1011import java .math .BigInteger ;
1112import static org .junit .Assert .assertArrayEquals ;
1213import static org .junit .Assert .assertEquals ;
@@ -40,31 +41,32 @@ public void testLongToUint32Bytes() {
4041 public void testIntToBytes () {
4142 int toParse = 5717 ;
4243 byte [] result = ArrayConverter .intToBytes (toParse , 2 );
43- assertArrayEquals ("The conversion result of 5717 should be {0x16} {0x55}" , new byte []{ 0x16 , 0x55 }, result );
44+ assertArrayEquals ("The conversion result of 5717 should be {0x16} {0x55}" , new byte [] { 0x16 , 0x55 }, result );
4445 }
4546
4647 /**
4748 * Test of bytesToInt method, of class ArrayConverter.
4849 */
4950 @ Test
5051 public void testBytesToInt () {
51- byte [] toParse = {0x16 , 0x55 };
52+ byte [] toParse = { 0x16 , 0x55 };
5253 int expectedResult = 5717 ;
53- assertEquals ("The conversion result of {0x16, 0x55} should be 5717" , expectedResult , ArrayConverter .bytesToInt (toParse ));
54+ assertEquals ("The conversion result of {0x16, 0x55} should be 5717" , expectedResult ,
55+ ArrayConverter .bytesToInt (toParse ));
5456 }
5557
5658 /**
5759 * Test of bytesToLong method, of class ArrayConverter.
5860 */
5961 @ Test
6062 public void testBytesToLong () {
61- /** TODO get the casting correct.
62- long result = 571714867398058L;
63- byte[] toParse = {0x02, 0x07, (byte) 0xf8, (byte) 0xbd, (byte) 0x95, (byte) 0x85, (byte) 0xaa};
64- byte[] test = ArrayConverter.longToBytes(result, 7);
65- int a = 0;
66- //assertEquals(result, ArrayConverter.bytesToLong(toParse));
67- */
63+ /**
64+ * TODO get the casting correct. long result = 571714867398058L; byte[]
65+ * toParse = {0x02, 0x07, (byte) 0xf8, (byte) 0xbd, (byte) 0x95, (byte)
66+ * 0x85, ( byte) 0xaa}; byte [] test = ArrayConverter.longToBytes(result,
67+ * 7); int a = 0; //assertEquals(result,
68+ * ArrayConverter.bytesToLong(toParse));
69+ */
6870
6971 }
7072
@@ -73,17 +75,17 @@ public void testBytesToLong() {
7375 */
7476 @ Test
7577 public void testBytesToHexString_byteArr () {
76- byte [] toTest = new byte []{ 0x00 , 0x11 , 0x22 , 0x33 , 0x44 };
78+ byte [] toTest = new byte [] { 0x00 , 0x11 , 0x22 , 0x33 , 0x44 };
7779 assertEquals ("00 11 22 33 44" , ArrayConverter .bytesToHexString (toTest ));
78- toTest = new byte []{ 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 };
80+ toTest = new byte [] { 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 };
7981 assertEquals ("00 01 02 03 04 05 06 07 08" , ArrayConverter .bytesToHexString (toTest ));
80- toTest = new byte []{ 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x10 };
82+ toTest = new byte [] { 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x08 , 0x09 , 0x10 };
8183 assertEquals ("00 01 02 03 04 05 06 07 08 09 10" , ArrayConverter .bytesToHexString (toTest ));
82- toTest = new byte []{ 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 ,
83- 0x07 ,};
84+ toTest = new byte [] { 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 ,
85+ 0x07 , };
8486 assertEquals ("\n 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07" , ArrayConverter .bytesToHexString (toTest ));
85- toTest = new byte []{ 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 ,
86- 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 ,};
87+ toTest = new byte [] { 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 ,
88+ 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , };
8789 assertEquals (
8890 "\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" ,
8991 ArrayConverter .bytesToHexString (toTest ));
@@ -94,11 +96,13 @@ public void testBytesToHexString_byteArr() {
9496 */
9597 @ Test
9698 public void testBytesToHexString_byteArr_boolean () {
97- byte [] toTest = new byte []{0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 ,
98- 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 };
99+ byte [] toTest = new byte [] { 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 ,
100+ 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 ,
101+ 0x06 , 0x07 };
99102 assertEquals ("00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07 00 01 02 03 04 05 06 07" ,
100103 ArrayConverter .bytesToHexString (toTest , false ));
101- assertEquals ("\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" ,
104+ assertEquals (
105+ "\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" ,
102106 ArrayConverter .bytesToHexString (toTest , true ));
103107 }
104108
@@ -108,14 +112,15 @@ public void testBytesToHexString_byteArr_boolean() {
108112 @ Test
109113 public void testBytesToHexString_3args () {
110114 }
111-
115+
112116 /**
113117 * Test ArrayConverter.bytesToRawHexString().
114118 */
115119 @ Test
116120 public void testBytesToRawHexString () {
117- byte [] toTest = new byte []{0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 ,
118- 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 };
121+ byte [] toTest = new byte [] { 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 ,
122+ 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 , 0x06 , 0x07 , 0x00 , 0x01 , 0x02 , 0x03 , 0x04 , 0x05 ,
123+ 0x06 , 0x07 };
119124 assertEquals ("0001020304050607000102030405060700010203040506070001020304050607" ,
120125 ArrayConverter .bytesToRawHexString (toTest ));
121126 }
@@ -168,13 +173,13 @@ public void testConvertListToArray() {
168173 @ Test
169174 public void testHexStringToByteArray () {
170175 String hex = "01" ;
171- assertArrayEquals ("Testing simple one byte hex value" , new byte []{ 0x01 },
176+ assertArrayEquals ("Testing simple one byte hex value" , new byte [] { 0x01 },
172177 ArrayConverter .hexStringToByteArray (hex ));
173178 hex = "FF" ;
174- assertArrayEquals ("Testing one byte hex value > 0x7f" , new byte []{ (byte ) 0xff },
179+ assertArrayEquals ("Testing one byte hex value > 0x7f" , new byte [] { (byte ) 0xff },
175180 ArrayConverter .hexStringToByteArray (hex ));
176181 hex = "FFFFFF" ;
177- assertArrayEquals ("Testing one byte hex value > 0x7f" , new byte []{ (byte ) 0xff , (byte ) 0xff , (byte ) 0xff },
182+ assertArrayEquals ("Testing one byte hex value > 0x7f" , new byte [] { (byte ) 0xff , (byte ) 0xff , (byte ) 0xff },
178183 ArrayConverter .hexStringToByteArray (hex ));
179184 }
180185
@@ -184,7 +189,7 @@ public void testBigIntegerToNullPaddedByteArray() {
184189
185190 assertArrayEquals ("Check zero output size" , new byte [0 ],
186191 ArrayConverter .bigIntegerToNullPaddedByteArray (test , 0 ));
187- assertArrayEquals ("Check check output size smaller than input" , new byte []{ (byte ) 0xEC },
192+ assertArrayEquals ("Check check output size smaller than input" , new byte [] { (byte ) 0xEC },
188193 ArrayConverter .bigIntegerToNullPaddedByteArray (test , 1 ));
189194 assertArrayEquals ("Check output size bigger than input size" ,
190195 ArrayConverter .hexStringToByteArray ("0000000000000000000000001D42C86F7923DFEC" ),
0 commit comments