86ff5ff7761f7b901d39b65bd7e807bfa5dda1e6
[hc2vpp.git] /
1 package io.fd.honeycomb.translate.v3po.util;
2
3 import static org.junit.Assert.assertArrayEquals;
4 import static org.junit.Assert.assertEquals;
5
6 import org.junit.Test;
7
8 /**
9  * Created by jsrnicek on 23.9.2016.
10  */
11 public class ByteDataTranslatorTest implements ByteDataTranslator {
12
13     @Test
14     public void testBooleanToByte() {
15         assertEquals(0, booleanToByte(null));
16         assertEquals(0, booleanToByte(false));
17         assertEquals(1, booleanToByte(true));
18     }
19
20     @Test
21     public void testByteToBoolean() {
22         assertEquals(Boolean.FALSE, byteToBoolean((byte) 0));
23         assertEquals(Boolean.TRUE, byteToBoolean((byte) 1));
24     }
25
26     @Test(expected = IllegalArgumentException.class)
27     public void testByteToBooleanFailed() {
28         byteToBoolean((byte) 123);
29     }
30
31     @Test
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());
38     }
39 }