From 342a9184a9e11878e0117ffc5dc1946af3516d98 Mon Sep 17 00:00:00 2001 From: Joerg Schaible Date: Thu, 27 Sep 2012 21:08:54 +0000 Subject: [PATCH] JUnit 3 --> JUnit 4 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@1391222 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/commons/lang3/Conversion.java | 2 +- .../apache/commons/lang3/ConversionTest.java | 733 +++++++++--------- 2 files changed, 366 insertions(+), 369 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/Conversion.java b/src/main/java/org/apache/commons/lang3/Conversion.java index 5ebd8cd31..3620be1d1 100644 --- a/src/main/java/org/apache/commons/lang3/Conversion.java +++ b/src/main/java/org/apache/commons/lang3/Conversion.java @@ -455,7 +455,7 @@ public class Conversion { /** *

- * Converta a part of a boolean array in big endian Msb0 bit ordering to a hexadecimal + * Converts a part of a boolean array in big endian Msb0 bit ordering to a hexadecimal * digit. *

*

diff --git a/src/test/java/org/apache/commons/lang3/ConversionTest.java b/src/test/java/org/apache/commons/lang3/ConversionTest.java index 7a16f95e5..0db80fd9c 100644 --- a/src/test/java/org/apache/commons/lang3/ConversionTest.java +++ b/src/test/java/org/apache/commons/lang3/ConversionTest.java @@ -19,12 +19,11 @@ package org.apache.commons.lang3; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.fail; import java.lang.Throwable; -import java.lang.reflect.Method; -import org.junit.Assert; import org.junit.Test; @@ -33,33 +32,13 @@ import org.junit.Test; * * @version $Id$ */ - public class ConversionTest { - private static void assertArrayEquals(boolean[] expected, boolean[] actual) { - assertEquals(expected.length, actual.length); - for (int i = 0; i < expected.length; i++ ) { - try { - assertEquals(expected[i], actual[i]); - } catch (Throwable e) { - String msg = "Mismatch at index " - + i - + " between:\n" - + dbgPrint(expected) - + " and\n" - + dbgPrint(actual); - fail(msg + "\n" + e.getMessage()); - } - } - } - /** - * convert an hexadecimal digit into an int using the default (Lsb0) bit ordering. - *

- * '1' is converted to 1 + * Tests {@link Conversion#hexDigitToInt(char)}. */ @Test - public void testHexDigitToInt() throws Exception { + public void testHexDigitToInt() { assertEquals(0, Conversion.hexDigitToInt('0')); assertEquals(1, Conversion.hexDigitToInt('1')); assertEquals(2, Conversion.hexDigitToInt('2')); @@ -85,13 +64,10 @@ public class ConversionTest { } /** - * convert an hexadecimal digit into an int using the Msb0 bit ordering. - *

- * '1' is converted to 8 - * + * Tests {@link Conversion#hexDigitM0ToInt(char)}. */ @Test - public void testHexDigitM0ToInt() throws Exception { + public void testHexDigitM0ToInt() { assertEquals(0x0, Conversion.hexDigitM0ToInt('0')); assertEquals(0x8, Conversion.hexDigitM0ToInt('1')); assertEquals(0x4, Conversion.hexDigitM0ToInt('2')); @@ -117,114 +93,112 @@ public class ConversionTest { } /** - * convert an hexadecimal digit into binary using the default (Lsb0) bit ordering. - *

- * '1' is converted as follow: (1, 0, 0, 0) - * + * Tests {@link Conversion#hexDigitToBools(char)}. */ @Test - public void testHexDigitToBools() throws Exception { - assertArrayEquals( + public void testHexDigitToBools() { + assertBoolArrayEquals( new boolean[]{false, false, false, false}, Conversion.hexDigitToBools('0')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, false, false}, Conversion.hexDigitToBools('1')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, true, false, false}, Conversion.hexDigitToBools('2')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, false, false}, Conversion.hexDigitToBools('3')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, false, true, false}, Conversion.hexDigitToBools('4')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, true, false}, Conversion.hexDigitToBools('5')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, true, true, false}, Conversion.hexDigitToBools('6')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, true, false}, Conversion.hexDigitToBools('7')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, false, false, true}, Conversion.hexDigitToBools('8')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, false, true}, Conversion.hexDigitToBools('9')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, true, false, true}, Conversion.hexDigitToBools('A')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, true, false, true}, Conversion.hexDigitToBools('a')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, false, true}, Conversion.hexDigitToBools('B')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, false, true}, Conversion.hexDigitToBools('b')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, false, true, true}, Conversion.hexDigitToBools('C')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, false, true, true}, Conversion.hexDigitToBools('c')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, true, true}, Conversion.hexDigitToBools('D')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, true, true}, Conversion.hexDigitToBools('d')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, true, true, true}, Conversion.hexDigitToBools('E')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, true, true, true}, Conversion.hexDigitToBools('e')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, true, true}, Conversion.hexDigitToBools('F')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, true, true}, Conversion.hexDigitToBools('f')); } + /** + * Tests {@link Conversion#hexDigitM0ToBools(char)}. + */ @Test - public void testHexDigitM0ToBools() throws Exception { - assertArrayEquals( + public void testHexDigitM0ToBools() { + assertBoolArrayEquals( new boolean[]{false, false, false, false}, Conversion.hexDigitM0ToBools('0')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, false, false, true}, Conversion.hexDigitM0ToBools('1')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, false, true, false}, Conversion.hexDigitM0ToBools('2')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, false, true, true}, Conversion.hexDigitM0ToBools('3')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, true, false, false}, Conversion.hexDigitM0ToBools('4')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, true, false, true}, Conversion.hexDigitM0ToBools('5')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, true, true, false}, Conversion.hexDigitM0ToBools('6')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{false, true, true, true}, Conversion.hexDigitM0ToBools('7')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, false, false}, Conversion.hexDigitM0ToBools('8')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, false, true}, Conversion.hexDigitM0ToBools('9')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, true, false}, Conversion.hexDigitM0ToBools('A')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, true, false}, Conversion.hexDigitM0ToBools('a')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, true, true}, Conversion.hexDigitM0ToBools('B')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, false, true, true}, Conversion.hexDigitM0ToBools('b')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, false, false}, Conversion.hexDigitM0ToBools('C')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, false, false}, Conversion.hexDigitM0ToBools('c')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, false, true}, Conversion.hexDigitM0ToBools('D')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, false, true}, Conversion.hexDigitM0ToBools('d')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, true, false}, Conversion.hexDigitM0ToBools('E')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, true, false}, Conversion.hexDigitM0ToBools('e')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, true, true}, Conversion.hexDigitM0ToBools('F')); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{true, true, true, true}, Conversion.hexDigitM0ToBools('f')); } /** - * Convert a boolean array to an hexadecimal digit using the default (Lsb0) bit ordering. - *

- * (1, 0, 0, 0) is converted as follow: '1' + * Tests {@link Conversion#boolsToHexDigit(boolean[])}. */ @Test - public void testBoolsToHexDigit() throws Exception { + public void testBoolsToHexDigit() { assertEquals('0', Conversion.boolsToHexDigit(new boolean[]{false, false, false, false})); assertEquals('1', Conversion.boolsToHexDigit(new boolean[]{true, false, false, false})); assertEquals('2', Conversion.boolsToHexDigit(new boolean[]{false, true, false, false})); @@ -244,13 +218,10 @@ public class ConversionTest { } /** - * Convert a boolean array to an hexadecimal digit using the default (Lsb0) bit ordering. - *

- * (1, 0, 0, 0) is converted as follow: '1' - * + * Tests {@link Conversion#boolsBeM0ToHexDigit(boolean[], int)}. */ @Test - public void testBoolsToHexDigit_2args() throws Exception { + public void testBoolsToHexDigit_2args() { boolean[] shortArray = new boolean[]{false, true, true}; assertEquals('6', Conversion.boolsToHexDigit(shortArray, 0)); assertEquals('3', Conversion.boolsToHexDigit(shortArray, 1)); @@ -266,13 +237,10 @@ public class ConversionTest { } /** - * Convert a boolean array to an hexadecimal digit using the Msb0 bit ordering. - *

- * (1, 0, 0, 0) is converted as follow: '8' - * + * Tests {@link Conversion#boolsToHexDigitM0_4bits(boolean[])}. */ @Test - public void testBoolsToHexDigitM0_bits() throws Exception { + public void testBoolsToHexDigitM0_bits() { assertEquals( '0', Conversion.boolsToHexDigitM0_4bits(new boolean[]{false, false, false, false})); assertEquals( @@ -308,14 +276,10 @@ public class ConversionTest { } /** - * Convert a boolean array to an hexadecimal digit using the Msb0 bit ordering. - *

- * (1, 0, 0, 0) is converted as follow: '8' (1,0,0,1,1,0,1,0) with srcPos = 3 is converted - * to 'D' - * + * Tests {@link Conversion#boolsToHexDigitM0_4bits(boolean[], int)}. */ @Test - public void testBoolsToHexDigitM0_4bits_2args() throws Exception { + public void testBoolsToHexDigitM0_4bits_2args() { // boolean[] shortArray = new boolean[]{true,true,false}; // assertEquals('6', Conversion.boolsToHexDigitM0(shortArray,0)); // assertEquals('3', Conversion.boolsToHexDigitM0(shortArray,1)); @@ -347,14 +311,10 @@ public class ConversionTest { } /** - * Convert the first 4 bits of a boolean array in big endian Msb0 bit ordering to an - * hexadecimal digit. - *

- * (1, 0, 0, 0) is converted as follow: '8' (1,0,0,0,0,0,0,0, 0,0,0,0,0,1,0,0) is converted - * to '4' + * Tests {@link Conversion#boolsToHexDigit(boolean[])}. */ @Test - public void testBoolsBeM0ToHexDigit() throws Exception { + public void testBoolsBeM0ToHexDigit() { assertEquals( '0', Conversion.boolsBeM0ToHexDigit(new boolean[]{false, false, false, false})); assertEquals( @@ -394,14 +354,10 @@ public class ConversionTest { } /** - * Convert a part of a boolean array in big endian Msb0 bit ordering to an hexadecimal - * digit. - *

- * (1, 0, 0, 0) with srcPos = 0 is converted as follow: '8' (1,0,0,0,0,0,0,0, - * 0,0,0,1,0,1,0,0) with srcPos = 2 is converted to '5' + * Tests {@link Conversion#boolsToHexDigit(boolean[], int)}. */ @Test - public void testBoolsBeM0ToHexDigit_2args() throws Exception { + public void testBoolsBeM0ToHexDigit_2args() { assertEquals( '5', Conversion.boolsBeM0ToHexDigit(new boolean[]{ @@ -445,16 +401,10 @@ public class ConversionTest { } /** - * Convert the 4 lsb of an int to an hexadecimal digit. - *

- * 0 returns '0' - *

- * 1 returns '1' - *

- * 10 returns 'A' and so on... + * Tests {@link Conversion#intToHexDigit(int)}. */ @Test - public void testIntToHexDigit() throws Exception { + public void testIntToHexDigit() { assertEquals('0', Conversion.intToHexDigit(0)); assertEquals('1', Conversion.intToHexDigit(1)); assertEquals('2', Conversion.intToHexDigit(2)); @@ -474,16 +424,10 @@ public class ConversionTest { } /** - * Convert the 4 lsb of an int to an hexadecimal digit encoded using the Msb0 bit ordering. - *

- * 0 returns '0' - *

- * 1 returns '8' - *

- * 10 returns '5' and so on... + * Tests {@link Conversion#intToHexDigitM0(int)}. */ @Test - public void testIntToHexDigitM0() throws Exception { + public void testIntToHexDigitM0() { assertEquals('0', Conversion.intToHexDigitM0(0)); assertEquals('8', Conversion.intToHexDigitM0(1)); assertEquals('4', Conversion.intToHexDigitM0(2)); @@ -502,7 +446,7 @@ public class ConversionTest { assertEquals('F', Conversion.intToHexDigitM0(15)); } - private static String dbgPrint(boolean[] src) { + static String dbgPrint(boolean[] src) { StringBuilder sb = new StringBuilder(); for (boolean e : src) { if (e) sb.append("1,"); @@ -512,8 +456,29 @@ public class ConversionTest { return out.substring(0, out.length() - 1); } + // org.junit.Assert(boolean[], boolean[]) does not exist in JUnit 4.2 + static void assertBoolArrayEquals(boolean[] expected, boolean[] actual) { + assertEquals(expected.length, actual.length); + for (int i = 0; i < expected.length; i++ ) { + try { + assertEquals(expected[i], actual[i]); + } catch (Throwable e) { + String msg = "Mismatch at index " + + i + + " between:\n" + + dbgPrint(expected) + + " and\n" + + dbgPrint(actual); + fail(msg + "\n" + e.getMessage()); + } + } + } + + /** + * Tests {@link Conversion#intsToLong(int[], int, long, int, int)}. + */ @Test - public void testIntsToLong() throws Exception { + public void testIntsToLong() { int[] src = new int[]{0xCDF1F0C1, 0x0F123456, 0x78000000}; assertEquals(0x0000000000000000L, Conversion.intsToLong(src, 0, 0L, 0, 0)); assertEquals(0x0000000000000000L, Conversion.intsToLong(src, 1, 0L, 0, 0)); @@ -527,14 +492,16 @@ public class ConversionTest { // assertEquals(0x0F12345678000000L,Conversion.intsToLong(src,1,0x123456789ABCDEF0L,32,2)); } - @Test - public void testShortsToLong() throws Exception { + public void todoTestShortsToLong() { // TODO: implement this test. This is somehow low priority since intsToLong and // bytesToLong are tested } + /** + * Tests {@link Conversion#bytesToLong(byte[], int, long, int, int)}. + */ @Test - public void testBytesToLong() throws Exception { + public void testBytesToLong() { byte[] src = new byte[]{ (byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34, (byte)0x56, (byte)0x78}; @@ -549,8 +516,11 @@ public class ConversionTest { // assertEquals(0x123456789A7856F0L,Conversion.bytesToLong(src,7,0x123456789ABCDEF0L,8,2)); } + /** + * Tests {@link Conversion#shortsToInt(short[], int, int, int, int)}. + */ @Test - public void testShortsToInt() throws Exception { + public void testShortsToInt() { short[] src = new short[]{ (short)0xCDF1, (short)0xF0C1, (short)0x0F12, (short)0x3456, (short)0x7800}; assertEquals(0x00000000, Conversion.shortsToInt(src, 0, 0, 0, 0)); @@ -563,8 +533,11 @@ public class ConversionTest { } + /** + * Tests {@link Conversion#bytesToInt(byte[], int, int, int, int)}. + */ @Test - public void testBytesToInt() throws Exception { + public void testBytesToInt() { byte[] src = new byte[]{ (byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34, (byte)0x56, (byte)0x78}; @@ -577,8 +550,11 @@ public class ConversionTest { // assertEquals(0x56341278,Conversion.bytesToInt(src, 5, 0x01234567, 8, 4)); } + /** + * Tests {@link Conversion#bytesToShort(byte[], int, short, int, int)}. + */ @Test - public void testBytesToShort() throws Exception { + public void testBytesToShort() { byte[] src = new byte[]{ (byte)0xCD, (byte)0xF1, (byte)0xF0, (byte)0xC1, (byte)0x0F, (byte)0x12, (byte)0x34, (byte)0x56, (byte)0x78}; @@ -591,8 +567,11 @@ public class ConversionTest { // assertEquals((short)0x5678,Conversion.bytesToShort(src, 7, (short) 0x0123, 8, 2)); } + /** + * Tests {@link Conversion#hexsToLong(String, int, long, int, int)}. + */ @Test - public void testHexsToLong() throws Exception { + public void testHexsToLong() { String src = "CDF1F0C10F12345678"; assertEquals(0x0000000000000000L, Conversion.hexsToLong(src, 0, 0L, 0, 0)); assertEquals(0x000000000000000CL, Conversion.hexsToLong(src, 0, 0L, 0, 1)); @@ -604,8 +583,11 @@ public class ConversionTest { 0x1234567876BCDEF0L, Conversion.hexsToLong(src, 15, 0x123456798ABCDEF0L, 24, 3)); } + /** + * Tests {@link Conversion#hexsToInt(String, int, int, int, int)}. + */ @Test - public void testHexsToInt() throws Exception { + public void testHexsToInt() { String src = "CDF1F0C10F12345678"; assertEquals(0x00000000, Conversion.hexsToInt(src, 0, 0, 0, 0)); assertEquals(0x0000000C, Conversion.hexsToInt(src, 0, 0, 0, 1)); @@ -615,8 +597,11 @@ public class ConversionTest { assertEquals(0x87645679, Conversion.hexsToInt(src, 15, 0x12345679, 20, 3)); } + /** + * Tests {@link Conversion#hexsToShort(String, int, short, int, int)}. + */ @Test - public void testHexsToShort() throws Exception { + public void testHexsToShort() { String src = "CDF1F0C10F12345678"; assertEquals((short)0x0000, Conversion.hexsToShort(src, 0, (short)0, 0, 0)); assertEquals((short)0x000C, Conversion.hexsToShort(src, 0, (short)0, 0, 1)); @@ -626,8 +611,11 @@ public class ConversionTest { assertEquals((short)0x8764, Conversion.hexsToShort(src, 15, (short)0x1234, 4, 3)); } + /** + * Tests {@link Conversion#hexsToByte(String, int, byte, int, int)}. + */ @Test - public void testHexsToByte() throws Exception { + public void testHexsToByte() { String src = "CDF1F0C10F12345678"; assertEquals((byte)0x00, Conversion.hexsToByte(src, 0, (byte)0, 0, 0)); assertEquals((byte)0x0C, Conversion.hexsToByte(src, 0, (byte)0, 0, 1)); @@ -637,18 +625,19 @@ public class ConversionTest { assertEquals((byte)0x84, Conversion.hexsToByte(src, 17, (byte)0x34, 4, 1)); } + /** + * Tests {@link Conversion#boolsToLong(boolean[], int, long, int, int)}. + */ @Test - public void testBoolsToLong() throws Exception { + public void testBoolsToLong() { boolean[] src = new boolean[]{ false, false, true, true, true, false, true, true, true, true, true, true, true, false, false, false, true, true, true, true, false, false, false, false, false, false, true, true, true, false, false, false, false, false, false, false, true, true, true, true, true, false, false, false, false, true, false, false, true, true, false, false, false, false, true, false, true, false, true, false, false, true, - true, false, true, true, true, false, false, false, false, true};// conversion of - // "CDF1F0C10F12345678" - // by hexsToBools - + true, false, true, true, true, false, false, false, false, true}; + // conversion of "CDF1F0C10F12345678" by hexsToBools assertEquals(0x0000000000000000L, Conversion.boolsToLong(src, 0, 0L, 0, 0)); assertEquals(0x000000000000000CL, Conversion.boolsToLong(src, 0, 0L, 0, 1 * 4)); assertEquals(0x000000001C0F1FDCL, Conversion.boolsToLong(src, 0, 0L, 0, 8 * 4)); @@ -660,17 +649,19 @@ public class ConversionTest { Conversion.boolsToLong(src, 15 * 4, 0x123456798ABCDEF0L, 24, 3 * 4)); } + /** + * Tests {@link Conversion#boolsToInt(boolean[], int, int, int, int)}. + */ @Test - public void testBoolsToInt() throws Exception { + public void testBoolsToInt() { boolean[] src = new boolean[]{ false, false, true, true, true, false, true, true, true, true, true, true, true, false, false, false, true, true, true, true, false, false, false, false, false, false, true, true, true, false, false, false, false, false, false, false, true, true, true, true, true, false, false, false, false, true, false, false, true, true, false, false, false, false, true, false, true, false, true, false, false, true, - true, false, true, true, true, false, false, false, false, true};// conversion of - // "CDF1F0C10F12345678" - // by hexsToBools + true, false, true, true, true, false, false, false, false, true}; + // conversion of "CDF1F0C10F12345678" by hexsToBools assertEquals(0x00000000, Conversion.boolsToInt(src, 0 * 4, 0, 0, 0 * 4)); assertEquals(0x0000000C, Conversion.boolsToInt(src, 0 * 4, 0, 0, 1 * 4)); assertEquals(0x1C0F1FDC, Conversion.boolsToInt(src, 0 * 4, 0, 0, 8 * 4)); @@ -679,17 +670,19 @@ public class ConversionTest { assertEquals(0x87645679, Conversion.boolsToInt(src, 15 * 4, 0x12345679, 20, 3 * 4)); } + /** + * Tests {@link Conversion#boolsToShort(boolean[], int, short, int, int)}. + */ @Test - public void testBoolsToShort() throws Exception { + public void testBoolsToShort() { boolean[] src = new boolean[]{ false, false, true, true, true, false, true, true, true, true, true, true, true, false, false, false, true, true, true, true, false, false, false, false, false, false, true, true, true, false, false, false, false, false, false, false, true, true, true, true, true, false, false, false, false, true, false, false, true, true, false, false, false, false, true, false, true, false, true, false, false, true, - true, false, true, true, true, false, false, false, false, true};// conversion of - // "CDF1F0C10F12345678" - // by hexsToBools + true, false, true, true, true, false, false, false, false, true}; + // conversion of "CDF1F0C10F12345678" by hexsToBools assertEquals((short)0x0000, Conversion.boolsToShort(src, 0 * 4, (short)0, 0, 0 * 4)); assertEquals((short)0x000C, Conversion.boolsToShort(src, 0 * 4, (short)0, 0, 1 * 4)); assertEquals((short)0x1FDC, Conversion.boolsToShort(src, 0 * 4, (short)0, 0, 4 * 4)); @@ -700,17 +693,19 @@ public class ConversionTest { (short)0x8764, Conversion.boolsToShort(src, 15 * 4, (short)0x1234, 4, 3 * 4)); } + /** + * Tests {@link Conversion#boolsToByte(boolean[], int, byte, int, int)}. + */ @Test - public void testBoolsToByte() throws Exception { + public void testBoolsToByte() { boolean[] src = new boolean[]{ false, false, true, true, true, false, true, true, true, true, true, true, true, false, false, false, true, true, true, true, false, false, false, false, false, false, true, true, true, false, false, false, false, false, false, false, true, true, true, true, true, false, false, false, false, true, false, false, true, true, false, false, false, false, true, false, true, false, true, false, false, true, - true, false, true, true, true, false, false, false, false, true};// conversion of - // "CDF1F0C10F12345678" - // by hexsToBools + true, false, true, true, true, false, false, false, false, true}; + // conversion of "CDF1F0C10F12345678" by hexsToBools assertEquals((byte)0x00, Conversion.boolsToByte(src, 0 * 4, (byte)0, 0, 0 * 4)); assertEquals((byte)0x0C, Conversion.boolsToByte(src, 0 * 4, (byte)0, 0, 1 * 4)); assertEquals((byte)0xDC, Conversion.boolsToByte(src, 0 * 4, (byte)0, 0, 2 * 4)); @@ -719,21 +714,24 @@ public class ConversionTest { assertEquals((byte)0x84, Conversion.boolsToByte(src, 17 * 4, (byte)0x34, 4, 1 * 4)); } + /** + * Tests {@link Conversion#longToInts(long, int, int[], int, int)}. + */ @Test - public void testLongToInts() throws Exception { - Assert.assertArrayEquals( + public void testLongToInts() { + assertArrayEquals( new int[]{}, Conversion.longToInts(0x0000000000000000L, 0, new int[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{}, Conversion.longToInts(0x0000000000000000L, 100, new int[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{}, Conversion.longToInts(0x0000000000000000L, 0, new int[]{}, 100, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}, Conversion.longToInts(0x1234567890ABCDEFL, 0, new int[]{-1, -1, -1, -1}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0x90ABCDEF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF}, Conversion.longToInts(0x1234567890ABCDEFL, 0, new int[]{-1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0x90ABCDEF, 0x12345678, 0xFFFFFFFF, 0xFFFFFFFF}, Conversion.longToInts(0x1234567890ABCDEFL, 0, new int[]{-1, -1, -1, -1}, 0, 2)); // assertArrayEquals(new @@ -742,245 +740,254 @@ public class ConversionTest { // assertArrayEquals(new // int[]{0xFFFFFFFF,0x90ABCDEF,0x12345678,0x90ABCDEF},Conversion.longToInts(0x1234567890ABCDEFL, // 0,new int[]{-1,-1,-1,-1},1,3)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0xFFFFFFFF, 0xFFFFFFFF, 0x90ABCDEF, 0x12345678}, Conversion.longToInts(0x1234567890ABCDEFL, 0, new int[]{-1, -1, -1, -1}, 2, 2)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0xFFFFFFFF, 0xFFFFFFFF, 0x90ABCDEF, 0xFFFFFFFF}, Conversion.longToInts(0x1234567890ABCDEFL, 0, new int[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x90ABCDEF}, Conversion.longToInts(0x1234567890ABCDEFL, 0, new int[]{-1, -1, -1, -1}, 3, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0xFFFFFFFF, 0xFFFFFFFF, 0x4855E6F7, 0xFFFFFFFF}, Conversion.longToInts(0x1234567890ABCDEFL, 1, new int[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0xFFFFFFFF, 0xFFFFFFFF, 0x242AF37B, 0xFFFFFFFF}, Conversion.longToInts(0x1234567890ABCDEFL, 2, new int[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0xFFFFFFFF, 0xFFFFFFFF, 0x121579BD, 0xFFFFFFFF}, Conversion.longToInts(0x1234567890ABCDEFL, 3, new int[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0xFFFFFFFF, 0xFFFFFFFF, 0x890ABCDE, 0xFFFFFFFF}, Conversion.longToInts(0x1234567890ABCDEFL, 4, new int[]{-1, -1, -1, -1}, 2, 1)); - // Assert.assertArrayEquals(new + // assertArrayEquals(new // int[]{0x4855E6F7,0x091A2B3C,0x4855E6F7,0x091A2B3C},Conversion.longToInts(0x1234567890ABCDEFL, // 1,new int[]{-1,-1,-1,-1},0,4));//rejected by assertion - Assert.assertArrayEquals( + assertArrayEquals( new int[]{0x091A2B3C}, Conversion.longToInts(0x1234567890ABCDEFL, 33, new int[]{0}, 0, 1)); } + /** + * Tests {@link Conversion#longToShorts(long, int, short[], int, int)}. + */ @Test - public void testLongToShorts() throws Exception { - Assert.assertArrayEquals( + public void testLongToShorts() { + assertArrayEquals( new short[]{}, Conversion.longToShorts(0x0000000000000000L, 0, new short[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{}, Conversion.longToShorts(0x0000000000000000L, 100, new short[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{}, Conversion.longToShorts(0x0000000000000000L, 0, new short[]{}, 100, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xFFFF, (short)0xFFFF}, Conversion.longToShorts(0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xCDEF, (short)0xFFFF, (short)0xFFFF, (short)0xFFFF}, Conversion.longToShorts(0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xCDEF, (short)0x90AB, (short)0xFFFF, (short)0xFFFF}, Conversion.longToShorts(0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 0, 2)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xCDEF, (short)0x90AB, (short)0x5678, (short)0xFFFF}, Conversion.longToShorts(0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 0, 3)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xCDEF, (short)0x90AB, (short)0x5678, (short)0x1234}, Conversion.longToShorts(0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 0, 4)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xCDEF, (short)0x90AB, (short)0x5678}, Conversion.longToShorts(0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 1, 3)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xCDEF, (short)0x90AB}, Conversion.longToShorts(0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 2, 2)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xCDEF, (short)0xFFFF}, Conversion.longToShorts(0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xFFFF, (short)0xCDEF}, Conversion.longToShorts(0x1234567890ABCDEFL, 0, new short[]{-1, -1, -1, -1}, 3, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xE6F7, (short)0xFFFF}, Conversion.longToShorts(0x1234567890ABCDEFL, 1, new short[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xF37B, (short)0xFFFF}, Conversion.longToShorts(0x1234567890ABCDEFL, 2, new short[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x79BD, (short)0xFFFF}, Conversion.longToShorts(0x1234567890ABCDEFL, 3, new short[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xBCDE, (short)0xFFFF}, Conversion.longToShorts(0x1234567890ABCDEFL, 4, new short[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xE6F7, (short)0x4855, (short)0x2B3C, (short)0x091A}, Conversion.longToShorts(0x1234567890ABCDEFL, 1, new short[]{-1, -1, -1, -1}, 0, 4)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0x2B3C}, Conversion.longToShorts(0x1234567890ABCDEFL, 33, new short[]{0}, 0, 1)); } + /** + * Tests {@link Conversion#intToShorts(int, int, short[], int, int)}. + */ @Test - public void testIntToShorts() throws Exception { - Assert.assertArrayEquals( + public void testIntToShorts() { + assertArrayEquals( new short[]{}, Conversion.intToShorts(0x00000000, 0, new short[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{}, Conversion.intToShorts(0x00000000, 100, new short[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{}, Conversion.intToShorts(0x00000000, 0, new short[]{}, 100, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xFFFF, (short)0xFFFF}, Conversion.intToShorts(0x12345678, 0, new short[]{-1, -1, -1, -1}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0x5678, (short)0xFFFF, (short)0xFFFF, (short)0xFFFF}, Conversion.intToShorts(0x12345678, 0, new short[]{-1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0x5678, (short)0x1234, (short)0xFFFF, (short)0xFFFF}, Conversion.intToShorts(0x12345678, 0, new short[]{-1, -1, -1, -1}, 0, 2)); - // Assert.assertArrayEquals(new + // assertArrayEquals(new // short[]{(short)0x5678,(short)0x1234,(short)0x5678,(short)0xFFFF},Conversion.intToShorts(0x12345678, // 0,new short[]{-1,-1,-1,-1},0,3));//rejected by assertion - // Assert.assertArrayEquals(new + // assertArrayEquals(new // short[]{(short)0x5678,(short)0x1234,(short)0x5678,(short)0x1234},Conversion.intToShorts(0x12345678, // 0,new short[]{-1,-1,-1,-1},0,4)); - // Assert.assertArrayEquals(new + // assertArrayEquals(new // short[]{(short)0xFFFF,(short)0x5678,(short)0x1234,(short)0x5678},Conversion.intToShorts(0x12345678, // 0,new short[]{-1,-1,-1,-1},1,3)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x5678, (short)0x1234}, Conversion.intToShorts(0x12345678, 0, new short[]{-1, -1, -1, -1}, 2, 2)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x5678, (short)0xFFFF}, Conversion.intToShorts(0x12345678, 0, new short[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0xFFFF, (short)0x5678}, Conversion.intToShorts(0x12345678, 0, new short[]{-1, -1, -1, -1}, 3, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x2B3C, (short)0xFFFF}, Conversion.intToShorts(0x12345678, 1, new short[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x159E, (short)0xFFFF}, Conversion.intToShorts(0x12345678, 2, new short[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x8ACF, (short)0xFFFF}, Conversion.intToShorts(0x12345678, 3, new short[]{-1, -1, -1, -1}, 2, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0xFFFF, (short)0xFFFF, (short)0x4567, (short)0xFFFF}, Conversion.intToShorts(0x12345678, 4, new short[]{-1, -1, -1, -1}, 2, 1)); - // Assert.assertArrayEquals(new + // assertArrayEquals(new // short[]{(short)0xE6F7,(short)0x4855,(short)0x2B3C,(short)0x091A},Conversion.intToShorts(0x12345678, // 1,new short[]{-1,-1,-1,-1},0,4));//rejected by assertion - // Assert.assertArrayEquals(new short[]{(short)0x2B3C},Conversion.intToShorts(0x12345678,33,new + // assertArrayEquals(new short[]{(short)0x2B3C},Conversion.intToShorts(0x12345678,33,new // short[]{0},0,1));//rejected by assertion - Assert.assertArrayEquals( + assertArrayEquals( new short[]{(short)0x091A}, Conversion.intToShorts(0x12345678, 17, new short[]{0}, 0, 1)); } + /** + * Tests {@link Conversion#longToBytes(long, int, byte[], int, int)}. + */ @Test - public void testLongToBytes() throws Exception { - Assert.assertArrayEquals( + public void testLongToBytes() { + assertArrayEquals( new byte[]{}, Conversion.longToBytes(0x0000000000000000L, 0, new byte[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{}, Conversion.longToBytes(0x0000000000000000L, 100, new byte[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{}, Conversion.longToBytes(0x0000000000000000L, 0, new byte[]{}, 100, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xEF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xEF, (byte)0xCD, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 2)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 4)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0x78, (byte)0x56, (byte)0x34, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 7)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0x78, (byte)0x56, (byte)0x34, (byte)0x12, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 8)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 2)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 4)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0x78, (byte)0x56, (byte)0x34, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 7)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0x78, (byte)0x56, (byte)0x34, (byte)0x12}, Conversion.longToBytes(0x1234567890ABCDEFL, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 8)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xF7, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 1, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0x7B, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.longToBytes(0x1234567890ABCDEFL, 2, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x6F, (byte)0x5E, (byte)0x85, (byte)0xC4, (byte)0xB3, (byte)0xA2, (byte)0x91, (byte)0x00}, Conversion.longToBytes(0x1234567890ABCDEFL, 5, new byte[]{ -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 8)); - // Assert.assertArrayEquals(new + // assertArrayEquals(new // byte[]{(byte)0xFF,(byte)0x00,(byte)0xFF,(byte)0x5E,(byte)0x85,(byte)0xC4,(byte)0xB3,(byte)0xA2,(byte)0x91,(byte)0x00,(byte)0x00},Conversion.longToBytes(0x1234567890ABCDEFL,13,new // byte[]{-1, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1},3,8));//rejected by assertion - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x5E, (byte)0x85, (byte)0xC4, (byte)0xB3, (byte)0xA2, (byte)0x91, (byte)0x00, (byte)0xFF}, @@ -988,78 +995,81 @@ public class ConversionTest { -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 7)); } + /** + * Tests {@link Conversion#intToBytes(int, int, byte[], int, int)}. + */ @Test - public void testIntToBytes() throws Exception { - Assert.assertArrayEquals( + public void testIntToBytes() { + assertArrayEquals( new byte[]{}, Conversion.intToBytes(0x00000000, 0, new byte[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{}, Conversion.intToBytes(0x00000000, 100, new byte[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{}, Conversion.intToBytes(0x00000000, 0, new byte[]{}, 100, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.intToBytes(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xEF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.intToBytes(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xEF, (byte)0xCD, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.intToBytes(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 2)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.intToBytes(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 4)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.intToBytes(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.intToBytes(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 2)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xAB, (byte)0x90, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.intToBytes(0x90ABCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 4)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xF7, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.intToBytes(0x90ABCDEF, 1, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0x7B, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.intToBytes(0x90ABCDEF, 2, new byte[]{ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x6F, (byte)0x5E, (byte)0x85, (byte)0xFC, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.intToBytes(0x90ABCDEF, 5, new byte[]{ -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 4)); - // Assert.assertArrayEquals(new + // assertArrayEquals(new // byte[]{(byte)0xFF,(byte)0x00,(byte)0xFF,(byte)0x5E,(byte)0x85,(byte)0xFC,(byte)0x00,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF},Conversion.intToBytes(0x90ABCDEF,13,new // byte[]{-1, 0,-1,-1,-1,-1,-1,-1,-1,-1,-1},3,4));//rejected by assertion - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x5E, (byte)0x85, (byte)0xFC, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, @@ -1067,66 +1077,72 @@ public class ConversionTest { -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1}, 3, 3)); } + /** + * Tests {@link Conversion#shortToBytes(short, int, byte[], int, int)}. + */ @Test - public void testShortToBytes() throws Exception { - Assert.assertArrayEquals( + public void testShortToBytes() { + assertArrayEquals( new byte[]{}, Conversion.shortToBytes((short)0x0000, 0, new byte[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{}, Conversion.shortToBytes((short)0x0000, 100, new byte[]{}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{}, Conversion.shortToBytes((short)0x0000, 0, new byte[]{}, 100, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.shortToBytes((short)0xCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 0, 0)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xEF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.shortToBytes((short)0xCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xEF, (byte)0xCD, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.shortToBytes((short)0xCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 0, 2)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.shortToBytes((short)0xCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 3, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xEF, (byte)0xCD, (byte)0xFF, (byte)0xFF}, Conversion.shortToBytes((short)0xCDEF, 0, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 3, 2)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xF7, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.shortToBytes((short)0xCDEF, 1, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0x7B, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.shortToBytes((short)0xCDEF, 2, new byte[]{ -1, -1, -1, -1, -1, -1, -1}, 0, 1)); - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0x6F, (byte)0xFE, (byte)0xFF, (byte)0xFF}, Conversion.shortToBytes((short)0xCDEF, 5, new byte[]{ -1, 0, -1, -1, -1, -1, -1}, 3, 2)); - // Assert.assertArrayEquals(new + // assertArrayEquals(new // byte[]{(byte)0xFF,(byte)0x00,(byte)0xFF,(byte)0x5E,(byte)0xFF,(byte)0xFF,(byte)0xFF},Conversion.shortToBytes((short)0xCDEF,13,new // byte[]{-1, 0,-1,-1,-1,-1,-1},3,2));//rejected by assertion - Assert.assertArrayEquals( + assertArrayEquals( new byte[]{ (byte)0xFF, (byte)0x00, (byte)0xFF, (byte)0xFE, (byte)0xFF, (byte)0xFF, (byte)0xFF}, Conversion.shortToBytes((short)0xCDEF, 13, new byte[]{ -1, 0, -1, -1, -1, -1, -1}, 3, 1)); } + /** + * Tests {@link Conversion#longToHexs(long, int, String, int, int)}. + */ @Test - public void testLongToHexs() throws Exception { + public void testLongToHexs() { assertEquals("", Conversion.longToHexs(0x0000000000000000L, 0, "", 0, 0)); assertEquals("", Conversion.longToHexs(0x0000000000000000L, 100, "", 0, 0)); assertEquals("", Conversion.longToHexs(0x0000000000000000L, 0, "", 100, 0)); @@ -1179,8 +1195,11 @@ public class ConversionTest { Conversion.longToHexs(0x1234567890ABCDEFL, 4, "FFFFFFFFFFFFFFFFFFFFFFFF", 3, 15)); } + /** + * Tests {@link Conversion#intToHexs(int, int, String, int, int)}. + */ @Test - public void testIntToHexs() throws Exception { + public void testIntToHexs() { assertEquals("", Conversion.intToHexs(0x00000000, 0, "", 0, 0)); assertEquals("", Conversion.intToHexs(0x00000000, 100, "", 0, 0)); assertEquals("", Conversion.intToHexs(0x00000000, 0, "", 100, 0)); @@ -1233,8 +1252,11 @@ public class ConversionTest { Conversion.intToHexs(0x90ABCDEF, 4, "FFFFFFFFFFFFFFFFFFFFFFFF", 3, 7)); } + /** + * Tests {@link Conversion#shortToHexs(short, int, String, int, int)}. + */ @Test - public void testShortToHexs() throws Exception { + public void testShortToHexs() { assertEquals("", Conversion.shortToHexs((short)0x0000, 0, "", 0, 0)); assertEquals("", Conversion.shortToHexs((short)0x0000, 100, "", 0, 0)); assertEquals("", Conversion.shortToHexs((short)0x0000, 0, "", 100, 0)); @@ -1275,8 +1297,11 @@ public class ConversionTest { Conversion.shortToHexs((short)0xCDEF, 4, "FFFFFFFFFFFFFFFFFFFFFFFF", 3, 3)); } + /** + * Tests {@link Conversion#byteToHexs(byte, int, String, int, int)}. + */ @Test - public void testByteToHexs() throws Exception { + public void testByteToHexs() { assertEquals("", Conversion.byteToHexs((byte)0x00, 0, "", 0, 0)); assertEquals("", Conversion.byteToHexs((byte)0x00, 100, "", 0, 0)); assertEquals("", Conversion.byteToHexs((byte)0x00, 0, "", 100, 0)); @@ -1293,22 +1318,25 @@ public class ConversionTest { assertEquals("000E0", Conversion.byteToHexs((byte)0xEF, 4, "00000", 3, 1)); } + /** + * Tests {@link Conversion#longToBools(long, int, boolean[], int, int)}. + */ @Test - public void testLongToBools() throws Exception { - assertArrayEquals( + public void testLongToBools() { + assertBoolArrayEquals( new boolean[]{}, Conversion.longToBools(0x0000000000000000L, 0, new boolean[]{}, 0, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{}, Conversion.longToBools(0x0000000000000000L, 100, new boolean[]{}, 0, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{}, Conversion.longToBools(0x0000000000000000L, 0, new boolean[]{}, 100, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[69], Conversion.longToBools(0x1234567890ABCDEFL, 0, new boolean[69], 0, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, @@ -1318,7 +1346,7 @@ public class ConversionTest { false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.longToBools(0x1234567890ABCDEFL, 0, new boolean[69], 0, 1)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, @@ -1328,7 +1356,7 @@ public class ConversionTest { false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.longToBools(0x1234567890ABCDEFL, 0, new boolean[69], 0, 2)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, @@ -1338,7 +1366,7 @@ public class ConversionTest { false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.longToBools(0x1234567890ABCDEFL, 0, new boolean[69], 0, 3)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, true, @@ -1347,7 +1375,7 @@ public class ConversionTest { false, false, false, true, false, true, true, false, false, false, true, false, false, true, false, false, false, false, false, false, false, false}, Conversion.longToBools(0x1234567890ABCDEFL, 0, new boolean[69], 0, 63)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, true, @@ -1356,7 +1384,7 @@ public class ConversionTest { false, false, false, true, false, true, true, false, false, false, true, false, false, true, false, false, false, false, false, false, false, false}, Conversion.longToBools(0x1234567890ABCDEFL, 0, new boolean[69], 0, 64)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, @@ -1366,7 +1394,7 @@ public class ConversionTest { false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.longToBools(0x1234567890ABCDEFL, 0, new boolean[69], 2, 1)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ false, false, true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, @@ -1375,7 +1403,7 @@ public class ConversionTest { false, true, false, false, false, true, false, true, true, false, false, false, true, false, false, true, false, false, false, false, false, false}, Conversion.longToBools(0x1234567890ABCDEFL, 0, new boolean[69], 2, 64)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, true, false, @@ -1384,7 +1412,7 @@ public class ConversionTest { false, true, false, true, true, false, false, false, true, false, false, true, false, false, false, false, false, false, false, false, false}, Conversion.longToBools(0x1234567890ABCDEFL, 1, new boolean[69], 0, 63)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, true, false, false, @@ -1394,7 +1422,7 @@ public class ConversionTest { false, false, false, false, false, false, false, false, false}, Conversion.longToBools(0x1234567890ABCDEFL, 2, new boolean[69], 0, 62)); - // assertArrayEquals(new boolean[]{false,false,false, true, true, false, true, true, + // assertBoolArrayEquals(new boolean[]{false,false,false, true, true, false, true, true, // true, true, false, true, true, false, false, true, true, true, true, false, true, // false, true, false, true, false, false, false, false, true, false, false, true, // false, false, false, true, true, true, true, false, false, true, true, false, true, @@ -1402,7 +1430,7 @@ public class ConversionTest { // false, false, true, false, false, false // ,false,false,false,false},Conversion.longToBools(0x1234567890ABCDEFL, 2,new // boolean[69], 3, 63));//rejected by assertion - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ false, false, false, true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, @@ -1413,72 +1441,76 @@ public class ConversionTest { Conversion.longToBools(0x1234567890ABCDEFL, 2, new boolean[69], 3, 62)); } + /** + * Tests {@link Conversion#intToBools(int, int, boolean[], int, int)}. + */ @Test - public void testIntToBools() throws Exception { - assertArrayEquals( + public void testIntToBools() { + assertBoolArrayEquals( new boolean[]{}, Conversion.intToBools(0x00000000, 0, new boolean[]{}, 0, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{}, Conversion.intToBools(0x00000000, 100, new boolean[]{}, 0, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{}, Conversion.intToBools(0x00000000, 0, new boolean[]{}, 100, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[69], Conversion.intToBools(0x90ABCDEF, 0, new boolean[69], 0, 0)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.intToBools(0x90ABCDEF, 0, new boolean[37], 0, 1)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.intToBools(0x90ABCDEF, 0, new boolean[37], 0, 2)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.intToBools(0x90ABCDEF, 0, new boolean[37], 0, 3)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, true, false, false, false, false, true, false, false, false, false, false, false, false, false}, Conversion.intToBools(0x90ABCDEF, 0, new boolean[37], 0, 31)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, true, false, false, false, false, true, false, false, true, false, false, false, false, false}, Conversion.intToBools(0x90ABCDEF, 0, new boolean[37], 0, 32)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.intToBools(0x90ABCDEF, 0, new boolean[37], 2, 1)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ false, false, true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, true, false, false, false, false, true, false, false, true, false, false, false}, Conversion.intToBools(0x90ABCDEF, 0, new boolean[37], 2, 32)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, true, false, false, false, false, true, false, false, true, false, false, false, false, false, false}, Conversion.intToBools(0x90ABCDEF, 1, new boolean[37], 0, 31)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, true, false, false, false, false, true, false, false, true, false, false, false, false, false, false, false}, Conversion.intToBools(0x90ABCDEF, 2, new boolean[37], 0, 30)); - // assertArrayEquals(new boolean[]{false, false, false, true, true, false, true, true, + // assertBoolArrayEquals(new boolean[]{false, false, false, true, true, false, true, + // true, // true, true, false, true, true, false, false, true, true, true, true, false, true, // false, true, false, true, false, false, false, false, true, false, false, false, // false, false, false, false},Conversion.intToBools(0x90ABCDEF, 2,new boolean[37], // 3,31));//rejected by assertion - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ false, false, false, true, true, false, true, true, true, true, false, true, true, false, false, true, true, true, true, false, true, false, true, false, @@ -1486,57 +1518,60 @@ public class ConversionTest { false, false}, Conversion.intToBools(0x90ABCDEF, 2, new boolean[37], 3, 30)); } + /** + * Tests {@link Conversion#shortToBools(short, int, boolean[], int, int)}. + */ @Test - public void testShortToBools() throws Exception { - assertArrayEquals( + public void testShortToBools() { + assertBoolArrayEquals( new boolean[]{}, Conversion.shortToBools((short)0x0000, 0, new boolean[]{}, 0, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{}, Conversion.shortToBools((short)0x0000, 100, new boolean[]{}, 0, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{}, Conversion.shortToBools((short)0x0000, 0, new boolean[]{}, 100, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[69], Conversion.shortToBools((short)0xCDEF, 0, new boolean[69], 0, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.shortToBools((short)0xCDEF, 0, new boolean[21], 0, 1)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.shortToBools((short)0xCDEF, 0, new boolean[21], 0, 2)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.shortToBools((short)0xCDEF, 0, new boolean[21], 0, 3)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, false, false, false, false, false, false}, Conversion.shortToBools((short)0xCDEF, 0, new boolean[21], 0, 15)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, false, false, false, false, false}, Conversion.shortToBools((short)0xCDEF, 0, new boolean[21], 0, 16)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.shortToBools((short)0xCDEF, 0, new boolean[21], 2, 1)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ false, false, true, true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, false, false, false}, Conversion.shortToBools((short)0xCDEF, 0, new boolean[21], 2, 16)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, true, false, true, true, true, true, false, true, true, false, false, true, true, false, false, false, false, false, false}, Conversion.shortToBools((short)0xCDEF, 1, new boolean[21], 0, 15)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ true, true, false, true, true, true, true, false, true, true, false, false, true, true, false, false, false, false, false, false, false}, @@ -1545,96 +1580,58 @@ public class ConversionTest { // true, true, false, true, true, false, false, true, false, false, false, false, // false},Conversion.shortToBools((short)0xCDEF, 2,new boolean[21], 3,15));//rejected by // assertion - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{ false, false, false, true, true, false, true, true, true, true, false, true, true, false, false, true, true, false, false, false, false}, Conversion.shortToBools((short)0xCDEF, 2, new boolean[21], 3, 14)); } + /** + * Tests {@link Conversion#byteToBools(byte, int, boolean[], int, int)}. + */ @Test - public void testByteToBools() throws Exception { - assertArrayEquals( + public void testByteToBools() { + assertBoolArrayEquals( new boolean[]{}, Conversion.byteToBools((byte)0x00, 0, new boolean[]{}, 0, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{}, Conversion.byteToBools((byte)0x00, 100, new boolean[]{}, 0, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[]{}, Conversion.byteToBools((byte)0x00, 0, new boolean[]{}, 100, 0)); - assertArrayEquals( + assertBoolArrayEquals( new boolean[69], Conversion.byteToBools((byte)0xEF, 0, new boolean[69], 0, 0)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ true, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.byteToBools((byte)0x95, 0, new boolean[13], 0, 1)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ true, false, false, false, false, false, false, false, false, false, false, false, false}, Conversion.byteToBools((byte)0x95, 0, new boolean[13], 0, 2)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ true, false, true, false, false, false, false, false, false, false, false, false, false}, Conversion.byteToBools((byte)0x95, 0, new boolean[13], 0, 3)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ true, false, true, false, true, false, false, false, false, false, false, false, false}, Conversion.byteToBools((byte)0x95, 0, new boolean[13], 0, 7)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ true, false, true, false, true, false, false, true, false, false, false, false, false}, Conversion.byteToBools((byte)0x95, 0, new boolean[13], 0, 8)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ false, false, true, false, false, false, false, false, false, false, false, false, false}, Conversion.byteToBools((byte)0x95, 0, new boolean[13], 2, 1)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ false, false, true, false, true, false, true, false, false, true, false, false, false}, Conversion.byteToBools((byte)0x95, 0, new boolean[13], 2, 8)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ false, true, false, true, false, false, true, false, false, false, false, false, false}, Conversion.byteToBools((byte)0x95, 1, new boolean[13], 0, 7)); - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ true, false, true, false, false, true, false, false, false, false, false, false, false}, Conversion.byteToBools((byte)0x95, 2, new boolean[13], 0, 6)); // assertArrayEquals(new boolean[]{false, false, false, true, true, false, true, true, // false, false, false, false, false},Conversion.byteToBools((byte)0x95, 2,new // boolean[13], 3, 7));//rejected by assertion - assertArrayEquals(new boolean[]{ + assertBoolArrayEquals(new boolean[]{ false, false, false, true, false, true, false, false, true, false, false, false, false}, Conversion.byteToBools((byte)0x95, 2, new boolean[13], 3, 6)); } - - private boolean hasMethod(String methodName) { - Method[] methods = this.getClass().getMethods(); - for (Method m : methods) { - if (m.getName().equals(methodName)) return true; - } - return false; - } - - @Test - public void testTestsToCheckImplemented() throws Exception { - if (!hasMethod("testIntsToLong")) fail("test testIntsToLong not implemented"); - if (!hasMethod("testShortsToLong")) fail("test testShortsToLong not implemented"); - if (!hasMethod("testShortsToInt")) fail("test testShortsToInt not implemented"); - if (!hasMethod("testBytesToLong")) fail("test testBytesToLong not implemented"); - if (!hasMethod("testBytesToInt")) fail("test testBytesToInt not implemented"); - if (!hasMethod("testBytesToShort")) fail("test testBytesToShort not implemented"); - if (!hasMethod("testHexsToLong")) fail("test testHexsToLong not implemented"); - if (!hasMethod("testHexsToInt")) fail("test testHexsToInt not implemented"); - if (!hasMethod("testHexsToShort")) fail("test testHexsToShort not implemented"); - if (!hasMethod("testHexsToByte")) fail("test testHexsToByte not implemented"); - if (!hasMethod("testBoolsToLong")) fail("test testBoolsToLong not implemented"); - if (!hasMethod("testBoolsToInt")) fail("test testBoolsToInt not implemented"); - if (!hasMethod("testBoolsToShort")) fail("test testBoolsToShort not implemented"); - if (!hasMethod("testBoolsToByte")) fail("test testBoolsToByte not implemented"); - if (!hasMethod("testLongToInts")) fail("test testLongToInts not implemented"); - if (!hasMethod("testLongToShorts")) fail("test testLongToShorts not implemented"); - if (!hasMethod("testIntToShorts")) fail("test testIntToShorts not implemented"); - if (!hasMethod("testLongToBytes")) fail("test testLongToBytes not implemented"); - if (!hasMethod("testIntToBytes")) fail("test testIntToBytes not implemented"); - if (!hasMethod("testShortToBytes")) fail("test testShortToBytes not implemented"); - if (!hasMethod("testLongToHexs")) fail("test testLongToHexs not implemented"); - if (!hasMethod("testIntToHexs")) fail("test testIntToHexs not implemented"); - if (!hasMethod("testShortToHexs")) fail("test testShortToHexs not implemented"); - if (!hasMethod("testByteToHexs")) fail("test testByteToHexs not implemented"); - if (!hasMethod("testLongToBools")) fail("test testLongToBools not implemented"); - if (!hasMethod("testIntToBools")) fail("test testIntToBools not implemented"); - if (!hasMethod("testShortToBools")) fail("test testShortToBools not implemented"); - if (!hasMethod("testByteToBools")) fail("test testByteToBools not implemented"); - } - }