Commit 9442061e authored by Laurent Montel's avatar Laurent Montel 😁

continue to implement job

parent 018270c1
......@@ -53,6 +53,13 @@ void CheckDuplicateEmailsJobTest::shouldReturnEmails_data()
QTest::addColumn<QStringList>("emails");
QTest::addColumn<QMap<QString, int> >("result");
QTest::newRow("empty") << QStringList() << QMap<QString, int>();
QStringList lst;
lst.append(QStringLiteral("foo"));
lst.append(QStringLiteral("bla"));
lst.append(QStringLiteral("blo"));
QTest::newRow("emptyresultbutnotemptylist") << lst << QMap<QString, int>();
}
void CheckDuplicateEmailsJobTest::shouldReturnEmails()
......
......@@ -34,6 +34,23 @@ void CheckDuplicateEmailsJob::start()
if (mEmails.isEmpty()) {
return;
}
QMap<QString, int> results;
Q_FOREACH(const QString &email, mEmails) {
int val = results.value(email, 0);
if (val == 0) {
results.insert(email, val+1);
} else {
results[email] = val+1;
}
}
QMapIterator<QString, int> i(results);
while (i.hasNext()) {
i.next();
if (i.value() > 1) {
mResult.insert(i.key(), i.value());
}
}
}
void CheckDuplicateEmailsJob::setEmails(const QStringList &list)
......
Markdown is supported
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