mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-10 14:38:02 -05:00
GP-5693 fixed left/right order when comparing exactly two functions
This commit is contained in:
@@ -44,6 +44,13 @@ public class AnyToAnyFunctionComparisonModel extends AbstractFunctionComparisonM
|
||||
}
|
||||
}
|
||||
|
||||
public AnyToAnyFunctionComparisonModel(Function left, Function right) {
|
||||
this.functions.add(left);
|
||||
this.functions.add(right);
|
||||
setActiveFunction(LEFT, left);
|
||||
setActiveFunction(RIGHT, right);
|
||||
}
|
||||
|
||||
public AnyToAnyFunctionComparisonModel(Function... functions) {
|
||||
this(Arrays.asList(functions));
|
||||
}
|
||||
|
||||
@@ -25,8 +25,6 @@ import org.junit.Test;
|
||||
|
||||
import generic.test.AbstractGenericTest;
|
||||
import ghidra.app.services.FunctionComparisonService;
|
||||
import ghidra.features.base.codecompare.model.AnyToAnyFunctionComparisonModel;
|
||||
import ghidra.features.base.codecompare.model.FunctionComparisonModelListener;
|
||||
import ghidra.program.database.ProgramBuilder;
|
||||
import ghidra.program.model.data.ByteDataType;
|
||||
import ghidra.program.model.data.DataType;
|
||||
@@ -97,6 +95,28 @@ public class AnyToAnyFunctionComparisonModelTest extends AbstractGhidraHeadedInt
|
||||
assertEquals(b2, model.getActiveFunction(RIGHT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPairOfFunctionsInNaturalOrder() throws Exception {
|
||||
|
||||
model = new AnyToAnyFunctionComparisonModel(b1, b2);
|
||||
|
||||
assertEquals(List.of(b1, b2), model.getFunctions(LEFT));
|
||||
assertEquals(List.of(b1, b2), model.getFunctions(RIGHT));
|
||||
assertEquals(b1, model.getActiveFunction(LEFT));
|
||||
assertEquals(b2, model.getActiveFunction(RIGHT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPairOfFunctionsOutOfNaturalOrder() throws Exception {
|
||||
|
||||
model = new AnyToAnyFunctionComparisonModel(b2, b1);
|
||||
|
||||
assertEquals(List.of(b1, b2), model.getFunctions(LEFT));
|
||||
assertEquals(List.of(b1, b2), model.getFunctions(RIGHT));
|
||||
assertEquals(b2, model.getActiveFunction(LEFT));
|
||||
assertEquals(b1, model.getActiveFunction(RIGHT));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleFunctions() throws Exception {
|
||||
assertEquals(List.of(a1, a2, b1, b2), model.getFunctions(LEFT));
|
||||
|
||||
Reference in New Issue
Block a user