summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2015-11-05 08:00:21 +0100
committerMontel Laurent <[email protected]>2015-11-05 08:00:21 +0100
commita69b54c3a42eb938d77ce47b45753b92499bad69 (patch)
tree94fd9f3ab66fe29ee7ed39019519492f5ed6d91f
parent7dfd6a1ce19987f411415f68767184ea25390aae (diff)
Port to QRegularExpression
-rw-r--r--importwizard/autodetect/balsa/balsasettings.cpp5
-rw-r--r--pimcommon/src/autotests/regularexpressiontests.cpp38
-rw-r--r--pimcommon/src/autotests/regularexpressiontests.h3
3 files changed, 44 insertions, 2 deletions
diff --git a/importwizard/autodetect/balsa/balsasettings.cpp b/importwizard/autodetect/balsa/balsasettings.cpp
index 4ef0601..046d831 100644
--- a/importwizard/autodetect/balsa/balsasettings.cpp
+++ b/importwizard/autodetect/balsa/balsasettings.cpp
@@ -27,6 +27,7 @@
#include <KConfig>
#include <KConfigGroup>
#include <QImage>
+#include <QRegularExpression>
BalsaSettings::BalsaSettings(const QString &filename, ImportWizard *parent)
: AbstractSettings(parent)
@@ -41,13 +42,13 @@ BalsaSettings::BalsaSettings(const QString &filename, ImportWizard *parent)
autoCheckDelay = grp.readEntry(QStringLiteral("AutoDelay"), -1);
}
- const QStringList mailBoxList = config.groupList().filter(QRegExp("mailbox-"));
+ const QStringList mailBoxList = config.groupList().filter(QRegularExpression("mailbox-"));
Q_FOREACH (const QString &mailBox, mailBoxList) {
KConfigGroup grp = config.group(mailBox);
readAccount(grp, autoCheck, autoCheckDelay);
}
- const QStringList smtpList = config.groupList().filter(QRegExp("smtp-server-"));
+ const QStringList smtpList = config.groupList().filter(QRegularExpression("smtp-server-"));
Q_FOREACH (const QString &smtp, smtpList) {
KConfigGroup grp = config.group(smtp);
readTransport(grp);
diff --git a/pimcommon/src/autotests/regularexpressiontests.cpp b/pimcommon/src/autotests/regularexpressiontests.cpp
index 1af860a..2fdd178 100644
--- a/pimcommon/src/autotests/regularexpressiontests.cpp
+++ b/pimcommon/src/autotests/regularexpressiontests.cpp
@@ -71,4 +71,42 @@ void RegularExpressionTests::shouldVerifyQStringListFilterConversion()
QCOMPARE(newList, expected);
}
+
+//QRegExp("mailbox-") //balsasettings.cpp
+void RegularExpressionTests::shouldVerifyQStringListFilterTwoConversion_data()
+{
+ QTest::addColumn<QStringList>("input");
+ QTest::addColumn<QStringList>("expected");
+ QTest::addColumn<QString>("regexp");
+ const QString regExpStr = QStringLiteral("mailbox-");
+ QTest::newRow("empty") << QStringList() << QStringList() << regExpStr;
+ QTest::newRow("nocatcher") << (QStringList() << QStringLiteral("ArchiveMailCollection DD") << QStringLiteral("ArchiveMailCollection") << QStringLiteral("ArchiveMailCollection ") << QString() ) << QStringList() << regExpStr;
+ QTest::newRow("catch") << (QStringList() << QStringLiteral("mailbox-12") << QStringLiteral("mailbox-5") << QStringLiteral("mailbox-8") )
+ << (QStringList() << QStringLiteral("mailbox-12") << QStringLiteral("mailbox-5") << QStringLiteral("mailbox-8") ) << regExpStr;
+ QTest::newRow("catch with empty") << (QStringList() << QString() << QStringLiteral("mailbox-12") << QStringLiteral("mailbox-5") << QString() << QStringLiteral("mailbox-8") )
+ << (QStringList() << QStringLiteral("mailbox-12") << QStringLiteral("mailbox-5") << QStringLiteral("mailbox-8") ) << regExpStr;
+
+
+ QTest::newRow("catch with not invalid string") << (QStringList() << QStringLiteral("mailbox12") << QStringLiteral("mailbox-12") << QStringLiteral("mailbox-5") << QString() << QStringLiteral("mailbox-8") )
+ << (QStringList() << QStringLiteral("mailbox-12") << QStringLiteral("mailbox-5") << QStringLiteral("mailbox-8") ) << regExpStr;
+
+ QTest::newRow("uppercase") << (QStringList() << QStringLiteral("Mailbox-12") << QStringLiteral("mailbox-12") << QStringLiteral("mailbox-5") << QString() << QStringLiteral("mailbox-8") )
+ << (QStringList() << QStringLiteral("mailbox-12") << QStringLiteral("mailbox-5") << QStringLiteral("mailbox-8") ) << regExpStr;
+
+ QTest::newRow("invalid") << (QStringList() << QStringLiteral("Mailbox-AA") << QStringLiteral("mailbox-5") << QString() << QStringLiteral("mailbox-8") )
+ << (QStringList() << QStringLiteral("mailbox-5") << QStringLiteral("mailbox-8") ) << regExpStr;
+}
+
+void RegularExpressionTests::shouldVerifyQStringListFilterTwoConversion()
+{
+ QFETCH(QStringList, input);
+ QFETCH(QStringList, expected);
+ QFETCH(QString, regexp);
+
+ QStringList newList = input.filter(QRegExp(regexp));
+ QCOMPARE(newList, expected);
+ newList = input.filter(QRegularExpression(regexp));
+ QCOMPARE(newList, expected);
+}
+
QTEST_MAIN(RegularExpressionTests)
diff --git a/pimcommon/src/autotests/regularexpressiontests.h b/pimcommon/src/autotests/regularexpressiontests.h
index b7bc328..2361dfc 100644
--- a/pimcommon/src/autotests/regularexpressiontests.h
+++ b/pimcommon/src/autotests/regularexpressiontests.h
@@ -30,6 +30,9 @@ public:
private Q_SLOTS:
void shouldVerifyQStringListFilterConversion_data();
void shouldVerifyQStringListFilterConversion();
+
+ void shouldVerifyQStringListFilterTwoConversion_data();
+ void shouldVerifyQStringListFilterTwoConversion();
};
#endif // REGULAREXPRESSIONTESTS_H