Commit 03c4b80c authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Reduce duplicate code

parent 825ca351
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "resourceconvertertest.h" #include "resourceconvertertest.h"
#include <QDebug> #include <QDebug>
ResourceConverterTest::ResourceConverterTest() ResourceConverterTest::ResourceConverterTest()
{ {
} }
...@@ -27,15 +29,20 @@ ResourceConverterTest::~ResourceConverterTest() ...@@ -27,15 +29,20 @@ ResourceConverterTest::~ResourceConverterTest()
{ {
} }
QString ResourceConverterTest::prefixStr() const
{
return QStringLiteral("foo/bla bla/bli");
}
QString ResourceConverterTest::convertToFullCollectionPath(const qlonglong collectionValue) QString ResourceConverterTest::convertToFullCollectionPath(const qlonglong collectionValue)
{ {
return QStringLiteral("foo/bla bla/bli%1").arg(collectionValue); return prefixStr() + QString::number(collectionValue);
} }
Akonadi::Collection::Id ResourceConverterTest::convertFolderPathToCollectionId(const QString &path) Akonadi::Collection::Id ResourceConverterTest::convertFolderPathToCollectionId(const QString &path)
{ {
QString str = path; QString str = path;
str.remove(QStringLiteral("foo/bla bla/bli")); str.remove(prefixStr());
auto result = str.toLongLong(); auto result = str.toLongLong();
//Make sure that we use another number. //Make sure that we use another number.
if (result != -1) { if (result != -1) {
......
...@@ -36,6 +36,7 @@ public: ...@@ -36,6 +36,7 @@ public:
void setTestPath(const QString &testPath); void setTestPath(const QString &testPath);
private: private:
Q_REQUIRED_RESULT QString prefixStr() const;
QString mTestPath; QString mTestPath;
}; };
......
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