mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-3415 Added mutability setting to enum datatypes as well as some code
cleanup.
This commit is contained in:
parent
ccabecec3a
commit
3ea8770bae
8 changed files with 347 additions and 320 deletions
|
@ -17,15 +17,12 @@ package ghidra.program.model.data;
|
|||
|
||||
import org.junit.*;
|
||||
|
||||
import ghidra.program.model.mem.MemBuffer;
|
||||
import ghidra.program.model.mem.MemoryAccessException;
|
||||
import ghidra.program.model.address.Address;
|
||||
import ghidra.program.model.mem.ByteMemBufferImpl;
|
||||
import ghidra.util.BigEndianDataConverter;
|
||||
import ghidra.util.UniversalIdGenerator;
|
||||
import mockit.Expectations;
|
||||
import mockit.Mocked;
|
||||
|
||||
public class EnumDataTypeTest {
|
||||
@Mocked
|
||||
MemBuffer memBuffer;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
@ -33,33 +30,27 @@ public class EnumDataTypeTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testNegativeValue() throws MemoryAccessException {
|
||||
new Expectations() {
|
||||
{
|
||||
memBuffer.getInt(anyInt);
|
||||
result = 0xffffffff;
|
||||
}
|
||||
};
|
||||
public void testNegativeValue() {
|
||||
|
||||
EnumDataType enumDt = new EnumDataType("Test", 4);
|
||||
enumDt.add("bob", 0xffffffffL);
|
||||
|
||||
ByteMemBufferImpl memBuffer = new ByteMemBufferImpl(Address.NO_ADDRESS,
|
||||
BigEndianDataConverter.INSTANCE.getBytes(-1), true);
|
||||
|
||||
Assert.assertEquals("bob", enumDt.getRepresentation(memBuffer, null, 0));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUpperBitLongValue() throws MemoryAccessException {
|
||||
new Expectations() {
|
||||
{
|
||||
memBuffer.getInt(anyInt);
|
||||
result = 0x80000000;
|
||||
}
|
||||
};
|
||||
public void testUpperBitLongValue() {
|
||||
|
||||
EnumDataType enumDt = new EnumDataType("Test", 4);
|
||||
enumDt.add("bob", 0x80000000L);
|
||||
|
||||
ByteMemBufferImpl memBuffer = new ByteMemBufferImpl(Address.NO_ADDRESS,
|
||||
BigEndianDataConverter.INSTANCE.getBytes(Integer.MIN_VALUE), true);
|
||||
|
||||
Assert.assertEquals("bob", enumDt.getRepresentation(memBuffer, null, 0));
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue