Ghidra is a software reverse engineering (SRE) framework
Added a few more tests for DbObjectCache
ghidravore7af55169c0fb
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/util/ObjectCacheTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/util/ObjectCacheTest.javaindex c966b542f0..368191a1c5 100644--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/util/ObjectCacheTest.java+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/program/database/util/ObjectCacheTest.java@@ -20,12 +20,14 @@ package ghidra.program.database.util;import static org.junit.Assert.*;+import java.util.Arrays;import java.util.ConcurrentModificationException;import org.junit.Test;import ghidra.program.database.DBObjectCache;import ghidra.program.database.DatabaseObject;+import ghidra.program.model.address.KeyRange;import ghidra.test.AbstractGhidraHeadedIntegrationTest;/**@@ -77,13 +79,33 @@ public class ObjectCacheTest extends AbstractGhidraHeadedIntegrationTest {assertTrue(obj1 != obj2);obj1.getValue(); // previously, this would have caused obj2 to be removed- // from the cache, thereby causing obj3 to be a new instance.+ // from the cache, thereby causing obj3 to be a new instance.TestObj obj3 = getTestObj(1);assertTrue(obj2 == obj3);}+ @Test+ public void testDeleteRange() {+ for (int i = 0; i < 10; i++) {+ getTestObj(i);+ }+ assertEquals(10, cache.size());+ cache.delete(Arrays.asList(new KeyRange(4, 6)));+ assertEquals(7, cache.size());+ }++ @Test+ public void testDeleteBigRange() {+ for (int i = 0; i < 10; i++) {+ getTestObj(i);+ }+ assertEquals(10, cache.size());+ cache.delete(Arrays.asList(new KeyRange(2, 100)));+ assertEquals(2, cache.size());+ }+private TestObj getTestObj(int key) {TestObj obj = cache.get(key);if (obj == null) {