Ghidra is a software reverse engineering (SRE) framework
GP-0: Test fixes
Danef71c697a2a8
diff --git a/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java b/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.javaindex 6471062a50..16264075b2 100644--- a/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java+++ b/Ghidra/Debug/ProposedUtils/src/main/java/ghidra/generic/util/datastruct/SemisparseByteArray.java@@ -215,7 +215,7 @@ public class SemisparseByteArray {if (length < 0) {throw new IllegalArgumentException("length: " + length);}- if (loc + length < loc) {+ if (Long.compareUnsigned(loc + length, loc) < 0) {throw new IndexOutOfBoundsException("given offset and length would exceed ULONG_MAX");}UnsignedLong uLoc = UnsignedLong.fromLongBits(loc);diff --git a/Ghidra/Debug/ProposedUtils/src/test/java/ghidra/generic/util/datastruct/SemisparseByteArrayTest.java b/Ghidra/Debug/ProposedUtils/src/test/java/ghidra/generic/util/datastruct/SemisparseByteArrayTest.javaindex ec07c422e9..0743f5ca5e 100644--- a/Ghidra/Debug/ProposedUtils/src/test/java/ghidra/generic/util/datastruct/SemisparseByteArrayTest.java+++ b/Ghidra/Debug/ProposedUtils/src/test/java/ghidra/generic/util/datastruct/SemisparseByteArrayTest.java@@ -32,10 +32,14 @@ public class SemisparseByteArrayTest {private static final String HELLO_WORLD = "Hello, World!";protected static final byte[] HW = HELLO_WORLD.getBytes();- protected static Range<UnsignedLong> makeRange(long lower, long upper) {+ protected static Range<UnsignedLong> rngClosedOpen(long lower, long upper) {return Range.closedOpen(UnsignedLong.fromLongBits(lower), UnsignedLong.fromLongBits(upper));}+ protected static Range<UnsignedLong> rngClosed(long lower, long upper) {+ return Range.closed(UnsignedLong.fromLongBits(lower), UnsignedLong.fromLongBits(upper));+ }+@Testpublic void testSingles() {SemisparseByteArray cache = new SemisparseByteArray();@@ -43,16 +47,16 @@ public class SemisparseByteArrayTest {cache.putData(0, HW, 0, 1);exp.clear();- exp.add(makeRange(0, 1));+ exp.add(rngClosedOpen(0, 1));assertEquals(exp, cache.getInitialized(0, HW.length + 7));exp.clear();- exp.add(makeRange(1, HW.length));+ exp.add(rngClosed(1, HW.length - 1));assertEquals(exp, cache.getUninitialized(0, HW.length - 1));cache.putData(2, HW, 2, 1);exp.clear();- exp.add(makeRange(1, 2));- exp.add(makeRange(3, HW.length));+ exp.add(rngClosedOpen(1, 2));+ exp.add(rngClosed(3, HW.length - 1));assertEquals(exp, cache.getUninitialized(0, HW.length - 1));cache.putData(11, HW, 11, 2);