diff --git a/src/test/java/com/solab/iso8583/parse/CustomBinCodecs.java b/src/test/java/com/solab/iso8583/parse/CustomBinCodecs.java index f78ec1e..b65fd0a 100644 --- a/src/test/java/com/solab/iso8583/parse/CustomBinCodecs.java +++ b/src/test/java/com/solab/iso8583/parse/CustomBinCodecs.java @@ -25,6 +25,8 @@ public class CustomBinCodecs { private final BigInteger b29 = new BigInteger("12345678901234567890123456789"); final byte[] longData2 = new byte[]{ 0x12, 0x34, 0x56, 0x78, (byte)0x90, 00, 00, 00, 00, 00 }; final byte[] bigintData1 = new byte[]{ 1, 0x23, 0x45, 0x67, (byte)0x89, 1, 0x23, 0x45, 0x67, (byte)0x89, 1, 0x23, 0x45, 0x67, (byte)0x89, 00, 00, 00, 00, 00 }; + final byte[] rlong = new byte[]{ 0x12, 0x34, 0x56, 0x78, (byte)0x9F }; + final byte[] rbi = new byte[]{ 0x12, 0x34, 0x56, 0x78, (byte)0x90, 0x12, 0x34, 0x56, 0x78, (byte)0x9F }; @Test public void testLongCodec() { @@ -98,4 +100,11 @@ public class CustomBinCodecs { testFieldType(IsoType.LLLBIN, new LllbinParseInfo(), 12, 19); } + @Test + public void testRightPadding() { + final LongBcdCodec lc = new LongBcdCodec(true); + Assert.assertEquals(123456789L, (long) lc.decodeBinaryField(rlong, 0, 5)); + final BigIntBcdCodec bc = new BigIntBcdCodec(true); + Assert.assertEquals(new BigInteger("1234567890123456789"), bc.decodeBinaryField(rbi, 0, 10)); + } } diff --git a/src/test/java/com/solab/iso8583/util/TestBcd.java b/src/test/java/com/solab/iso8583/util/TestBcd.java index b88db92..7fab8e1 100644 --- a/src/test/java/com/solab/iso8583/util/TestBcd.java +++ b/src/test/java/com/solab/iso8583/util/TestBcd.java @@ -60,7 +60,7 @@ public class TestBcd { buf[0] = (byte)0x99; buf[1] = (byte)0x9f; Assert.assertEquals(999, Bcd.decodeRightPaddedToLong(buf,0,4)); - Assert.assertEquals(new BigInteger("999"), Bcd.decodeRightPaddedToBigInteger(buf,0,3)); + Assert.assertEquals(new BigInteger("999"), Bcd.decodeRightPaddedToBigInteger(buf,0,4)); } }