Search in sources :

Example 1 with Reference

use of com.google.security.zynamics.binnavi.API.disassembly.Reference in project binnavi by google.

the class OperandExpressionTest method testReferences.

@Test
public void testReferences() throws CouldntSaveDataException, CouldntDeleteException {
    final MockOperandExpressionListener listener = new MockOperandExpressionListener();
    final MockOperandTreeNode node = new MockOperandTreeNode();
    final OperandExpression expression = new OperandExpression(node);
    expression.addListener(listener);
    final Reference reference1 = expression.addReference(new Address(0x123), ReferenceType.CALL_VIRTUAL);
    final Reference reference2 = expression.addReference(new Address(0x124), ReferenceType.DATA);
    final List<Reference> references = expression.getReferences();
    assertEquals(2, references.size());
    assertEquals(reference1, references.get(0));
    assertEquals(reference2, references.get(1));
    assertEquals("addedReference;addedReference;", listener.events);
    expression.deleteReference(reference1);
    assertEquals(1, expression.getReferences().size());
    assertEquals("addedReference;addedReference;removedReference;", listener.events);
    expression.removeListener(listener);
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) Reference(com.google.security.zynamics.binnavi.API.disassembly.Reference) OperandExpression(com.google.security.zynamics.binnavi.API.disassembly.OperandExpression) Test(org.junit.Test)

Example 2 with Reference

use of com.google.security.zynamics.binnavi.API.disassembly.Reference in project binnavi by google.

the class ReferenceTest method testConstructor.

@Test
public void testConstructor() {
    final Reference reference = new Reference(new CReference(new CAddress(0), ReferenceType.CALL_DIRECT));
    assertEquals(com.google.security.zynamics.binnavi.API.disassembly.ReferenceType.CALL_DIRECT, reference.getType());
    assertEquals(0, reference.getTarget().toLong());
    assertEquals("CALL_DIRECT Reference to 0", reference.toString());
}
Also used : CReference(com.google.security.zynamics.binnavi.disassembly.CReference) Reference(com.google.security.zynamics.binnavi.API.disassembly.Reference) CReference(com.google.security.zynamics.binnavi.disassembly.CReference) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

Reference (com.google.security.zynamics.binnavi.API.disassembly.Reference)2 Test (org.junit.Test)2 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)1 OperandExpression (com.google.security.zynamics.binnavi.API.disassembly.OperandExpression)1 CReference (com.google.security.zynamics.binnavi.disassembly.CReference)1 MockOperandTreeNode (com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode)1 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)1