@Test
	public void testApplyRegisterRefDiffs() throws Exception {
		// 0x10018a6: p1 has reg ref to esi.
		// 0x100295a: p2 has reg ref to cx.
		// 0x1002d0b: p1 has reg ref to edi; p2 has reg ref to eax.
		// 0x10033fe: p1 & p2 both have reg ref to edi.

		Register esiReg1 = p1.getRegister("ESI");
		Register ediReg1 = p1.getRegister("EDI");

		int transactionID1 = p1.startTransaction("Test Transaction");
		ReferenceManager refManager1 = p1.getReferenceManager();
		refManager1.addRegisterReference(addr(p1, 0x10018a6), 0, esiReg1, RefType.DATA,
			SourceType.USER_DEFINED);

		refManager1.addRegisterReference(addr(p1, 0x1002cf5), 0, ediReg1, RefType.DATA,
			SourceType.USER_DEFINED);

		refManager1.addRegisterReference(addr(p1, 0x10033f6), 0, ediReg1, RefType.DATA,
			SourceType.USER_DEFINED);
		p1.endTransaction(transactionID1, true);

		ReferenceManager referenceManager2 = p2.getReferenceManager();
		Register cxReg2 = p2.getRegister("CX");
		Register ediReg2 = p2.getRegister("EDI");
		Register eaxReg2 = p2.getRegister("EAX");

		int transactionID2 = p2.startTransaction("Test Transaction");
		referenceManager2.addRegisterReference(addr(p2, 0x100295a), 0, cxReg2, RefType.DATA,
			SourceType.USER_DEFINED);

		referenceManager2.addRegisterReference(addr(p2, 0x1002cf5), 0, eaxReg2, RefType.DATA,
			SourceType.USER_DEFINED);

		referenceManager2.addRegisterReference(addr(p2, 0x10033f6), 0, ediReg2, RefType.DATA,
			SourceType.USER_DEFINED);
		p2.endTransaction(transactionID2, true);

		AddressSet as = new AddressSet();
		as.addRange(addr(0x010018a0), addr(0x010018ab));
		as.addRange(addr(0x01002cf5), addr(0x01002d0c));
		as.addRange(addr(0x01002950), addr(0x0100295c));
		as.addRange(addr(0x010033f6), addr(0x010033fe));
		programMerge = new ProgramMergeManager(p1, p2, as);
		AddressSet expectedDiffs = new AddressSet();
		expectedDiffs.addRange(addr(0x010018a6), addr(0x010018a6));
		expectedDiffs.addRange(addr(0x0100295a), addr(0x0100295a));
		expectedDiffs.addRange(addr(0x01002cf5), addr(0x01002cf5));
		programMerge.setDiffFilter(new ProgramDiffFilter(ProgramDiffFilter.REFERENCE_DIFFS));
		programMerge.setMergeFilter(
			new ProgramMergeFilter(ProgramMergeFilter.REFERENCES, ProgramMergeFilter.REPLACE));
//		printAddressSet(expectedDiffs);
//		printAddressSet(programMerge.getFilteredDifferences());
		assertEquals(expectedDiffs, programMerge.getFilteredDifferences());
		programMerge.merge(expectedDiffs, TaskMonitor.DUMMY);
		assertEquals(new AddressSet(), programMerge.getFilteredDifferences());
	}
Test that programMerge can determine the register reference differences
between Program1 and Program2.
Ghidra/Features/Base/src/test.slow/java/ghidra/program/util/ProgramMerge1Test.java