mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-29 05:38:48 +08:00
GP-0: Test fixes
This commit is contained in:
+1
-1
@@ -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);
|
||||
|
||||
+9
-5
@@ -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));
|
||||
}
|
||||
|
||||
@Test
|
||||
public 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);
|
||||
|
||||
Reference in New Issue
Block a user