TestPointerFactorypublic class TestPointerFactory extends TestCase Tests for the pointer factory, and the pointers themselves |
Fields Summary |
---|
private static byte[] | vp6_a | private static byte[] | vp6_b | private static byte[] | vp6_c | private static byte[] | vp6_d |
Methods Summary |
---|
public void | testCreateV4()
PointerFactory pf = new PointerFactory(4);
try {
pf.createPointer(new byte[]{}, 0);
fail();
} catch(IllegalArgumentException e) {
// As expected
}
| public void | testCreateV5()
PointerFactory pf = new PointerFactory(5);
try {
pf.createPointer(new byte[]{}, 0);
fail();
} catch(RuntimeException e) {
// Still to do
assertEquals("TODO", e.getMessage());
}
| public void | testCreateV6()
PointerFactory pf = new PointerFactory(6);
Pointer a = pf.createPointer(vp6_a, 0);
assertEquals(0x16, a.getType());
assertEquals(0x0143aff4, a.getAddress());
assertEquals(0x80, a.getOffset());
assertEquals(0x54, a.getLength());
assertEquals(0x46, a.getFormat());
assertTrue(a.destinationCompressed());
assertTrue(a.destinationHasStrings());
assertFalse(a.destinationHasChunks());
assertFalse(a.destinationHasPointers());
assertEquals(18, a.getSizeInBytes());
Pointer b = pf.createPointer(vp6_b, 0);
assertEquals(0x17, b.getType());
assertEquals(0x014fd84c, b.getAddress());
assertEquals(0xd4, b.getOffset());
assertEquals(0x20, b.getLength());
assertEquals(0x54, b.getFormat());
assertFalse(b.destinationCompressed());
assertFalse(b.destinationHasStrings());
assertFalse(b.destinationHasChunks());
assertTrue(b.destinationHasPointers());
Pointer c = pf.createPointer(vp6_c, 0);
assertEquals(0x17, c.getType());
assertEquals(0x014fd8bc, c.getAddress());
assertEquals(0xf8, c.getOffset());
assertEquals(0x20, c.getLength());
assertEquals(0x54, c.getFormat());
assertFalse(c.destinationCompressed());
assertFalse(c.destinationHasStrings());
assertFalse(c.destinationHasChunks());
assertTrue(c.destinationHasPointers());
// Type: ff Addr: 014fffac Offset: 0 Len: 0 Format: 60 From: 8a94
Pointer d = pf.createPointer(vp6_d, 0);
assertEquals(0xff, d.getType());
assertEquals(0x014fffac, d.getAddress());
assertEquals(0x00, d.getOffset());
assertEquals(0x00, d.getLength());
assertEquals(0x60, d.getFormat());
assertFalse(d.destinationCompressed());
assertFalse(d.destinationHasStrings());
assertFalse(d.destinationHasChunks());
assertFalse(d.destinationHasPointers());
| public void | testCreateV6FromMid()
PointerFactory pf = new PointerFactory(11);
// Create a from part way down the byte stream
byte[] bytes = new byte[28];
System.arraycopy(vp6_b, 0, bytes, 0, 10);
System.arraycopy(vp6_a, 0, bytes, 10, 18);
Pointer a = pf.createPointer(bytes, 10);
assertEquals(0x16, a.getType());
assertEquals(0x0143aff4, a.getAddress());
assertEquals(0x80, a.getOffset());
assertEquals(0x54, a.getLength());
assertEquals(0x46, a.getFormat());
assertTrue(a.destinationCompressed());
assertTrue(a.destinationHasStrings());
assertFalse(a.destinationHasChunks());
assertFalse(a.destinationHasPointers());
|
|