Merge branch 'patch'

This commit is contained in:
ghidra1 2020-07-16 15:33:14 -04:00
commit 837bc8416b
4 changed files with 111 additions and 47 deletions

View file

@ -15,8 +15,7 @@
*/
package ghidra.program.model.address;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import java.util.Iterator;
@ -807,6 +806,44 @@ public class AddressSetTest extends AbstractGenericTest {
Assert.assertEquals(set, newSet);
}
@Test
public void testTrimStart() {
AddressSet set = set(0x10, 0x20, 0x30, 0x40);
set.add(space2.getAddress(0x10), space2.getAddress(0x20));
set.add(space2.getAddress(0x30), space2.getAddress(0x40));
AddressSetView trimSet = AddressSetView.trimStart(set, addr(0x15));
AddressSet expectedSet = set(0x16, 0x20, 0x30, 0x40);
expectedSet.add(space2.getAddress(0x10), space2.getAddress(0x20));
expectedSet.add(space2.getAddress(0x30), space2.getAddress(0x40));
assertEquals(expectedSet, trimSet);
trimSet = AddressSetView.trimStart(set, space2.getAddress(0x15));
expectedSet = new AddressSet(space2.getAddress(0x16), space2.getAddress(0x20));
expectedSet.add(space2.getAddress(0x30), space2.getAddress(0x40));
assertEquals(expectedSet, trimSet);
}
@Test
public void testTrimEnd() {
AddressSet set = set(0x10, 0x20, 0x30, 0x40);
set.add(space2.getAddress(0x10), space2.getAddress(0x20));
set.add(space2.getAddress(0x30), space2.getAddress(0x40));
AddressSetView trimSet = AddressSetView.trimEnd(set, addr(0x15));
AddressSet expectedSet = set(0x10, 0x14);
assertEquals(expectedSet, trimSet);
trimSet = AddressSetView.trimEnd(set, space2.getAddress(0x15));
expectedSet = set(0x10, 0x20, 0x30, 0x40);
expectedSet.add(space2.getAddress(0x10), space2.getAddress(0x14));
assertEquals(expectedSet, trimSet);
}
//
////
//// public void testSequentialInsertionSpeed() {