use of com.ibm.j9ddr.corereaders.memory.IMemoryRange in project openj9 by eclipse.
the class TestAbstractMemory method testOverlap.
@Test
public void testOverlap() {
IMemoryRange a = null;
IMemoryRange b = null;
// A & B don't overlap
a = new UnbackedMemorySource(0x100, 0x100, "");
b = new UnbackedMemorySource(0x200, 0x100, "");
assertFalse(a.overlaps(b));
assertFalse(b.overlaps(a));
// End of A overlaps start of B
a = new UnbackedMemorySource(0x100, 0x101, "");
b = new UnbackedMemorySource(0x200, 0x100, "");
assertTrue(a.overlaps(b));
// Start of B overlaps end of A
assertTrue(b.overlaps(a));
a = new UnbackedMemorySource(0x100, 0x300, "");
b = new UnbackedMemorySource(0x200, 0x100, "");
// B is a sub range of A
assertTrue(a.overlaps(b));
assertTrue(b.overlaps(a));
a = new MockMemorySource(new byte[] { 0xB }, 0, 0x200, 0x100);
b = new MockMemorySource(new byte[] { 0xC }, 0, 0x200, 0x150);
assertTrue(a.overlaps(b));
assertTrue(b.overlaps(a));
}
Aggregations