Search in sources :

Example 1 with OperandExpression

use of com.google.security.zynamics.binnavi.API.disassembly.OperandExpression 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 OperandExpression

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

the class OperandExpressionTest method testConstructor.

@Test
public void testConstructor() {
    final MockOperandTreeNode node = new MockOperandTreeNode();
    final OperandExpression expression = new OperandExpression(node);
    assertEquals(ExpressionType.Register, expression.getType());
    assertEquals("Mock Replacement", expression.getReplacement());
    assertEquals("Mock Value", expression.toString());
}
Also used : MockOperandTreeNode(com.google.security.zynamics.binnavi.disassembly.MockOperandTreeNode) OperandExpression(com.google.security.zynamics.binnavi.API.disassembly.OperandExpression) Test(org.junit.Test)

Aggregations

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