Bugfixes in BinaryStruct and some Tests for MDNS

This commit is contained in:
Ziver Koc 2016-03-15 13:55:20 +01:00
parent 64a9b4126c
commit 96e7d4489a
9 changed files with 320 additions and 117 deletions

View file

@ -42,7 +42,7 @@ public class BinaryStructOutputStreamTest {
public void basicIntTest() throws IOException {
BinaryStruct struct = new BinaryStruct() {
@BinaryField(index=1, length=32)
public int i1 = 1;
int i1 = 1;
@BinaryField(index=2, length=32)
public int i2 = 2;
};
@ -51,6 +51,20 @@ public class BinaryStructOutputStreamTest {
assertArrayEquals(new byte[]{0,0,0,1, 0,0,0,2}, data);
}
@Test
public void shortIntTest() throws IOException {
BinaryStruct struct = new BinaryStruct() {
@BinaryField(index=1, length=16)
int i1 = 1;
@BinaryField(index=2, length=16)
int i2 = 2;
};
byte[] data = BinaryStructOutputStream.serialize(struct);
assertArrayEquals(new byte[]{0,1, 0,2}, data);
}
@Test
public void basicBooleanTest() throws IOException {
BinaryStruct struct = new BinaryStruct() {