Moved some test classes to the test folder
This commit is contained in:
parent
6c81d79332
commit
ccead35ee7
3 changed files with 15 additions and 5 deletions
|
|
@ -60,10 +60,10 @@ public class Converter {
|
|||
*/
|
||||
public static byte[] toBytes(int num){
|
||||
return new byte[]{
|
||||
(byte)(num & 0xff),
|
||||
(byte)((num >> 8)& 0xff),
|
||||
(byte)((num >> 24)& 0xff),
|
||||
(byte)((num >> 16)& 0xff),
|
||||
(byte)((num >> 24)& 0xff)};
|
||||
(byte)((num >> 8)& 0xff),
|
||||
(byte)(num & 0xff)};
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -90,4 +90,14 @@ public class ConverterTest {
|
|||
assertEquals(Integer.MAX_VALUE, Converter.toInt(new byte[]{(byte)0x7F,(byte)0xFF,(byte)0xFF,(byte)0xFF}));
|
||||
assertEquals(Integer.MAX_VALUE, Converter.toInt(new byte[]{(byte)0x7F,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void intToByteArray(){
|
||||
assertArrayEquals(new byte[]{0x00,0x00,0x00,0x00}, Converter.toBytes(0));
|
||||
assertArrayEquals(new byte[]{0x00,0x00,0x00,0x01}, Converter.toBytes(1));
|
||||
assertArrayEquals(new byte[]{0x00,0x00,0x01,0x00}, Converter.toBytes(256));
|
||||
assertArrayEquals(new byte[]{(byte)0xFF,(byte)0xFF,(byte)0xFF,(byte)0xFF}, Converter.toBytes(-1));
|
||||
assertArrayEquals(new byte[]{(byte)0x7F,(byte)0xFF,(byte)0xFF,(byte)0xFF}, Converter.toBytes(Integer.MAX_VALUE));
|
||||
assertArrayEquals(new byte[]{(byte)0x80,(byte)0x00,(byte)0x00,(byte)0x00}, Converter.toBytes(Integer.MIN_VALUE));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue