use of org.openmuc.jasn1.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding3.
@Test
public void implicitEncoding3() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(0));
int length = testInteger.encode(berBAOStream, false);
Assert.assertEquals(2, length);
byte[] expectedBytes = new byte[] { 0x01, 0x00 };
Assert.assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
use of org.openmuc.jasn1.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding7.
@Test
public void implicitEncoding7() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(-129));
int length = testInteger.encode(berBAOStream, false);
Assert.assertEquals(3, length);
byte[] expectedBytes = new byte[] { 0x02, (byte) 0xff, (byte) 0x7f };
Assert.assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
use of org.openmuc.jasn1.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method explicitEncoding2.
@Test
public void explicitEncoding2() throws IOException {
ReverseByteArrayOutputStream berStream = new ReverseByteArrayOutputStream(50);
BerInteger testInteger = new BerInteger(BigInteger.valueOf(5555));
int length = testInteger.encode(berStream, true);
Assert.assertEquals(4, length);
byte[] expectedBytes = new byte[] { 0x02, 0x02, 0x15, (byte) 0xb3 };
Assert.assertArrayEquals(expectedBytes, berStream.getArray());
}
use of org.openmuc.jasn1.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding1.
@Test
public void implicitEncoding1() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
// 51 is the example in X.690
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(51));
int length = testInteger.encode(berBAOStream, false);
Assert.assertEquals(2, length);
byte[] expectedBytes = new byte[] { 0x01, 0x33 };
Assert.assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
use of org.openmuc.jasn1.ber.ReverseByteArrayOutputStream in project jasn1 by openmuc.
the class BerIntegerTest method implicitEncoding2.
@Test
public void implicitEncoding2() throws IOException {
ReverseByteArrayOutputStream berBAOStream = new ReverseByteArrayOutputStream(50);
IntegerUnivPrim testInteger = new IntegerUnivPrim(BigInteger.valueOf(256));
int length = testInteger.encode(berBAOStream, false);
Assert.assertEquals(3, length);
byte[] expectedBytes = new byte[] { 0x02, 0x01, 0x00 };
Assert.assertArrayEquals(expectedBytes, berBAOStream.getArray());
}
Aggregations