Added more testcases

This commit is contained in:
Ziver Koc 2016-02-01 17:52:41 +01:00
parent b7bedc94cd
commit 644c5ab6ea
2 changed files with 36 additions and 2 deletions

View file

@ -16,7 +16,7 @@ public class BinaryStructTest {
}
@Test
public void basicTest(){
public void basicIntTest(){
BinaryTestStruct struct = new BinaryTestStruct() {
@BinaryField(index=1, length=32)
public int i1;
@ -32,4 +32,37 @@ public class BinaryStructTest {
BinaryStructParser.parse(struct, new byte[]{0,0,0,1, 0,0,0,2});
struct.assertObj();
}
@Test
public void basicBooleanTest(){
BinaryTestStruct struct = new BinaryTestStruct() {
@BinaryField(index=1, length=1)
public boolean b1;
@BinaryField(index=2, length=1)
public boolean b2;
public void assertObj(){
assertFalse(b1);
assertFalse(b2);
}
};
BinaryStructParser.parse(struct, new byte[]{0b0100_000});
struct.assertObj();
}
@Test
public void basicStringTest(){
BinaryTestStruct struct = new BinaryTestStruct() {
@BinaryField(index=1, length=8*12)
public String s1;
public void assertObj(){
assertEquals(s1, "hello world!");
}
};
BinaryStructParser.parse(struct, "hello world!".getBytes());
struct.assertObj();
}
}