📄 ife_bitmaptest.java
字号:
try { outBytes = oneByte.pack(c); fail("8 bytes bitmap: pack of 64 bits bitmap by 1 byte packager should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold bits numbered up to 8 in the 1 bytes available.",e.getMessage()); } try { outBytes = twoBytes.pack(c); fail("8 bytes bitmap: pack of 64 bits bitmap by 2 bytes packager should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold bits numbered up to 16 in the 2 bytes available.",e.getMessage()); } try { outBytes = threeBytes.pack(c); fail("8 bytes bitmap: pack of 64 bits bitmap by 3 bytes packager should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold bits numbered up to 24 in the 3 bytes available.",e.getMessage()); } try { outBytes = fourBytes.pack(c); fail("8 bytes bitmap: pack of 64 bits bitmap by 4 bytes packager should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold bits numbered up to 32 in the 4 bytes available.",e.getMessage()); } } public void test16ByteBitmapWithDataWith2ndBitMapBitOn() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = sixteenBytes.unpack(c, DataWith2ndBitMapBitOn, 0); assertEquals("16 bytes bitmap: unpack of 8 bytes bitmap should consume 32 bytes in characters", 32, consumed); assertEquals("16 bytes bitmap: 16 bytes bitmap should result in a bitmap holding fields up to 128", 128 ,((BitSet)c.getValue()).length() - 1); outBytes = sixteenBytes.pack(c); assertEquals("16 bytes bitmap: pack of 16 bytes bitmap must produce a result 32 bytes long",32,outBytes.length); assertEquals("16 bytes bitmap: pack of upacked value should be the same as original", ISOUtil.hexString(DataWith2ndBitMapBitOn,0,32),ISOUtil.hexString(outBytes)); try { outBytes = oneByte.pack(c); fail("16 bytes bitmap: pack of 64 bits bitmap by 1 byte packager should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold bits numbered up to 8 in the 1 bytes available.",e.getMessage()); } try { outBytes = twoBytes.pack(c); fail("16 bytes bitmap: pack of 64 bits bitmap by 2 bytes packager should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold bits numbered up to 16 in the 2 bytes available.",e.getMessage()); } try { outBytes = threeBytes.pack(c); fail("16 bytes bitmap: pack of 64 bits bitmap by 3 bytes packager should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold bits numbered up to 24 in the 3 bytes available.",e.getMessage()); } try { outBytes = fourBytes.pack(c); fail("16 bytes bitmap: pack of 64 bits bitmap by 4 bytes packager should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold bits numbered up to 32 in the 4 bytes available.",e.getMessage()); } try { outBytes = eightBytes.pack(c); fail("16 bytes bitmap: pack of 64 bits bitmap by 4 bytes packager should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold bits numbered up to 64 in the 8 bytes available.",e.getMessage()); } } public void test16ByteBitmapWithDataWith2ndBitMapBitOFF() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = sixteenBytes.unpack(c, DataWith2ndBitMapBitOff,0); assertEquals("16 bytes bitmap with data with 2nd bit map bit off: unpack of 8 bytes bitmap should consume 32 bytes in characters as the 2nd bitmap indicator is off",16,consumed); assertEquals("16 bytes bitmap with data with 2nd bit map bit off: 16 byte bitmap with 2nd bitmap idicator is off should have a maximum field of 64",64,((BitSet)c.getValue()).length() - 1); outBytes = sixteenBytes.pack(c); assertEquals("16 bytes bitmap with data with 2nd bit map bit off: pack of 64 bits bitmap with 16 bytes packager must produce a result 16 bytes long",16,outBytes.length); assertEquals("16 bytes bitmap with data with 2nd bit map bit off: pack of upacked value should be the same as original", ISOUtil.hexString(DataWith2ndBitMapBitOff,0,16),ISOUtil.hexString(outBytes)); }/* public void test48ByteBitmap() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = fortyeightBytes.unpack(c, inBytes,0); assertEquals("All 48 Bytes should be consumed",48,consumed); assertEquals("48 characters can only result in a bitmap holding fields up to 192",192,((BitSet)c.getValue()).length() - 1); outBytes = fortyeightBytes.pack(c); assertEquals("Pack of forty eight bytes must produce a result 48 bytes long",48,outBytes.length); assertEquals("48 byte bitmap pack should reflect unpack",ISOUtil.hexString(inBytes,0,48),ISOUtil.hexString(outBytes)); try { outBytes = thirtytwoBytes.pack(c); fail("Pack of bitmap with fields outside of 32 byte range should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold fields numbered up to 128 in the 32 bytes available.",e.getMessage()); } try { outBytes = thirtytwoBytes.pack(c); fail("Pack of bitmap with fields outside of 32 byte range should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold fields numbered up to 128 in the 32 bytes available.",e.getMessage()); } try { outBytes = sixteenBytes.pack(c); fail("Pack of bitmap with fields outside of 16 byte range should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold fields numbered up to 64 in the 16 bytes available.",e.getMessage()); } try { outBytes = twoBytes.pack(c); fail("Pack of bitmap with fields outside of 2 byte range should result in ISOException"); } catch (Exception e) { // expected. assertEquals("Bitmap can only hold fields numbered up to 8 in the 2 bytes available.",e.getMessage()); } } public void test48ByteBitmapWithOnly32BytesUsed() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = fortyeightBytes.unpack(c, thirtytwoByteBitMapIn48Bytes,0); assertEquals("32 bytes should be consumed as the 2nd bitmap indicator is on, 3rd is off ",32,consumed); assertEquals("48 byte bitmap with just 32 bytes used should have a maximum field of ",128,((BitSet)c.getValue()).length() - 1); outBytes = fortyeightBytes.pack(c); assertEquals("48 Byte (32 bytes used) bitmap pack should reflect unpack",ISOUtil.hexString(thirtytwoByteBitMapIn48Bytes,0,32),ISOUtil.hexString(outBytes)); } public void test48ByteBitmapWithOnly16BytesUsed() throws Exception { ISOComponent c = new ISOBitMap(1); int consumed = fortyeightBytes.unpack(c, sixteenByteBitMapIn48Bytes,0); assertEquals("16 bytes should be consumed as the 2nd bitmap indicator is off",16,consumed); assertEquals("48 byte bitmap with just 16 bytes used should have a maximum field of ",64,((BitSet)c.getValue()).length() - 1); outBytes = fortyeightBytes.pack(c); assertEquals("48 Byte (16 bytes used) bitmap pack should reflect unpack",ISOUtil.hexString(sixteenByteBitMapIn48Bytes,0,16),ISOUtil.hexString(outBytes)); } */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -