use of org.openmuc.jasn1.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerReal method encodeAndSave.
public void encodeAndSave(int encodingSizeGuess) throws IOException {
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(encodingSizeGuess);
encode(os, false);
code = os.getArray();
}
use of org.openmuc.jasn1.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method encodeDecodeLargeLongs.
@Test
public void encodeDecodeLargeLongs() throws IOException {
ReverseByteArrayOutputStream os = new ReverseByteArrayOutputStream(50);
BerInteger myInt = new BerInteger(BigInteger.valueOf(20093243433l));
myInt.encode(os, true);
ByteArrayInputStream berInputStream = new ByteArrayInputStream(os.getArray());
BerInteger myInt2 = new BerInteger();
myInt2.decode(berInputStream, true);
Assert.assertEquals(20093243433l, myInt2.value.longValue());
}
use of org.openmuc.jasn1.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method encodeDecodeLargeNegativeLongs.
@Test
public void encodeDecodeLargeNegativeLongs() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
BerInteger myInt = new BerInteger(BigInteger.valueOf(-20093243433l));
myInt.encode(berBAOStream, true);
ByteArrayInputStream berInputStream = new ByteArrayInputStream(berBAOStream.getArray());
BerInteger myInt2 = new BerInteger();
myInt2.decode(berInputStream, true);
Assert.assertEquals(-20093243433l, myInt2.value.longValue());
}
use of org.openmuc.jasn1.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding4.
@Test
public void implicitEncoding4() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(127));
int length = testInteger.encode(berBAOStream, false);
Assert.assertEquals(2, length);
byte[] expectedBytes = new byte[] { 0x01, 0x7f };
Assert.assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
use of org.openmuc.jasn1.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding5.
@Test
public void implicitEncoding5() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(128));
int length = testInteger.encode(berBAOStream, false);
Assert.assertEquals(3, length);
byte[] expectedBytes = new byte[] { 0x02, 0x00, (byte) 0x80 };
Assert.assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
Aggregations