void LocationSetTest::testFindDifferentRef()
{
    LocationSet set;

    SharedExp result;
    QVERIFY(!set.findDifferentRef(nullptr, result));

    set.insert(Location::regOf(REG_PENT_EAX));
    QVERIFY(!set.findDifferentRef(RefExp::get(Location::regOf(REG_PENT_EAX), nullptr), result));

    set.insert(RefExp::get(Location::regOf(REG_PENT_EAX), nullptr));
    QVERIFY(!set.findDifferentRef(RefExp::get(Location::regOf(REG_PENT_EAX), nullptr), result));

    Assign as1(Location::regOf(REG_PENT_ECX), Location::regOf(REG_PENT_EDX));
    Assign as2(Location::regOf(REG_PENT_ECX), Location::regOf(REG_PENT_EDX));

    as1.setNumber(10);
    as2.setNumber(20);

    set.insert(RefExp::get(Location::regOf(REG_PENT_ECX), &as1));
    // no other ref
    QVERIFY(!set.findDifferentRef(RefExp::get(Location::regOf(REG_PENT_ECX), &as1), result));

    set.insert(RefExp::get(Location::regOf(REG_PENT_ECX), &as2));
    // return a different ref
    QVERIFY(set.findDifferentRef(RefExp::get(Location::regOf(REG_PENT_ECX), &as1), result));
    QCOMPARE(result->toString(), QString("r25{20}"));

    // should work even when the ref is not in the set
    set.remove(RefExp::get(Location::regOf(REG_PENT_ECX), &as1));
    QVERIFY(set.findDifferentRef(RefExp::get(Location::regOf(REG_PENT_ECX), &as1), result));
    QCOMPARE(result->toString(), QString("r25{20}"));
}