@@ -178,30 +178,36 @@ public void testCustomCharsetToString() {
178178 }
179179
180180 @ Test
181- public void testDecodeByteArrayOddCharacters () {
181+ public void testDecodeBadCharacterPos0 () {
182182 try {
183- new Hex ().decode (new byte []{ 65 } );
184- fail ("An exception wasn't thrown when trying to decode an odd number of characters " );
183+ new Hex ().decode ("q0" );
184+ fail ("An exception wasn't thrown when trying to decode an illegal character " );
185185 } catch (final DecoderException e ) {
186186 // Expected exception
187187 }
188188 }
189189
190190 @ Test
191- public void testDecodeBadCharacterPos0 () {
191+ public void testDecodeBadCharacterPos1 () {
192192 try {
193- new Hex ().decode ("q0 " );
193+ new Hex ().decode ("0q " );
194194 fail ("An exception wasn't thrown when trying to decode an illegal character" );
195195 } catch (final DecoderException e ) {
196196 // Expected exception
197197 }
198198 }
199199
200200 @ Test
201- public void testDecodeBadCharacterPos1 () {
201+ public void testDecodeByteArrayEmpty () throws DecoderException {
202+ assertTrue (Arrays .equals (new byte [0 ], Hex .decodeHex (new char [0 ])));
203+ assertTrue (Arrays .equals (new byte [0 ], new Hex ().decode (new byte [0 ])));
204+ }
205+
206+ @ Test
207+ public void testDecodeByteArrayOddCharacters () {
202208 try {
203- new Hex ().decode ("0q" );
204- fail ("An exception wasn't thrown when trying to decode an illegal character " );
209+ new Hex ().decode (new byte []{ 65 } );
210+ fail ("An exception wasn't thrown when trying to decode an odd number of characters " );
205211 } catch (final DecoderException e ) {
206212 // Expected exception
207213 }
@@ -242,12 +248,6 @@ public void testDecodeHexStringOddCharacters() {
242248 }
243249 }
244250
245- @ Test
246- public void testDecodeByteArrayEmpty () throws DecoderException {
247- assertTrue (Arrays .equals (new byte [0 ], Hex .decodeHex (new char [0 ])));
248- assertTrue (Arrays .equals (new byte [0 ], new Hex ().decode (new byte [0 ])));
249- }
250-
251251 @ Test
252252 public void testDecodeStringEmpty () throws DecoderException {
253253 assertTrue (Arrays .equals (new byte [0 ], (byte []) new Hex ().decode ("" )));
@@ -302,17 +302,6 @@ public void testEncodeHexByteArrayEmpty() throws EncoderException {
302302 assertTrue (Arrays .equals (new byte [0 ], new Hex ().encode (new byte [0 ])));
303303 }
304304
305- @ Test
306- public void testEncodeStringEmpty () throws EncoderException {
307- assertTrue (Arrays .equals (new char [0 ], (char []) new Hex ().encode ("" )));
308- }
309-
310- @ Test
311- public void testEncodeHexByteArrayZeroes () {
312- final char [] c = Hex .encodeHex (new byte [36 ]);
313- assertEquals ("000000000000000000000000000000000000000000000000000000000000000000000000" , new String (c ));
314- }
315-
316305 @ Test
317306 public void testEncodeHexByteArrayHelloWorldLowerCaseHex () {
318307 final byte [] b = StringUtils .getBytesUtf8 ("Hello World" );
@@ -339,6 +328,17 @@ public void testEncodeHexByteArrayHelloWorldUpperCaseHex() {
339328 assertTrue (expected .equals (new String (actual )));
340329 }
341330
331+ @ Test
332+ public void testEncodeHexByteArrayZeroes () {
333+ final char [] c = Hex .encodeHex (new byte [36 ]);
334+ assertEquals ("000000000000000000000000000000000000000000000000000000000000000000000000" , new String (c ));
335+ }
336+
337+ @ Test
338+ public void testEncodeStringEmpty () throws EncoderException {
339+ assertTrue (Arrays .equals (new char [0 ], (char []) new Hex ().encode ("" )));
340+ }
341+
342342 @ Test
343343 public void testRequiredCharset () throws UnsupportedEncodingException , DecoderException {
344344 testCustomCharset ("UTF-8" , "testRequiredCharset" );
0 commit comments