use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerRealTest method codingZero.
@Test
public void codingZero() throws IOException {
ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50);
BerReal berReal = new BerReal(0);
berReal.encode(berStream, true);
assertArrayEquals(HexString.toBytes("0900"), berStream.getArray());
ByteArrayInputStream berInputStream = new ByteArrayInputStream(berStream.getArray());
BerReal berRealDecoded = new BerReal();
berRealDecoded.decode(berInputStream, true);
assertEquals(0, berRealDecoded.value, 0.01);
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerRealTest method coding0dot7.
@Test
public void coding0dot7() throws IOException {
final BerReal orig = new BerReal(0.7);
final ReverseByteArrayOutputStream baos = new ReverseByteArrayOutputStream(100, true);
orig.encode(baos, true);
// System.out.println(DatatypeConverter.printHexBinary(baos.getArray()));
assertArrayEquals(HexString.toBytes("090980CC0B333333333333"), baos.getArray());
final BerReal decoded = new BerReal();
decoded.decode(new ByteArrayInputStream(baos.getArray()), true);
assertEquals(orig.value, decoded.value, 0.001);
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerRealTest method codingNegInf.
@Test
public void codingNegInf() throws IOException {
ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50);
BerReal berReal = new BerReal(Double.NEGATIVE_INFINITY);
berReal.encode(berStream, true);
assertArrayEquals(HexString.toBytes("090141"), berStream.getArray());
ByteArrayInputStream berInputStream = new ByteArrayInputStream(berStream.getArray());
BerReal berRealDecoded = new BerReal();
berRealDecoded.decode(berInputStream, true);
assertEquals(Double.NEGATIVE_INFINITY, berRealDecoded.value, 0.01);
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerOctetStringTest method explicitEncoding.
@Test
public void explicitEncoding() throws IOException {
ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50);
byte[] byteArray = new byte[] { 0x01, 0x02, 0x03 };
BerOctetString asn1OctetString = new BerOctetString(byteArray);
int length = asn1OctetString.encode(berStream, true);
assertEquals(5, length);
byte[] expectedBytes = new byte[] { 0x04, 0x03, 0x01, 0x02, 0x03 };
assertArrayEquals(expectedBytes, berStream.getArray());
}
use of com.beanit.asn1bean.ber.ReverseByteArrayOutputStream in project sandbox-java by stIncMale.
the class InAppAttribute method encodeAndSave.
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream reverseOS = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(reverseOS, false);
code = reverseOS.getArray();
}
Aggregations