1 package io.fd.honeycomb.translate.v3po.util;
3 import static org.junit.Assert.assertArrayEquals;
4 import static org.junit.Assert.assertEquals;
9 * Created by jsrnicek on 23.9.2016.
11 public class ByteDataTranslatorTest implements ByteDataTranslator {
14 public void testBooleanToByte() {
15 assertEquals(0, booleanToByte(null));
16 assertEquals(0, booleanToByte(false));
17 assertEquals(1, booleanToByte(true));
21 public void testByteToBoolean() {
22 assertEquals(Boolean.FALSE, byteToBoolean((byte) 0));
23 assertEquals(Boolean.TRUE, byteToBoolean((byte) 1));
26 @Test(expected = IllegalArgumentException.class)
27 public void testByteToBooleanFailed() {
28 byteToBoolean((byte) 123);
32 public void testToString() {
33 final byte[] expected = "test".getBytes();
34 final byte[] cString = new byte[expected.length + 10];
35 System.arraycopy(expected, 0, cString, 0, expected.length);
36 final String jString = toString(cString);
37 assertArrayEquals(expected, jString.getBytes());