Test BCD with right padding

This commit is contained in:
Enrique Zamudio
2018-04-17 15:00:48 -05:00
parent 360cb3e3e5
commit 09c006fdc4
2 changed files with 10 additions and 1 deletions
@@ -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));
}
}
@@ -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));
}
}