Commit 1f37580a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix relation copy and valid method

REVIEW: 129515
parent 5517f37b
......@@ -47,6 +47,7 @@ private Q_SLOTS:
void testCreateFetch();
void testMonitor();
void testEqualRelation();
};
void RelationTest::initTestCase()
......@@ -159,6 +160,20 @@ void RelationTest::testMonitor()
}
}
void RelationTest::testEqualRelation()
{
Relation r1;
Item it1(45);
Item it2(46);
r1.setLeft(it1);
r1.setRight(it2);
r1.setRemoteId(QByteArrayLiteral("foo"));
r1.setType(QByteArrayLiteral("foo1"));
Relation r2 = r1;
QCOMPARE(r1, r2);
}
QTEST_AKONADIMAIN(RelationTest)
#include "relationtest.moc"
......@@ -61,6 +61,7 @@ Relation &Relation::operator=(const Relation &other)
d->left = other.d->left;
d->right = other.d->right;
d->type = other.d->type;
d->remoteId = other.d->remoteId;
return *this;
}
......@@ -69,7 +70,8 @@ bool Relation::operator==(const Relation &other) const
if (isValid() && other.isValid()) {
return d->left == other.d->left
&& d->right == other.d->right
&& d->type == other.d->type;
&& d->type == other.d->type
&& d->remoteId == other.d->remoteId;
}
return false;
}
......@@ -121,7 +123,7 @@ QByteArray Relation::remoteId() const
bool Relation::isValid() const
{
return (d->left.isValid() || !d->left.remoteId().isEmpty()) && (d->right.isValid() || !d->left.remoteId().isEmpty()) && !d->type.isEmpty();
return (d->left.isValid() || !d->left.remoteId().isEmpty()) && (d->right.isValid() || !d->right.remoteId().isEmpty()) && !d->type.isEmpty();
}
uint qHash(const Relation &relation)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment