### Question:
Base1_BITMAP126 extends ISOBitMapPackager { public byte[] pack (ISOComponent c) throws ISOException { return ISOUtil.bitSet2byte ((BitSet) c.getValue()); } Base1_BITMAP126();  Base1_BITMAP126(int len, String description); byte[] pack(ISOComponent c); int unpack(ISOComponent c, byte[] b, int offset); int getMaxPackedLength();  }### Answer:
@Test public void testPack() throws Throwable { BitSet v = new BitSet(100); Base1_BITMAP126 base1_BITMAP126 = new Base1_BITMAP126(100, "testBase1_BITMAP126Description"); byte[] result = base1_BITMAP126.pack(new ISOBitMap(100, v)); assertEquals(0, result.length, "result.length"); }
@Test public void testPackThrowsClassCastException() throws Throwable { try { new Base1_BITMAP126(100, "testBase1_BITMAP126Description").pack(new ISOMsg("testBase1_BITMAP126Mti")); fail("Expected ClassCastException to be thrown"); } catch (ClassCastException ex) { assertEquals(ClassCastException.class, ex.getClass(), "ex.getClass()"); } }
@Test public void testPackThrowsNullPointerException() throws Throwable { try { new Base1_BITMAP126(100, "testBase1_BITMAP126Description").pack(new ISOBinaryField()); fail("Expected NullPointerException to be thrown"); } catch (NullPointerException ex) { if (isJavaVersionAtMost(JAVA_14)) { assertNull(ex.getMessage(), "ex.getMessage()"); } else { assertEquals("Cannot invoke \"java.util.BitSet.length()\" because \"b\" is null", ex.getMessage(), "ex.getMessage()"); } } }