only:covering current implementation
This commit is contained in:
parent
48ee5abec7
commit
da0fe3ba15
|
@ -11,7 +11,7 @@ public class HexUtil {
|
|||
return hexToBytes(hex);
|
||||
}
|
||||
|
||||
private static byte[] hexToBytes(String s) {
|
||||
public static byte[] hexToBytes(String s) {
|
||||
return hexToBytes(s, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package com.rusefi.io.can;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
|
||||
public class HexUtilTest {
|
||||
@Test
|
||||
public void decodeSimple() {
|
||||
byte[] pa = HexUtil.hexToBytes("abcd");
|
||||
assertArrayEquals(new byte[]{(byte) 0xab, (byte) 0xcd}, pa);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodeUneven() {
|
||||
byte[] pa = HexUtil.hexToBytes("1abcd");
|
||||
assertArrayEquals(new byte[]{1, (byte) 0xab, (byte) 0xcd}, pa);
|
||||
}
|
||||
|
||||
@Test(expected = NumberFormatException.class)
|
||||
public void unexpected() {
|
||||
HexUtil.hexToBytes("0xff");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue