public void testInterpret() throws Exception { byte[] b = new byte[3]; inter.interpret("123", b, 0); TestUtils.assertEquals(new byte[] {49, 50, 51}, b); }
public void testUninterpret() throws Exception { byte[] data = new byte[] {(byte)0xFF, (byte)0x12}; byte[] b = new byte[] {0x46, 0x46, 0x31, 0x32}; TestUtils.assertEquals(data, inter.uninterpret(b, 0, 2)); }
public void testPack() throws Exception { ISOField field = new ISOField(12, "1234"); IFA_FLLNUM packager = new IFA_FLLNUM(10, "Should be 04ABCD"); TestUtils.assertEquals("041234 ".getBytes(), packager.pack(field)); }
public void testPack() throws Exception { ISOField field = new ISOField(12, "1234"); IFA_NUMERIC packager = new IFA_NUMERIC(10, "Should be 0000001234"); TestUtils.assertEquals("0000001234".getBytes(), packager.pack(field)); }
public void testPack() throws Exception { ISOField field = new ISOField(12, "1234"); IFA_LLLNUM packager = new IFA_LLLNUM(10, "Should be 0041234"); TestUtils.assertEquals("0041234".getBytes(), packager.pack(field)); }
public void testPack() throws Exception { ISOField field = new ISOField(12, "1234"); IFE_NUMERIC packager = new IFE_NUMERIC(10, "Should be 0000001234"); TestUtils.assertEquals(new byte[] {(byte)0xF0, (byte)0xF0, (byte)0xF0, (byte)0xF0, (byte)0xF0, (byte)0xF0, (byte)0xF1, (byte)0xF2, (byte)0xF3, (byte)0xF4}, packager.pack(field)); }
public void testPack() throws Exception { ISOBinaryField field = new ISOBinaryField(12, new byte[] {0x12, 0x34}); IFA_LLLBINARY packager = new IFA_LLLBINARY(2, "Should be 1234"); TestUtils.assertEquals(new byte[] {0x30, 0x30, 0x32, 0x12, 0x34}, packager.pack(field)); }
public void testPack() throws Exception { ISOField field = new ISOField(3, "0123456789ABCDEF"); IFB_HEX packager = new IFB_HEX(16, "Should be 0123456789ABCDEF", true); TestUtils.assertEquals( new byte[] {0x01, 0x23, 0x45, 0x67, (byte) 0x89, (byte) 0xAB, (byte) 0xCD, (byte) 0xEF} , packager.pack(field)); }
public void testPack() throws Exception { ISOField field = new ISOField(12, "ABCD"); IFE_LLCHAR packager = new IFE_LLCHAR(10, "Should be 04ABCD"); TestUtils.assertEquals(new byte[] {(byte)0xF0, (byte)0xF4, (byte)0xC1, (byte)0xC2, (byte)0xC3, (byte)0xC4}, packager.pack(field)); }
public void testPack() throws Exception { ISOField field = new ISOField(12, "ABCD"); IFB_LLLHECHAR packager = new IFB_LLLHECHAR(10, "Should be 04ABCD"); TestUtils.assertEquals(new byte[] {0x00, 0x04, (byte)0xC1, (byte)0xC2, (byte)0xC3, (byte)0xC4}, packager.pack(field)); }
public void testPack() throws Exception { ISOField field = new ISOField(12, "1234"); IFB_LLLNUM packager = new IFB_LLLNUM(10, "Should be 00041234", true); TestUtils.assertEquals(new byte[]{0x00, 0x04, 0x12, 0x34}, packager.pack(field)); }
public void testPack() throws Exception { ISOField field = new ISOField(12, "D123"); IFB_AMOUNT packager = new IFB_AMOUNT(6, "Should be D00123", true); TestUtils.assertEquals(new byte[]{68, 0x00, 0x01, 0x23}, packager.pack(field)); }
public void testPackOddDigits() throws Exception { ISOField field = new ISOField(12, "D123"); IFB_AMOUNT packager = new IFB_AMOUNT(5, "Should be D0123", true); TestUtils.assertEquals(new byte[]{68, 0x01, 0x23}, packager.pack(field)); }
@Test public void testPackANonEmptyArray() throws Exception { ISOField field = new ISOField(9, "12"); IFE_LNUM packager = new IFE_LNUM(9, "testing packing a non empty Array"); TestUtils.assertEquals(new byte[] {(byte) 0xF2, (byte) 0xF1, (byte) 0xF2}, packager.pack(field)); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x30, 0x30, 0x32, 0x12, 0x34}; IFA_LLLBINARY packager = new IFA_LLLBINARY(2, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
@Test public void testPackAnEmptyArray() throws Exception { ISOField field = new ISOField(9, ""); IFE_LLLNUM packager = new IFE_LLLNUM(9, "testing packing an empty Array"); TestUtils.assertEquals(new byte[] {(byte)0xF0,(byte)0xF0,(byte)0xF0}, packager.pack(field)); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x02, 0x12, 0x34, 0x00, 0x00}; IFB_LLHFBINARY packager = new IFB_LLHFBINARY(4, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
public void testUnpack() throws Exception { byte[] raw = new byte[] {0x02, 0x12, 0x34}; IFB_LLBINARY packager = new IFB_LLBINARY(2, "Should be 1234"); ISOBinaryField field = new ISOBinaryField(12); packager.unpack(field, raw, 0); TestUtils.assertEquals(new byte[] {0x12, 0x34}, (byte[])field.getValue()); }
@Test public void testUnpackOffsetArray() throws Exception { byte[] raw = new byte[] {0x30, 0x31, (byte) 0xF2, 0x30, 0x31}; IFE_LBINARY packager = new IFE_LBINARY(9, "testing unpacking a non empty Array with an offset"); ISOBinaryField field = new ISOBinaryField(9); packager.unpack(field, raw, 2); TestUtils.assertEquals(new byte[] {0x30, 0x31}, (byte[])field.getValue()); } }
public void testReversability() throws Exception { byte[] origin = new byte[] {0x12, 0x34, 0x56, 0x78}; ISOBinaryField f = new ISOBinaryField(12, origin); IFB_LLLBINARY packager = new IFB_LLLBINARY(100, "Should be 12345678"); ISOBinaryField unpack = new ISOBinaryField(12); packager.unpack(unpack, packager.pack(f), 0); TestUtils.assertEquals(origin, (byte[])unpack.getValue()); }