new byte[] { 0x03, 0x02, 0x07, (byte) 0x80 } } };
public void testDecode_Encode() throws IOException {
// decoder/encoder for testing
ASN1BitString asn1 = ASN1BitString.getInstance();
// decode from byte array
for (int i = 0; i < validBitstring.length; i++) {
DerInputStream in = new DerInputStream(
(byte[]) validBitstring[i][1]);
BitString expected = (BitString) validBitstring[i][0];
BitString decoded = (BitString) asn1.decode(in);
assertEquals("Testcase: " + i, expected.unusedBits,
decoded.unusedBits);
assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,
decoded.bytes));
}
// decode from input stream
for (int i = 0; i < validBitstring.length; i++) {
DerInputStream in = new DerInputStream(new ByteArrayInputStream(
(byte[]) validBitstring[i][1]));
BitString expected = (BitString) validBitstring[i][0];
BitString decoded = (BitString) asn1.decode(in);
assertEquals("Testcase: " + i, expected.unusedBits,
decoded.unusedBits);
assertTrue("Testcase: " + i, Arrays.equals(expected.bytes,