You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2014/11/10 16:29:17 UTC
svn commit: r1637889 -
/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java
Author: ggregory
Date: Mon Nov 10 15:29:17 2014
New Revision: 1637889
URL: http://svn.apache.org/r1637889
Log:
Sort test methods.
Modified:
commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java?rev=1637889&r1=1637888&r2=1637889&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java (original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/HexTest.java Mon Nov 10 15:29:17 2014
@@ -206,13 +206,8 @@ public class HexTest {
}
@Test
- public void testDecodeByteBufferEmpty() throws DecoderException {
- assertTrue(Arrays.equals(new byte[0], new Hex().decode(ByteBuffer.allocate(0))));
- }
-
- @Test
- public void testDecodeCharArrayEmpty() throws DecoderException {
- assertTrue(Arrays.equals(new byte[0], Hex.decodeHex(new char[0])));
+ public void testDecodeByteArrayObjectEmpty() throws DecoderException {
+ assertTrue(Arrays.equals(new byte[0], (byte[]) new Hex().decode((Object) new byte[0])));
}
@Test
@@ -226,6 +221,16 @@ public class HexTest {
}
@Test
+ public void testDecodeByteBufferEmpty() throws DecoderException {
+ assertTrue(Arrays.equals(new byte[0], new Hex().decode(ByteBuffer.allocate(0))));
+ }
+
+ @Test
+ public void testDecodeByteBufferObjectEmpty() throws DecoderException {
+ assertTrue(Arrays.equals(new byte[0], (byte[]) new Hex().decode((Object) ByteBuffer.allocate(0))));
+ }
+
+ @Test
public void testDecodeByteBufferOddCharacters() {
ByteBuffer buffer = ByteBuffer.allocate(1);
buffer.put((byte) 65);
@@ -238,6 +243,11 @@ public class HexTest {
}
@Test
+ public void testDecodeCharArrayEmpty() throws DecoderException {
+ assertTrue(Arrays.equals(new byte[0], Hex.decodeHex(new char[0])));
+ }
+
+ @Test
public void testDecodeClassCastException() {
try {
new Hex().decode(new int[] { 65 });
@@ -278,13 +288,23 @@ public class HexTest {
}
@Test
- public void testDecodeByteArrayObjectEmpty() throws DecoderException {
- assertTrue(Arrays.equals(new byte[0], (byte[]) new Hex().decode((Object) new byte[0])));
+ public void testEncodeByteArrayEmpty() throws EncoderException {
+ assertTrue(Arrays.equals(new byte[0], new Hex().encode(new byte[0])));
}
@Test
- public void testDecodeByteBufferObjectEmpty() throws DecoderException {
- assertTrue(Arrays.equals(new byte[0], (byte[]) new Hex().decode((Object) ByteBuffer.allocate(0))));
+ public void testEncodeByteArrayObjectEmpty() throws EncoderException {
+ assertTrue(Arrays.equals(new char[0], (char[]) new Hex().encode((Object) new byte[0])));
+ }
+
+ @Test
+ public void testEncodeByteBufferEmpty() throws EncoderException {
+ assertTrue(Arrays.equals(new byte[0], new Hex().encode(ByteBuffer.allocate(0))));
+ }
+
+ @Test
+ public void testEncodeByteBufferObjectEmpty() throws EncoderException {
+ assertTrue(Arrays.equals(new char[0], (char[]) new Hex().encode((Object) ByteBuffer.allocate(0))));
}
@Test
@@ -337,12 +357,6 @@ public class HexTest {
}
@Test
- public void testEncodeHexByteBufferEmpty() throws EncoderException {
- assertTrue(Arrays.equals(new char[0], Hex.encodeHex(ByteBuffer.allocate(0))));
- assertTrue(Arrays.equals(new byte[0], new Hex().encode(ByteBuffer.allocate(0))));
- }
-
- @Test
public void testEncodeHexByteArrayHelloWorldLowerCaseHex() {
final byte[] b = StringUtils.getBytesUtf8("Hello World");
final String expected = "48656c6c6f20576f726c64";
@@ -356,29 +370,41 @@ public class HexTest {
}
@Test
- public void testEncodeHexByteBufferHelloWorldLowerCaseHex() {
- final ByteBuffer b = StringUtils.getByteBufferUtf8("Hello World");
- final String expected = "48656c6c6f20576f726c64";
+ public void testEncodeHexByteArrayHelloWorldUpperCaseHex() {
+ final byte[] b = StringUtils.getBytesUtf8("Hello World");
+ final String expected = "48656C6C6F20576F726C64";
char[] actual;
actual = Hex.encodeHex(b);
- assertEquals(expected, new String(actual));
+ assertFalse(expected.equals(new String(actual)));
actual = Hex.encodeHex(b, true);
- assertEquals(expected, new String(actual));
- actual = Hex.encodeHex(b, false);
assertFalse(expected.equals(new String(actual)));
+ actual = Hex.encodeHex(b, false);
+ assertTrue(expected.equals(new String(actual)));
}
@Test
- public void testEncodeHexByteArrayHelloWorldUpperCaseHex() {
- final byte[] b = StringUtils.getBytesUtf8("Hello World");
- final String expected = "48656C6C6F20576F726C64";
+ public void testEncodeHexByteArrayZeroes() {
+ final char[] c = Hex.encodeHex(new byte[36]);
+ assertEquals("000000000000000000000000000000000000000000000000000000000000000000000000", new String(c));
+ }
+
+ @Test
+ public void testEncodeHexByteBufferEmpty() throws EncoderException {
+ assertTrue(Arrays.equals(new char[0], Hex.encodeHex(ByteBuffer.allocate(0))));
+ assertTrue(Arrays.equals(new byte[0], new Hex().encode(ByteBuffer.allocate(0))));
+ }
+
+ @Test
+ public void testEncodeHexByteBufferHelloWorldLowerCaseHex() {
+ final ByteBuffer b = StringUtils.getByteBufferUtf8("Hello World");
+ final String expected = "48656c6c6f20576f726c64";
char[] actual;
actual = Hex.encodeHex(b);
- assertFalse(expected.equals(new String(actual)));
+ assertEquals(expected, new String(actual));
actual = Hex.encodeHex(b, true);
- assertFalse(expected.equals(new String(actual)));
+ assertEquals(expected, new String(actual));
actual = Hex.encodeHex(b, false);
- assertTrue(expected.equals(new String(actual)));
+ assertFalse(expected.equals(new String(actual)));
}
@Test
@@ -395,12 +421,6 @@ public class HexTest {
}
@Test
- public void testEncodeHexByteArrayZeroes() {
- final char[] c = Hex.encodeHex(new byte[36]);
- assertEquals("000000000000000000000000000000000000000000000000000000000000000000000000", new String(c));
- }
-
- @Test
public void testEncodeHexByteBufferZeroes() {
final char[] c = Hex.encodeHex(ByteBuffer.allocate(36));
assertEquals("000000000000000000000000000000000000000000000000000000000000000000000000", new String(c));
@@ -422,26 +442,6 @@ public class HexTest {
}
@Test
- public void testEncodeByteArrayEmpty() throws EncoderException {
- assertTrue(Arrays.equals(new byte[0], new Hex().encode(new byte[0])));
- }
-
- @Test
- public void testEncodeByteArrayObjectEmpty() throws EncoderException {
- assertTrue(Arrays.equals(new char[0], (char[]) new Hex().encode((Object) new byte[0])));
- }
-
- @Test
- public void testEncodeByteBufferEmpty() throws EncoderException {
- assertTrue(Arrays.equals(new byte[0], new Hex().encode(ByteBuffer.allocate(0))));
- }
-
- @Test
- public void testEncodeByteBufferObjectEmpty() throws EncoderException {
- assertTrue(Arrays.equals(new char[0], (char[]) new Hex().encode((Object) ByteBuffer.allocate(0))));
- }
-
- @Test
public void testRequiredCharset() throws UnsupportedEncodingException, DecoderException {
testCustomCharset("UTF-8", "testRequiredCharset");
testCustomCharset("UTF-16", "testRequiredCharset");