1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
package com.drew.lang;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
/**
* @author Drew Noakes http://drewnoakes.com
*/
public class ByteConvertTest
{
@Test
public void toInt32BigEndian()
{
assertEquals(0x01020304, ByteConvert.toInt32BigEndian(new byte[]{1, 2, 3, 4}));
assertEquals(0x01020304, ByteConvert.toInt32BigEndian(new byte[]{1, 2, 3, 4, 5}));
}
@Test
public void toInt32LittleEndian()
{
assertEquals(0x04030201, ByteConvert.toInt32LittleEndian(new byte[]{1, 2, 3, 4}));
assertEquals(0x04030201, ByteConvert.toInt32LittleEndian(new byte[]{1, 2, 3, 4, 5}));
}
}
|